Files
personal-website/components/GlobalStyles.tsx
T
2021-01-12 23:27:52 +01:00

44 lines
1.1 KiB
TypeScript

import { FC, useContext } from 'react';
import { createGlobalStyle } from 'styled-components';
import { DarkModeContext } from '../components/DarkMode';
interface Props {
dark: boolean;
}
const Global = createGlobalStyle<Props>`
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Source Code Pro', monospace;
font-size: 17px;
line-height: 1.5;
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}
body {
background: ${({ dark, theme }) =>
dark ? theme.colors.dark.background : theme.colors.light.background};
color: ${({ dark, theme }) => (dark ? theme.colors.dark.text : theme.colors.light.text)};
transition: color 250ms ease-in-out, background 250ms ease-in-out;
scroll-behavior: smooth;
}
body::-webkit-scrollbar {
width: 0.5rem;
}
body::-webkit-scrollbar-thumb {
background-color: ${({ dark, theme }) => (dark ? theme.colors.dark.text : theme.colors.light.text)};
}
`;
const GlobalStyles: FC = () => {
const { dark } = useContext(DarkModeContext);
return <Global dark={dark} />;
};
export default GlobalStyles;