Skip to content

Commit 2d589cc

Browse files
(Pill): make link render depending on the disabled prop
see: https://v1.lightningdesignsystem.com/components/pills/#About-Pills
1 parent e691ea7 commit 2d589cc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/scripts/Pill.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useEventCallback } from './hooks';
1515
*/
1616
export type PillProps = {
1717
label?: string;
18+
fullLabel?: string;
1819
truncate?: boolean;
1920
disabled?: boolean;
2021
icon?: {
@@ -33,6 +34,7 @@ export const Pill: FC<PillProps> = (props) => {
3334
icon,
3435
disabled,
3536
label,
37+
fullLabel,
3638
truncate,
3739
className,
3840
pillRef,
@@ -56,6 +58,7 @@ export const Pill: FC<PillProps> = (props) => {
5658

5759
const pillClassNames = classnames(
5860
'slds-pill',
61+
{ 'slds-pill_link': !disabled },
5962
{ 'slds-truncate': truncate },
6063
className
6164
);
@@ -73,7 +76,15 @@ export const Pill: FC<PillProps> = (props) => {
7376
icon={icon.icon}
7477
/>
7578
) : undefined}
76-
<span className='slds-pill__label'>{label}</span>
79+
{disabled ? (
80+
<span className='slds-pill__label' title={fullLabel}>
81+
{label}
82+
</span>
83+
) : (
84+
<a className='slds-pill__action' title={fullLabel}>
85+
<span className='slds-pill__label'>{label}</span>
86+
</a>
87+
)}
7788
<Button
7889
disabled={disabled}
7990
className='slds-pill__remove'

stories/Pill.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const ControlledWithKnobs: ComponentStoryObj<typeof Pill> = {
2222
name: 'Controlled with knobs',
2323
args: {
2424
label: 'Pill Label',
25+
fullLabel: 'Full Label of the Pill',
2526
},
2627
parameters: {
2728
info: 'Pill controlled with knobs',

0 commit comments

Comments
 (0)