Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fuselage): Callout Custom Icon #881

Merged
merged 2 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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