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

Button: Do not add [data-size="medium"]` when size is explicitly specified as medium #2929

Merged
merged 3 commits into from
Feb 23, 2023
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/calm-moons-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Button: Fixes the style override issue when size is explicitly specified as medium
8 changes: 8 additions & 0 deletions src/Button/Button.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export const TestSxProp = () => {
const count = 4
return (
<div style={{display: 'flex', flexDirection: 'row', gap: '1rem'}}>
<Button
size="medium"
sx={{
color: 'deeppink',
}}
>
Medium Pink
</Button>
<Button
size="small"
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function generateCustomSxProp(
providedSx: BetterSystemStyleObject,
) {
// Possible data attributes: data-size, data-block, data-no-visuals
const size = props.size ? `[data-size="${props.size}"]` : ''
const size = props.size && props.size !== 'medium' ? `[data-size="${props.size}"]` : '' // medium is a default size therefore it doesn't have a data attribute that used for styling
const block = props.block ? `[data-block="block"]` : ''
const noVisuals = props.leadingIcon || props.trailingIcon || props.trailingAction ? '' : '[data-no-visuals="true"]'

Expand Down