forked from npm/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.js
56 lines (50 loc) · 1.3 KB
/
theme.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react'
import {ThemeProvider as Provider, theme, Box} from '@primer/react'
import deepmerge from 'deepmerge'
export const NPM_RED = '#cb3837'
export const npmTheme = deepmerge(theme, {
colors: {
logoBg: NPM_RED,
},
colorSchemes: {
light: {
colors: {
accent: {
fg: NPM_RED,
emphasis: NPM_RED,
},
},
},
dark_dimmed: {
colors: {
canvas: {
default: '#333333',
},
fg: {
default: '#E1E4E8',
},
btn: {
text: '#E1E4E8',
bg: 'transparent',
border: '#444D56',
hoverBorder: '#444D56',
hoverBg: NPM_RED,
},
},
},
},
})
export const ThemeProvider = props => <Provider theme={npmTheme} {...props} />
export const Theme = React.forwardRef(function Theme({theme: colorMode, as = Box, ...props}, ref) {
return (
<Provider colorMode={colorMode} nightScheme="dark_dimmed">
{React.createElement(as, {...props, ref})}
</Provider>
)
})
export const LightTheme = React.forwardRef(function LightTheme(props, ref) {
return <Theme ref={ref} theme="light" {...props} />
})
export const DarkTheme = React.forwardRef(function DarkTheme(props, ref) {
return <Theme ref={ref} theme="dark" {...props} />
})