Skip to content

Commit 99d8907

Browse files
authored
Merge branch 'main' into pagelayout-hidden-prop
2 parents 343a5c3 + e28aadb commit 99d8907

File tree

10 files changed

+278
-150
lines changed

10 files changed

+278
-150
lines changed

.changeset/breezy-trainers-drop.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+
Updates SegmentedControl styles to use component primitives.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"dependencies": {
8181
"@primer/behaviors": "^1.1.1",
8282
"@primer/octicons-react": "^17.3.0",
83-
"@primer/primitives": "7.8.4",
83+
"@primer/primitives": "7.9.0",
8484
"@radix-ui/react-polymorphic": "^0.0.14",
8585
"@react-aria/ssr": "^3.1.0",
8686
"@styled-system/css": "^5.1.5",

src/SegmentedControl/SegmentedControl.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ type SegmentedControlProps = {
2222
} & SxProp
2323

2424
const getSegmentedControlStyles = (props?: SegmentedControlProps) => ({
25-
// TODO: update color primitive name(s) to use different primitives:
26-
// - try to use general 'control' primitives (e.g.: https://primer.style/primitives/spacing#ui-control)
27-
// - when that's not possible, use specific to segmented controls
28-
backgroundColor: 'switchTrack.bg', // TODO: update primitive when it is available
25+
backgroundColor: 'segmentedControl.bg',
2926
borderColor: 'border.default',
3027
borderRadius: 2,
3128
borderStyle: 'solid',
3229
borderWidth: 1,
3330
display: props?.fullWidth ? 'flex' : 'inline-flex',
34-
height: '32px' // TODO: use primitive `primer.control.medium.size` when it is available
31+
height: '32px' // TODO: use primitive `control.medium.size` when it is available
3532
})
3633

3734
const Root: React.FC<SegmentedControlProps> = ({

src/SegmentedControl/__snapshots__/SegmentedControl.test.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports[`SegmentedControl renders consistently 1`] = `
4444
-ms-flex-align: center;
4545
align-items: center;
4646
background-color: #f6f8fa;
47-
border-color: #8c959f;
47+
border-color: #6e7781;
4848
border-style: solid;
4949
border-width: 1px;
5050
border-radius: var(--segmented-control-outer-radius);
@@ -157,11 +157,11 @@ exports[`SegmentedControl renders consistently 1`] = `
157157
}
158158
159159
.c2:hover .segmentedControl-content {
160-
background-color: rgba(208,215,222,0.32);
160+
background-color: rgba(175,184,193,0.2);
161161
}
162162
163163
.c2:active .segmentedControl-content {
164-
background-color: rgba(208,215,222,0.48);
164+
background-color: rgba(175,184,193,0.4);
165165
}
166166
167167
.c2:first-child {
@@ -256,11 +256,11 @@ exports[`SegmentedControl renders consistently 1`] = `
256256
}
257257
258258
.c3:hover .segmentedControl-content {
259-
background-color: rgba(208,215,222,0.32);
259+
background-color: rgba(175,184,193,0.2);
260260
}
261261
262262
.c3:active .segmentedControl-content {
263-
background-color: rgba(208,215,222,0.48);
263+
background-color: rgba(175,184,193,0.4);
264264
}
265265
266266
.c3:first-child {

src/SegmentedControl/getSegmentedControlStyles.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ export const getSegmentedControlButtonStyles = (
4545
padding: props?.selected ? 0 : 'var(--segmented-control-button-bg-inset)',
4646
position: 'relative',
4747
...(props?.isIconOnly && {
48-
height: 'var(--primer-control-medium-size, 32px)',
49-
width: 'var(--primer-control-medium-size, 32px)'
48+
height: '32px', // TODO: use primitive `control.medium.size` when it is available
49+
width: '32px' // TODO: use primitive `control.medium.size` when it is available
5050
}),
5151

5252
'.segmentedControl-content': {
5353
alignItems: 'center',
5454
backgroundColor: props?.selected ? 'btn.bg' : 'transparent',
55-
borderColor: props?.selected ? '#8c959f' : 'transparent', // TODO: use a functional primitive for the selected border color when it is available
55+
borderColor: props?.selected ? 'segmentedControl.button.selected.border' : 'transparent',
5656
borderStyle: 'solid',
5757
borderWidth: 1,
5858
borderRadius: props?.selected
@@ -76,11 +76,11 @@ export const getSegmentedControlButtonStyles = (
7676
},
7777

7878
':hover .segmentedControl-content': {
79-
backgroundColor: props?.selected ? undefined : 'actionListItem.default.hoverBg' // TODO: replace with a functional primitive
79+
backgroundColor: props?.selected ? undefined : 'segmentedControl.button.hover.bg'
8080
},
8181

8282
':active .segmentedControl-content': {
83-
backgroundColor: props?.selected ? undefined : 'actionListItem.default.activeBg' // TODO: replace with a functional primitive
83+
backgroundColor: props?.selected ? undefined : 'segmentedControl.button.active.bg'
8484
},
8585

8686
// Icon-only buttons render the button inside of an element rendered by the Tooltip component.

src/__tests__/__snapshots__/SideNav.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ exports[`SideNav SideNav.Link renders consistently 1`] = `
9090
9191
.c1.variant-normal > .c0[aria-current='page']::before,
9292
.c1.variant-normal > .c0[aria-selected='true']::before {
93-
background-color: #FD8C73;
93+
background-color: #fd8c73;
9494
}
9595
9696
.c1.variant-lightweight > .c0 {

src/__tests__/__snapshots__/UnderlineNavLink.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports[`UnderlineNav.Link adds activeClassName={SELECTED_CLASS} when it gets a
3030
3131
.c0.PRC-selected {
3232
color: #24292f;
33-
border-bottom-color: #FD8C73;
33+
border-bottom-color: #fd8c73;
3434
}
3535
3636
.c0.PRC-selected .PRC-UnderlineNav-octicon {
@@ -90,7 +90,7 @@ exports[`UnderlineNav.Link renders consistently 1`] = `
9090
9191
.c0.PRC-selected {
9292
color: #24292f;
93-
border-bottom-color: #FD8C73;
93+
border-bottom-color: #fd8c73;
9494
}
9595
9696
.c0.PRC-selected .PRC-UnderlineNav-octicon {
@@ -148,7 +148,7 @@ exports[`UnderlineNav.Link respects the "selected" prop 1`] = `
148148
149149
.c0.PRC-selected {
150150
color: #24292f;
151-
border-bottom-color: #FD8C73;
151+
border-bottom-color: #fd8c73;
152152
}
153153
154154
.c0.PRC-selected .PRC-UnderlineNav-octicon {

0 commit comments

Comments
 (0)