File tree Expand file tree Collapse file tree 2 files changed +63
-9
lines changed Expand file tree Collapse file tree 2 files changed +63
-9
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,25 @@ import classnames from 'classnames';
55 *
66 */
77export type BadgeProps = {
8- type ?: 'default ' | 'shade ' | 'inverse ' ;
8+ type ?: 'inverse ' | 'lightest ' | 'success' | 'warning' | 'error ';
99 label ?: string ;
1010} & HTMLAttributes < HTMLSpanElement > ;
1111
1212/**
1313 *
1414 */
1515export const Badge : FC < BadgeProps > = ( { type, label, ...props } ) => {
16- const typeClassName = type ? `slds-theme_${ type } ` : null ;
17- const badgeClassNames = classnames ( 'slds-badge' , typeClassName ) ;
16+ const typeClassName = / ^ ( i n v e r s e | l i g h t e s t ) $ / . test ( type ?? '' )
17+ ? `slds-badge_${ type } `
18+ : null ;
19+ const themeClassName = / ^ ( s u c c e s s | w a r n i n g | e r r o r ) $ / . test ( type ?? '' )
20+ ? `slds-theme_${ type } `
21+ : null ;
22+ const badgeClassNames = classnames (
23+ 'slds-badge' ,
24+ typeClassName ,
25+ themeClassName
26+ ) ;
1827 return (
1928 < span className = { badgeClassNames } { ...props } >
2029 { label || props . children }
Original file line number Diff line number Diff line change @@ -30,29 +30,74 @@ export const Default: ComponentStoryObj<typeof Badge> = {
3030/**
3131 *
3232 */
33- export const Shade : ComponentStoryObj < typeof Badge > = {
33+ export const Inverse : ComponentStoryObj < typeof Badge > = {
3434 args : {
35- type : 'shade ' ,
35+ type : 'inverse ' ,
3636 children : 'Badge Label' ,
3737 } ,
3838 parameters : {
3939 docs : {
40- storyDescription : 'Badge with type: shade ' ,
40+ storyDescription : 'Badge with type: inverse ' ,
4141 } ,
4242 } ,
4343} ;
4444
4545/**
4646 *
4747 */
48- export const Inverse : ComponentStoryObj < typeof Badge > = {
48+ export const Lightest : ComponentStoryObj < typeof Badge > = {
4949 args : {
50- type : 'inverse ' ,
50+ type : 'lightest ' ,
5151 children : 'Badge Label' ,
5252 } ,
5353 parameters : {
5454 docs : {
55- storyDescription : 'Badge with type: inverse' ,
55+ storyDescription : 'Badge with type: lightest' ,
56+ } ,
57+ } ,
58+ } ;
59+
60+ /**
61+ *
62+ */
63+ export const Success : ComponentStoryObj < typeof Badge > = {
64+ args : {
65+ type : 'success' ,
66+ children : 'Badge Label' ,
67+ } ,
68+ parameters : {
69+ docs : {
70+ storyDescription : 'Badge with type: success' ,
71+ } ,
72+ } ,
73+ } ;
74+
75+ /**
76+ *
77+ */
78+ export const Warning : ComponentStoryObj < typeof Badge > = {
79+ args : {
80+ type : 'warning' ,
81+ children : 'Badge Label' ,
82+ } ,
83+ parameters : {
84+ docs : {
85+ storyDescription : 'Badge with type: warning' ,
86+ } ,
87+ } ,
88+ } ;
89+
90+ /**
91+ *
92+ */
93+ export const Error : ComponentStoryObj < typeof Badge > = {
94+ args : {
95+ type : 'error' ,
96+ children : 'Badge Label' ,
97+ } ,
98+ parameters : {
99+ docs : {
100+ storyDescription : 'Badge with type: error' ,
56101 } ,
57102 } ,
58103} ;
You can’t perform that action at this time.
0 commit comments