styleHandler.ts29 lines · main
| 1 | import { useContext } from 'react' |
| 2 | |
| 3 | import { ThemeContext } from './../../components/ThemeProvider/ThemeProvider' |
| 4 | import defaultTheme from './../theme/defaultTheme' |
| 5 | |
| 6 | type Keys = keyof typeof defaultTheme |
| 7 | |
| 8 | export default function styleHandler(target: Keys) { |
| 9 | let { |
| 10 | theme: { [target]: __styles }, |
| 11 | }: any = useContext(ThemeContext) |
| 12 | |
| 13 | // console.log(__styles) |
| 14 | |
| 15 | // __styles.replace(/\s+/g, ' ') |
| 16 | |
| 17 | // console.log('before string', __styles) |
| 18 | |
| 19 | // __styles = JSON.stringify(JSON.parse(__styles)) |
| 20 | __styles = JSON.stringify(__styles).replace(/\\n/g, '').replace(/\s\s+/g, ' ') |
| 21 | |
| 22 | // console.log('string', __styles) |
| 23 | |
| 24 | __styles = JSON.parse(__styles) |
| 25 | |
| 26 | // console.log('string', __styles) |
| 27 | |
| 28 | return __styles |
| 29 | } |