diff options
author | Amine Mouafik <amine@mouafik.fr> | 2019-05-12 20:00:41 +0700 |
---|---|---|
committer | Amine Mouafik <amine@mouafik.fr> | 2019-05-12 20:00:41 +0700 |
commit | d8a1d5f9151cc31f4c2b5c0096a35e49b2c74d61 (patch) | |
tree | 3974d449d8ef389fc61bf880ae758b5debc22a80 /uidev/src/withTheme/index.tsx | |
parent | Use dark background in SVG logo (diff) | |
parent | Update CHANGELOG.md (diff) | |
download | ferdium-app-d8a1d5f9151cc31f4c2b5c0096a35e49b2c74d61.tar.gz ferdium-app-d8a1d5f9151cc31f4c2b5c0096a35e49b2c74d61.tar.zst ferdium-app-d8a1d5f9151cc31f4c2b5c0096a35e49b2c74d61.zip |
Merge tag 'v5.1.0'
# Conflicts:
# README.md
# src/components/layout/AppLayout.js
Diffstat (limited to 'uidev/src/withTheme/index.tsx')
-rw-r--r-- | uidev/src/withTheme/index.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/uidev/src/withTheme/index.tsx b/uidev/src/withTheme/index.tsx new file mode 100644 index 000000000..17a1074d3 --- /dev/null +++ b/uidev/src/withTheme/index.tsx | |||
@@ -0,0 +1,50 @@ | |||
1 | import { theme, Theme, ThemeType } from '@meetfranz/theme'; | ||
2 | import { Classes } from 'jss'; | ||
3 | import React from 'react'; | ||
4 | import injectSheet, { ThemeProvider } from 'react-jss'; | ||
5 | |||
6 | const defaultTheme = { | ||
7 | name: 'Default', | ||
8 | variables: theme(ThemeType.default), | ||
9 | }; | ||
10 | |||
11 | const darkTheme = { | ||
12 | name: 'Dark Mode', | ||
13 | variables: theme(ThemeType.dark), | ||
14 | }; | ||
15 | |||
16 | const themes = [defaultTheme, darkTheme]; | ||
17 | |||
18 | const styles = (theme: Theme) => ({ | ||
19 | title: { | ||
20 | fontSize: 14, | ||
21 | }, | ||
22 | container: { | ||
23 | border: theme.inputBorder, | ||
24 | borderRadius: theme.borderRadiusSmall, | ||
25 | marginBottom: 20, | ||
26 | padding: 20, | ||
27 | background: theme.colorContentBackground, | ||
28 | }, | ||
29 | }); | ||
30 | |||
31 | const Container = injectSheet(styles)(({ name, classes, story }: { name: string, classes: Classes, story: React.ReactNode }) => ( | ||
32 | <article> | ||
33 | <h1 className={classes.title}>{name}</h1> | ||
34 | <div className={classes.container}> | ||
35 | {story} | ||
36 | </div> | ||
37 | </article> | ||
38 | )); | ||
39 | |||
40 | export const WithTheme = ({ children }: {children: React.ReactChild}) => { | ||
41 | return ( | ||
42 | <> | ||
43 | {themes.map((theme, key) => ( | ||
44 | <ThemeProvider key={key} theme={theme.variables}> | ||
45 | <Container story={children} name={theme.name} /> | ||
46 | </ThemeProvider> | ||
47 | ))} | ||
48 | </> | ||
49 | ); | ||
50 | }; | ||