Skip to content

Commit ee4b76f

Browse files
Button: Do not add [data-size="medium"]` when size is explicitly specified as medium (#2929)
* Do not add data attribute for medium size * add changeset * add comment that I accidently deleted
1 parent 6bf9e67 commit ee4b76f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.changeset/calm-moons-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Button: Fixes the style override issue when size is explicitly specified as medium

src/Button/Button.dev.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ export const TestSxProp = () => {
3838
const count = 4
3939
return (
4040
<div style={{display: 'flex', flexDirection: 'row', gap: '1rem'}}>
41+
<Button
42+
size="medium"
43+
sx={{
44+
color: 'deeppink',
45+
}}
46+
>
47+
Medium Pink
48+
</Button>
4149
<Button
4250
size="small"
4351
sx={{

src/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function generateCustomSxProp(
6767
providedSx: BetterSystemStyleObject,
6868
) {
6969
// Possible data attributes: data-size, data-block, data-no-visuals
70-
const size = props.size ? `[data-size="${props.size}"]` : ''
70+
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
7171
const block = props.block ? `[data-block="block"]` : ''
7272
const noVisuals = props.leadingIcon || props.trailingIcon || props.trailingAction ? '' : '[data-no-visuals="true"]'
7373

0 commit comments

Comments
 (0)