Skip to content

Commit

Permalink
feat(fuselage): Callout Custom Icon #881
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris authored Oct 21, 2022
1 parent cfa253f commit 3dadd68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/fuselage/src/components/Callout/Callout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ Danger.args = {
Danger.parameters = setStoryDescription(
'Communicates that an important aspect of the system is not working as expected and requires urgent action.'
);

export const CustomIcon = Template.bind({});
CustomIcon.args = {
title: 'This is a danger message',
icon: 'hash',
};
13 changes: 10 additions & 3 deletions packages/fuselage/src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ type CalloutProps = Omit<ComponentProps<typeof Box>, 'type' | 'name'> & {
type?: 'info' | 'success' | 'warning' | 'danger';
title?: ReactNode;
children?: ReactNode;
icon?: ComponentProps<typeof Icon>['name'];
};

export const Callout = ({ children, title, type, ...props }: CalloutProps) => {
const iconName: 'info-circled' | 'checkmark-circled' | 'warning' | 'ban' =
export const Callout = ({
type,
title,
children,
icon,
...props
}: CalloutProps) => {
const defaultIcon =
(type === 'info' && 'info-circled') ||
(type === 'success' && 'checkmark-circled') ||
(type === 'warning' && 'warning') ||
Expand All @@ -20,7 +27,7 @@ export const Callout = ({ children, title, type, ...props }: CalloutProps) => {

return (
<Box is='section' rcx-callout rcx-callout--type={type} {...props}>
<Icon name={iconName} size='x20' />
<Icon name={icon || defaultIcon} size='x20' />
<Box rcx-callout__wrapper>
{title && (
<Box is='h1' rcx-callout__title>
Expand Down

0 comments on commit 3dadd68

Please sign in to comment.