-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: Add basic dark/light mode support
- Loading branch information
1 parent
c0c0b45
commit 6883e5f
Showing
6 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {useMedia} from 'react-use'; | ||
import {ThemeProvider as EmotionThemeProvider} from '@emotion/react'; | ||
|
||
import theme from 'src/theme'; | ||
|
||
type Props = Omit<React.ComponentProps<typeof EmotionThemeProvider>, 'theme'>; | ||
|
||
const ThemeProvider = (props: Props) => ( | ||
<EmotionThemeProvider | ||
theme={theme[useMedia('(prefers-color-scheme: dark)') ? 'dark' : 'light']} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default ThemeProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {mergeWith} from 'lodash'; | ||
|
||
export type ProlinkTheme = typeof light; | ||
|
||
declare module '@emotion/react' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface Theme extends ProlinkTheme {} | ||
} | ||
|
||
const colors = { | ||
white: '#fff', | ||
}; | ||
|
||
const light = { | ||
background: colors.white, | ||
backgroundSecondary: '#fafafa', | ||
border: '#eee', | ||
|
||
control: { | ||
border: '#ccc', | ||
borderFocus: '#aaa', | ||
placeholderText: '#737386', | ||
}, | ||
|
||
primaryText: '#28272b', | ||
subText: '#888', | ||
|
||
button: { | ||
primary: { | ||
backgroundHover: '#000', | ||
background: '#28272b', | ||
color: colors.white, | ||
}, | ||
muted: { | ||
backgroundHover: '#e5e5e5', | ||
background: '#eee', | ||
color: 'inherit', | ||
}, | ||
}, | ||
}; | ||
|
||
const dark = mergeWith( | ||
{ | ||
background: '#28272b', | ||
primaryText: '#fff', | ||
}, | ||
light, | ||
(value, srcValue) => (value !== undefined ? value : srcValue) | ||
); | ||
|
||
export default {light, dark}; |