Skip to content

Commit 63ca6f2

Browse files
joshblackmperrotti
andauthored
fix(BaseStyles): set data-color-mode to auto when auto color mode (#5649)
Co-authored-by: Mike Perrotti <[email protected]>
1 parent 76bf60d commit 63ca6f2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/strong-walls-approve.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+
Update BaseStyles to set data-color-mode to auto when colorMode in ThemeProvider is auto

packages/react/src/BaseStyles.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type BaseStylesProps = PropsWithChildren & {
5454

5555
function BaseStyles(props: BaseStylesProps) {
5656
const {children, color, fontFamily, lineHeight, className, as: Component = 'div', style, ...rest} = props
57-
const {colorScheme, dayScheme, nightScheme} = useTheme()
57+
const {colorMode, colorScheme, dayScheme, nightScheme} = useTheme()
5858
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)
5959

6060
if (enabled) {
@@ -79,7 +79,7 @@ function BaseStyles(props: BaseStylesProps) {
7979
* valid color modes for primer/primitives: auto | light | dark
8080
* valid color modes for primer/primer: auto | day | night | light | dark
8181
*/
82-
data-color-mode={colorScheme?.includes('dark') ? 'dark' : 'light'}
82+
data-color-mode={colorMode === 'auto' ? 'auto' : colorScheme?.includes('dark') ? 'dark' : 'light'}
8383
data-light-theme={dayScheme}
8484
data-dark-theme={nightScheme}
8585
style={{
@@ -103,7 +103,7 @@ function BaseStyles(props: BaseStylesProps) {
103103
* valid color modes for primer/primitives: auto | light | dark
104104
* valid color modes for primer/primer: auto | day | night | light | dark
105105
*/
106-
data-color-mode={colorScheme?.includes('dark') ? 'dark' : 'light'}
106+
data-color-mode={colorMode === 'auto' ? 'auto' : colorScheme?.includes('dark') ? 'dark' : 'light'}
107107
data-light-theme={dayScheme}
108108
data-dark-theme={nightScheme}
109109
style={{
@@ -129,7 +129,7 @@ function BaseStyles(props: BaseStylesProps) {
129129
* valid color modes for primer/primitives: auto | light | dark
130130
* valid color modes for primer/primer: auto | day | night | light | dark
131131
*/
132-
data-color-mode={colorScheme?.includes('dark') ? 'dark' : 'light'}
132+
data-color-mode={colorMode === 'auto' ? 'auto' : colorScheme?.includes('dark') ? 'dark' : 'light'}
133133
data-light-theme={dayScheme}
134134
data-dark-theme={nightScheme}
135135
style={style}

0 commit comments

Comments
 (0)