aboutsummaryrefslogtreecommitdiffstats
path: root/uidev/src/withTheme/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'uidev/src/withTheme/index.tsx')
-rw-r--r--uidev/src/withTheme/index.tsx50
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 @@
1import { theme, Theme, ThemeType } from '@meetfranz/theme';
2import { Classes } from 'jss';
3import React from 'react';
4import injectSheet, { ThemeProvider } from 'react-jss';
5
6const defaultTheme = {
7 name: 'Default',
8 variables: theme(ThemeType.default),
9};
10
11const darkTheme = {
12 name: 'Dark Mode',
13 variables: theme(ThemeType.dark),
14};
15
16const themes = [defaultTheme, darkTheme];
17
18const 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
31const 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
40export 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};