Skip to content

Commit

Permalink
feat(ActionList.Description): Add support for className prop (#5102)
Browse files Browse the repository at this point in the history
* add classname prop to ActionList.Description

* small location change

* add prop to docs.json
  • Loading branch information
randall-krauskopf authored Oct 15, 2024
1 parent e94f0a1 commit 2742ee5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-lamps-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Add `classname` prop support to `ActionList.Description` component
8 changes: 7 additions & 1 deletion packages/react/src/ActionList/ActionList.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@
{
"name": "sx",
"type": "SystemStyleObject"
},
{
"name": "className",
"type": "string | undefined",
"defaultValue": "",
"description": "CSS string"
}
]
},
Expand Down Expand Up @@ -326,4 +332,4 @@
]
}
]
}
}
11 changes: 10 additions & 1 deletion packages/react/src/ActionList/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export type ActionListDescriptionProps = {
* - `"block"` - Secondary text is positioned below primary text.
*/
variant?: 'inline' | 'block'
className?: string
} & SxProp

export const Description: React.FC<React.PropsWithChildren<ActionListDescriptionProps>> = ({
variant = 'inline',
sx = {},
className,
...props
}) => {
const styles = {
Expand All @@ -36,12 +38,19 @@ export const Description: React.FC<React.PropsWithChildren<ActionListDescription
const {blockDescriptionId, inlineDescriptionId} = React.useContext(ItemContext)

return variant === 'block' ? (
<Box as="span" sx={merge(styles, sx as SxProp)} id={blockDescriptionId} data-component="ActionList.Description">
<Box
as="span"
sx={merge(styles, sx as SxProp)}
id={blockDescriptionId}
className={className}
data-component="ActionList.Description"
>
{props.children}
</Box>
) : (
<Truncate
id={inlineDescriptionId}
className={className}
sx={merge(styles, sx as SxProp)}
title={props.children as string}
inline={true}
Expand Down

0 comments on commit 2742ee5

Please sign in to comment.