File tree Expand file tree Collapse file tree 3 files changed +123
-0
lines changed Expand file tree Collapse file tree 3 files changed +123
-0
lines changed Original file line number Diff line number Diff line change 1+ .wrapper {
2+ @apply border rounded-full flex items-center w-fit py-1 pl-1 pr-2 .5 text-sm font-medium ;
3+
4+ .icon {
5+ @apply w-4 h- 4;
6+ }
7+
8+ .badge {
9+ @apply rounded-full border px-2 .5 py-0 .5 mr-2 text-white ;
10+ }
11+
12+ .message {
13+ @apply mr- 1;
14+ }
15+
16+ & .default {
17+ @apply border-green-200 bg-green-100 dark :border- green- 700 dark :bg- neutral- 900;
18+
19+ .icon {
20+ @apply text-green-500 dark :text- green- 300;
21+ }
22+
23+ .badge {
24+ @apply border-green-200 dark :border- green- 600 bg- green- 600;
25+ }
26+
27+ .message {
28+ @apply text-green-700 dark :text- green- 300;
29+ }
30+ }
31+
32+ & .error {
33+ @apply border-danger-200 dark :border- danger- 700 bg- danger- 100 dark :bg- neutral- 900;
34+
35+ .icon {
36+ @apply text-danger-500 dark :text- danger- 300;
37+ }
38+
39+ .badge {
40+ @apply border-danger-200 dark :border- danger- 600 bg- danger- 600;
41+ }
42+
43+ .message {
44+ @apply text-danger-700 dark :text- danger- 300;
45+ }
46+ }
47+
48+ & .warning {
49+ @apply border-warning-200 dark :border- warning- 700 bg- warning- 100 dark :bg- neutral- 900;
50+
51+ .icon {
52+ @apply text-warning-500 dark :text- warning- 300;
53+ }
54+
55+ .badge {
56+ @apply border-warning-200 dark :border- warning- 600 bg- warning- 600;
57+ }
58+
59+ .message {
60+ @apply text-warning-700 dark :text- warning- 300;
61+ }
62+ }
63+ }
Original file line number Diff line number Diff line change 1+ import Badge from './' ;
2+ import type { Meta as MetaObj , StoryObj } from '@storybook/react' ;
3+
4+ type Story = StoryObj < typeof Badge > ;
5+ type Meta = MetaObj < typeof Badge > ;
6+
7+ export const Default : Story = {
8+ args : {
9+ href : '/' ,
10+ children : 'OpenJS Foundation Certification 2023' ,
11+ kind : 'default' ,
12+ badgeText : 'New' ,
13+ } ,
14+ } ;
15+
16+ export const Error : Story = {
17+ args : {
18+ href : '/' ,
19+ children : 'OpenJS Foundation Certification 2023' ,
20+ kind : 'error' ,
21+ badgeText : 'New' ,
22+ } ,
23+ } ;
24+
25+ export const Warning : Story = {
26+ args : {
27+ href : '/' ,
28+ children : 'OpenJS Foundation Certification 2023' ,
29+ kind : 'warning' ,
30+ badgeText : 'New' ,
31+ } ,
32+ } ;
33+
34+ export default { component : Badge } as Meta ;
Original file line number Diff line number Diff line change 1+ import ArrowRightIcon from '@heroicons/react/24/solid/ArrowRightIcon' ;
2+ import LocalizedLink from '@/components/LocalizedLink' ;
3+ import type { ComponentProps , FC , PropsWithChildren } from 'react' ;
4+ import type Link from 'next/link' ;
5+
6+ import styles from './index.module.scss' ;
7+
8+ type BadgeProps = {
9+ kind ?: 'default' | 'warning' | 'error' ;
10+ badgeText ?: string ;
11+ } & ComponentProps < typeof Link > ;
12+
13+ const Badge : FC < PropsWithChildren < BadgeProps > > = ( {
14+ kind = 'default' ,
15+ badgeText,
16+ children,
17+ ...args
18+ } ) => (
19+ < LocalizedLink className = { `${ styles . wrapper } ${ styles [ kind ] } ` } { ...args } >
20+ { badgeText && < span className = { styles . badge } > { badgeText } </ span > }
21+ < span className = { styles . message } > { children } </ span >
22+ < ArrowRightIcon className = { styles . icon } />
23+ </ LocalizedLink >
24+ ) ;
25+
26+ export default Badge ;
You can’t perform that action at this time.
0 commit comments