Skip to content

Commit

Permalink
Button: Do not add [data-size="medium"]` when size is explicitly spec…
Browse files Browse the repository at this point in the history
…ified as medium (#2929)

* Do not add data attribute for medium size

* add changeset

* add comment that I accidently deleted
  • Loading branch information
broccolinisoup committed Feb 23, 2023
1 parent 6bf9e67 commit ee4b76f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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

0 comments on commit ee4b76f

Please sign in to comment.