Skip to content

Commit e56edcc

Browse files
feat(InfoBox): introduce (#7352)
* feat(StabilityIndex): introduce * ooopss Signed-off-by: Augustin Mauroy <[email protected]> * fix:css code style * update from feedback * use danger * add style for `a` * use alertBox name * fix --------- Signed-off-by: Augustin Mauroy <[email protected]>
1 parent 56cdefb commit e56edcc

File tree

4 files changed

+170
-6
lines changed

4 files changed

+170
-6
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.alertBox {
2+
@apply flex
3+
flex-row
4+
items-center
5+
gap-2
6+
rounded
7+
px-4
8+
py-3
9+
text-sm
10+
text-white;
11+
12+
a {
13+
@apply font-ibm-plex-mono
14+
text-white
15+
underline;
16+
17+
&:hover {
18+
@apply no-underline;
19+
}
20+
}
21+
22+
&.small {
23+
@apply gap-1
24+
py-2
25+
text-xs;
26+
27+
.title {
28+
@apply px-1;
29+
}
30+
}
31+
32+
.title {
33+
@apply rounded-sm
34+
px-1.5;
35+
}
36+
37+
svg {
38+
@apply inline
39+
size-5;
40+
}
41+
42+
&.info {
43+
@apply bg-info-600;
44+
45+
.title {
46+
@apply bg-info-700;
47+
}
48+
}
49+
50+
&.success {
51+
@apply bg-green-600;
52+
53+
.title {
54+
@apply bg-green-700;
55+
}
56+
}
57+
58+
&.warning {
59+
@apply bg-warning-600;
60+
61+
.title {
62+
@apply bg-warning-700;
63+
}
64+
}
65+
66+
&.danger {
67+
@apply bg-danger-600;
68+
69+
.title {
70+
@apply bg-danger-700;
71+
}
72+
}
73+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { ExclamationCircleIcon } from '@heroicons/react/24/solid';
2+
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
3+
4+
import AlertBox from '@/components/Common/AlertBox';
5+
6+
type Story = StoryObj<typeof AlertBox>;
7+
type Meta = MetaObj<typeof AlertBox>;
8+
9+
export const Info: Story = {
10+
args: {
11+
level: 'info',
12+
title: '3',
13+
children:
14+
'Legacy. Although this feature is unlikely to be removed and is still covered by semantic versioning guarantees, it is no longer actively maintained, and other alternatives are available.',
15+
size: 'default',
16+
},
17+
};
18+
19+
export const Success: Story = {
20+
args: {
21+
level: 'success',
22+
title: '2',
23+
children:
24+
'Stable. Compatibility with the npm ecosystem is a high priority.',
25+
size: 'default',
26+
},
27+
};
28+
29+
export const Warning: Story = {
30+
args: {
31+
level: 'warning',
32+
title: '1',
33+
children:
34+
'Experimental. The feature is not subject to semantic versioning rules. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments. Experimental features are subdivided into stages:',
35+
size: 'default',
36+
},
37+
};
38+
39+
export const Danger: Story = {
40+
args: {
41+
level: 'danger',
42+
title: '0',
43+
children:
44+
'Deprecated. The feature may emit warnings. Backward compatibility is not guaranteed.',
45+
size: 'default',
46+
},
47+
};
48+
49+
export const WithIcon: Story = {
50+
args: {
51+
level: 'info',
52+
title: '3',
53+
children: (
54+
<p>
55+
Lorem ipsum dolor sit amet <ExclamationCircleIcon /> consectetur
56+
adipisicing elit. Inventore, quasi doloremque. Totam, earum velit, sunt
57+
voluptates fugiat beatae praesentium quis magni explicabo repudiandae
58+
nam aut molestias ex ad sequi eum!
59+
</p>
60+
),
61+
size: 'default',
62+
},
63+
};
64+
65+
export default {
66+
component: AlertBox,
67+
argTypes: {
68+
size: {
69+
options: ['default', 'small'],
70+
control: { type: 'radio' },
71+
},
72+
},
73+
} as Meta;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import classNames from 'classnames';
2+
import type { FC, PropsWithChildren } from 'react';
3+
4+
import styles from './index.module.css';
5+
6+
type AlertBoxProps = PropsWithChildren<{
7+
level: 'info' | 'success' | 'warning' | 'danger';
8+
title: string;
9+
size?: 'default' | 'small';
10+
}>;
11+
12+
const AlertBox: FC<AlertBoxProps> = ({
13+
level,
14+
title,
15+
children,
16+
size = 'default',
17+
}) => (
18+
<div className={classNames(styles.alertBox, styles[level], styles[size])}>
19+
<span className={styles.title}>{title}</span>
20+
{children}
21+
</div>
22+
);
23+
24+
export default AlertBox;

apps/site/next-env.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)