Skip to content

Commit 7917cc7

Browse files
author
Younes Chellaf
committed
Add Icon as jsx child and extend story to cover errorLayout inside a card
1 parent 4b82439 commit 7917cc7

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

src/layouts/ErrorLayout/ErrorLayout.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
.bk-error-icon {
2424
color: bk.$color-blackberry-100;
25-
font-size: 7rem;
25+
font-size: 5rem;
2626
padding: bk.$spacing-4;
2727
}
2828

src/layouts/ErrorLayout/ErrorLayout.stories.tsx

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import * as React from 'react';
66

77
import type { Meta, StoryObj } from '@storybook/react-vite';
8+
import { Icon } from '../../components/graphics/Icon/Icon.tsx';
89
import { Button } from '../../components/actions/Button/Button.tsx';
910
import { ErrorLayout } from './ErrorLayout.tsx';
11+
import { Card } from '../../components/containers/Card/Card.tsx';
1012

1113
type ErrorLayoutArgs = React.ComponentProps<typeof ErrorLayout>;
1214
type Story = StoryObj<ErrorLayoutArgs>;
@@ -19,13 +21,13 @@ export default {
1921
},
2022
} satisfies Meta<ErrorLayoutArgs>;
2123

22-
export const ErrorApp: Story = {
23-
render: () => {
24-
return (
24+
export const ErrorLayoutStandard : Story = {
25+
args: {
26+
children: (
2527
<ErrorLayout
2628
title="Error"
2729
description="In case there is a secondary text to be added withIn case there is a secondary text to be added with"
28-
icon="badge-dashboard"
30+
icon={<Icon icon="badge-dashboard"/>}
2931
redirectLinkLabel="Link"
3032
redirectTo="#"
3133
>
@@ -38,6 +40,32 @@ export const ErrorApp: Story = {
3840
</Button>
3941
</ErrorLayout.Actions>
4042
</ErrorLayout>
41-
);
43+
)
44+
}
45+
};
46+
47+
export const ErrorLayoutInCard : Story = {
48+
decorators: [Story => <Card><Story/></Card>],
49+
args: {
50+
children: (
51+
<>
52+
<ErrorLayout
53+
title="Error"
54+
description="In case there is a secondary text to be added withIn case there is a secondary text to be added with"
55+
icon={<Icon icon="audit-log"/>}
56+
redirectLinkLabel="Link"
57+
redirectTo="#"
58+
>
59+
<ErrorLayout.Actions>
60+
<Button kind ='secondary'>
61+
Back
62+
</Button>
63+
<Button kind ='primary'>
64+
Refresh
65+
</Button>
66+
</ErrorLayout.Actions>
67+
</ErrorLayout>
68+
</>
69+
),
4270
},
4371
};

src/layouts/ErrorLayout/ErrorLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type ErorrLayoutProps = Omit<ComponentProps<'div'>, 'title'> & {
2323
flat?: undefined | boolean,
2424

2525
/** The error icon */
26-
icon: IconName,
26+
icon?: undefined | React.ReactElement,
2727

2828
/** The title of the error, to be displayed in the under the icon. */
2929
title: string,
@@ -63,7 +63,7 @@ export const ErrorLayout = Object.assign(
6363
)}
6464
>
6565
<div className={cl['bk-error-layout__content']}>
66-
<Icon className={cl['bk-error-icon']} icon={icon}/>
66+
{icon && <span className={cx('_icon', cl['bk-error-icon'])}>{icon}</span>}
6767
<H2 className={cl['bk-error-title']}>{title}</H2>
6868
{description &&
6969
<div className={cl['bk-error-description']}>

0 commit comments

Comments
 (0)