Skip to content

Commit

Permalink
Use import for focus-visible instead of require (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreif committed Jun 27, 2022
1 parent e5be3db commit b3a98ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-buckets-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Converted commonjs `require` of `focus-visible` to an esm `import`
1 change: 1 addition & 0 deletions @types/focus-visible/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'focus-visible'
6 changes: 3 additions & 3 deletions src/BaseStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './co
import {useTheme} from './ThemeProvider'
import {ComponentProps} from './utils/types'

// load polyfill for :focus-visible
import 'focus-visible'

const GlobalStyle = createGlobalStyle<{colorScheme?: 'light' | 'dark'}>`
* { box-sizing: border-box; }
body { margin: 0; }
Expand Down Expand Up @@ -36,9 +39,6 @@ function BaseStyles(props: BaseStylesProps) {
const {children, ...rest} = props
const {colorScheme} = useTheme()

// load polyfill for :focus-visible
require('focus-visible')

return (
<Base {...rest} data-portal-root>
<GlobalStyle colorScheme={colorScheme?.includes('dark') ? 'dark' : 'light'} />
Expand Down

0 comments on commit b3a98ba

Please sign in to comment.