Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-docs-site-to-react-18
Browse files Browse the repository at this point in the history
  • Loading branch information
radglob authored Jun 20, 2023
2 parents 5bc0862 + baf907d commit f222b7d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"@types/lodash.keyby": "4.6.7",
"@types/node": "16.11.11",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.9",
"@types/react-dom": "18.2.6",
"@typescript-eslint/eslint-plugin": "5.59.6",
"@typescript-eslint/parser": "5.59.6",
"ajv": "8.12.0",
Expand Down
2 changes: 1 addition & 1 deletion script/set-react-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const versions = new Map([
},
{
name: '@types/react-dom',
version: '18.0.9',
version: '18.2.6',
},
{
name: 'react',
Expand Down
14 changes: 3 additions & 11 deletions src/BaseStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import styled, {createGlobalStyle} from 'styled-components'
import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants'
import {useTheme, defaultColorMode, ColorModeWithAuto} from './ThemeProvider'
import {useTheme} from './ThemeProvider'
import {ComponentProps} from './utils/types'

// load polyfill for :focus-visible
Expand Down Expand Up @@ -38,21 +38,13 @@ export type BaseStylesProps = ComponentProps<typeof Base>
function BaseStyles(props: BaseStylesProps) {
const {children, color = 'fg.default', fontFamily = 'normal', lineHeight = 'default', ...rest} = props

const {colorScheme, colorMode, dayScheme, nightScheme} = useTheme()
const {colorScheme, dayScheme, nightScheme} = useTheme()

/**
* We need to map valid primer/react color modes onto valid color modes for primer/primitives
* valid color modes for primer/primitives: auto | light | dark
* valid color modes for primer/primer: auto | day | night | light | dark
*/
type colorModesForPrimitives = 'auto' | 'light' | 'dark'
const primerColorModeToPrimitiveColorMode: {[key in ColorModeWithAuto]: colorModesForPrimitives} = {
auto: 'auto',
light: 'light',
dark: 'dark',
day: 'light',
night: 'dark',
}

return (
<Base
Expand All @@ -61,7 +53,7 @@ function BaseStyles(props: BaseStylesProps) {
fontFamily={fontFamily}
lineHeight={lineHeight}
data-portal-root
data-color-mode={primerColorModeToPrimitiveColorMode[colorMode || defaultColorMode]}
data-color-mode={colorScheme?.includes('dark') ? 'dark' : 'light'}
data-light-theme={dayScheme}
data-dark-theme={nightScheme}
>
Expand Down

0 comments on commit f222b7d

Please sign in to comment.