forked from aeharding/voyager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlobalStyles.tsx
55 lines (46 loc) · 1.26 KB
/
GlobalStyles.tsx
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
import { Global, ThemeProvider, css } from "@emotion/react";
import { useAppSelector } from "./store";
import useSystemDarkMode from "./helpers/useSystemDarkMode";
import {
baseVariables,
darkVariables,
lightVariables,
} from "./theme/variables";
import React from "react";
interface GlobalStylesProps {
children: React.ReactNode;
}
export default function GlobalStyles({ children }: GlobalStylesProps) {
const systemDarkMode = useSystemDarkMode();
const { fontSizeMultiplier, useSystemFontSize } = useAppSelector(
(state) => state.appearance.font
);
const baseFontStyles = useSystemFontSize
? css`
font: -apple-system-body;
`
: css`
font-size: ${fontSizeMultiplier}rem;
`;
const { userDarkMode, usingSystemDarkMode } = useAppSelector(
(state) => state.appearance.dark
);
const isDark = usingSystemDarkMode ? systemDarkMode : userDarkMode;
return (
<ThemeProvider theme={{ dark: isDark }}>
<Global
styles={css`
html {
${baseFontStyles}
ion-content ion-item {
font-size: 1rem;
}
}
${baseVariables}
${isDark ? darkVariables : lightVariables}
`}
/>
{children}
</ThemeProvider>
);
}