Skip to content

Commit 804b7d3

Browse files
committed
add loading prop
1 parent 0c73871 commit 804b7d3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.changeset/calm-hoops-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Add loading support to ActionList.TrailingAction component.

packages/react/src/ActionList/ActionList.docs.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@
251251
"name": "href",
252252
"type": "string",
253253
"description": "href when the TrailingAction is rendered as a link."
254+
},
255+
{
256+
"name": "loading",
257+
"type": "boolean",
258+
"defaultValue": "false",
259+
"description": "Whether the TrailingAction is in a loading state. When true, the TrailingAction will render a spinner instead of an icon."
254260
}
255261
]
256262
},
@@ -393,4 +399,4 @@
393399
]
394400
}
395401
]
396-
}
402+
}

packages/react/src/ActionList/TrailingAction.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ export type ActionListTrailingActionProps = ElementProps & {
1919
icon?: React.ElementType
2020
label: string
2121
className?: string
22+
/**
23+
* Specify whether the action is in a loading state
24+
*/
25+
loading?: boolean
2226
}
2327

2428
export const TrailingAction = forwardRef(
25-
({as = 'button', icon, label, href = null, className, ...props}, forwardedRef) => {
29+
({as = 'button', icon, label, href = null, className, loading, ...props}, forwardedRef) => {
2630
return (
2731
<span className={clsx(className, classes.TrailingAction)}>
2832
{icon ? (
@@ -33,6 +37,7 @@ export const TrailingAction = forwardRef(
3337
variant="invisible"
3438
tooltipDirection="w"
3539
href={href}
40+
loading={loading}
3641
// @ts-expect-error StyledButton wants both Anchor and Button refs
3742
ref={forwardedRef}
3843
className={classes.TrailingActionButton}
@@ -44,6 +49,7 @@ export const TrailingAction = forwardRef(
4449
variant="invisible"
4550
as={as}
4651
href={href}
52+
loading={loading}
4753
ref={forwardedRef}
4854
className={classes.TrailingActionButton}
4955
{...props}

0 commit comments

Comments
 (0)