Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ActionList.Description): Add support for className prop #5102

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading