Skip to content

Commit e53228c

Browse files
Add size prop to ActionList.LinkItem (#6470)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dylanatsmith <[email protected]>
1 parent a9108e1 commit e53228c

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed
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 `size` prop to ActionList.LinkItem component. The `size` prop accepts `'medium'` (default) or `'large'` values and provides the same styling options as ActionList.Item for consistent sizing across ActionList components.

packages/react/src/ActionList/ActionList.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ LinkItemPlayground.args = {
227227
disabled: false,
228228
id: 'item-1',
229229
variant: 'default',
230+
size: 'medium',
230231
inactiveText: '',
231232
leadingVisual: null,
232233
loading: false,
@@ -242,6 +243,12 @@ LinkItemPlayground.argTypes = {
242243
control: 'radio',
243244
options: ['default', 'danger'],
244245
},
246+
size: {
247+
control: {
248+
type: 'radio',
249+
},
250+
options: ['medium', 'large'],
251+
},
245252
role: {
246253
type: 'string',
247254
},

packages/react/src/ActionList/ActionList.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,23 @@ describe('ActionList', () => {
176176
expect(descriptions[1]).toHaveAttribute('title', 'Complex content')
177177
expect(descriptions[2]).not.toHaveAttribute('title')
178178
})
179+
180+
it('should support size prop on LinkItem', () => {
181+
const {container} = HTMLRender(
182+
<ActionList>
183+
<ActionList.LinkItem href="//github.com" size="large">
184+
Large Link Item
185+
</ActionList.LinkItem>
186+
<ActionList.LinkItem href="//github.com" size="medium">
187+
Medium Link Item
188+
</ActionList.LinkItem>
189+
<ActionList.LinkItem href="//github.com">Default Link Item</ActionList.LinkItem>
190+
</ActionList>,
191+
)
192+
193+
const linkElements = container.querySelectorAll('a')
194+
expect(linkElements[0]).toHaveAttribute('data-size', 'large')
195+
expect(linkElements[1]).toHaveAttribute('data-size', 'medium')
196+
expect(linkElements[2]).toHaveAttribute('data-size', 'medium') // default should be medium
197+
})
179198
})

packages/react/src/ActionList/LinkItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ type LinkProps = {
2121
// LinkItem does not support selected, loading, variants, etc.
2222
export type ActionListLinkItemProps = Pick<
2323
ActionListItemProps,
24-
'active' | 'children' | 'sx' | 'inactiveText' | 'variant'
24+
'active' | 'children' | 'sx' | 'inactiveText' | 'variant' | 'size'
2525
> &
2626
LinkProps
2727

2828
export const LinkItem = React.forwardRef(
29-
({sx, active, inactiveText, variant, as: Component, className, ...props}, forwardedRef) => {
29+
({sx, active, inactiveText, variant, size, as: Component, className, ...props}, forwardedRef) => {
3030
return (
3131
<Item
3232
className={className}
3333
active={active}
3434
inactiveText={inactiveText}
3535
data-inactive={inactiveText ? true : undefined}
3636
variant={variant}
37+
size={size}
3738
sx={sx}
3839
_PrivateItemWrapper={({children, onClick, ...rest}) => {
3940
const clickHandler = (event: React.MouseEvent<HTMLElement>) => {

0 commit comments

Comments
 (0)