File tree Expand file tree Collapse file tree 2 files changed +72
-3
lines changed Expand file tree Collapse file tree 2 files changed +72
-3
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 ?: '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-badge_${ 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 @@ -41,3 +41,63 @@ export const Inverse: ComponentStoryObj<typeof Badge> = {
4141 } ,
4242 } ,
4343} ;
44+
45+ /**
46+ *
47+ */
48+ export const Lightest : ComponentStoryObj < typeof Badge > = {
49+ args : {
50+ type : 'lightest' ,
51+ children : 'Badge Label' ,
52+ } ,
53+ parameters : {
54+ docs : {
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' ,
101+ } ,
102+ } ,
103+ } ;
You can’t perform that action at this time.
0 commit comments