File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change 11import React , {
2- ReactHTML ,
32 HTMLAttributes ,
43 MouseEvent ,
54 KeyboardEvent ,
@@ -16,9 +15,9 @@ import { useEventCallback } from './hooks';
1615 */
1716export type PillProps = {
1817 label ?: string ;
18+ title ?: string ;
1919 truncate ?: boolean ;
2020 disabled ?: boolean ;
21- tag ?: keyof ReactHTML ;
2221 icon ?: {
2322 category ?: IconCategory ;
2423 icon ?: string ;
@@ -35,7 +34,7 @@ export const Pill: FC<PillProps> = (props) => {
3534 icon,
3635 disabled,
3736 label,
38- tag ,
37+ title ,
3938 truncate,
4039 className,
4140 pillRef,
@@ -57,28 +56,33 @@ export const Pill: FC<PillProps> = (props) => {
5756 }
5857 } ) ;
5958
60- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61- const Tag : any = disabled ? 'span' : tag || 'a' ;
6259 const pillClassNames = classnames (
6360 'slds-pill' ,
61+ { 'slds-pill_link' : ! disabled } ,
6462 { 'slds-truncate' : truncate } ,
6563 className
6664 ) ;
6765 return (
68- < Tag
66+ < span
6967 ref = { pillRef }
7068 className = { pillClassNames }
7169 onKeyDown = { onKeyDown }
7270 onClick = { onClick }
7371 >
7472 { icon && icon . icon ? (
75- < Icon
76- className = 'slds-pill__icon'
77- category = { icon . category }
78- icon = { icon . icon }
79- />
73+ < span className = 'slds-pill__icon_container' >
74+ < Icon category = { icon . category } icon = { icon . icon } />
75+ </ span >
8076 ) : undefined }
81- < span className = 'slds-pill__label' > { label } </ span >
77+ { disabled ? (
78+ < span className = 'slds-pill__label' title = { title } >
79+ { label }
80+ </ span >
81+ ) : (
82+ < a className = 'slds-pill__action' title = { title } >
83+ < span className = 'slds-pill__label' > { label } </ span >
84+ </ a >
85+ ) }
8286 < Button
8387 disabled = { disabled }
8488 className = 'slds-pill__remove'
@@ -88,6 +92,6 @@ export const Pill: FC<PillProps> = (props) => {
8892 tabIndex = { - 1 }
8993 onClick = { onPillRemove }
9094 />
91- </ Tag >
95+ </ span >
9296 ) ;
9397} ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export const ControlledWithKnobs: ComponentStoryObj<typeof Pill> = {
2222 name : 'Controlled with knobs' ,
2323 args : {
2424 label : 'Pill Label' ,
25+ title : 'Full Label of the Pill' ,
2526 } ,
2627 parameters : {
2728 info : 'Pill controlled with knobs' ,
You can’t perform that action at this time.
0 commit comments