-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { ReactNode } from 'react' | ||
import { Tokens } from '../../tokens' | ||
|
||
export const AVAILABLE_THEMES = { | ||
org: 'betterplace.org', | ||
at: 'betterplace.at', | ||
me: 'betterplace.me', | ||
} | ||
|
||
type Theme = keyof typeof AVAILABLE_THEMES | ||
|
||
type ThemeProviderProps = { | ||
theme: Theme | ||
children: ReactNode | ||
} | ||
|
||
export const ThemeProvider = (props: ThemeProviderProps) => { | ||
const tokens = { | ||
globals: Tokens.globals, | ||
[props.theme]: Tokens[props.theme], | ||
} | ||
|
||
console.log(tokens) | ||
|
||
const ThemeContext = React.createContext(props.theme) | ||
|
||
return ( | ||
<ThemeContext.Provider value={props.theme}> | ||
<div className={'theme-' + props.theme}>{props.children}</div> | ||
</ThemeContext.Provider> | ||
) | ||
} | ||
|
||
export const withThemeProvider = (Story: any, context: { globals: { theme: Theme } }) => { | ||
return ( | ||
<ThemeProvider theme={context.globals.theme}> | ||
<Story {...context} /> | ||
</ThemeProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"colors": { | ||
"colorRed100": "#ff0000", | ||
"colorGreen100": "#00ff00", | ||
"colorGreen300": "#00aa00" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import globals from './globals.json' | ||
import org from './theme-org.json' | ||
import at from './theme-at.json' | ||
import me from './theme-me.json' | ||
|
||
export const Tokens = { | ||
globals, | ||
org, | ||
at, | ||
me, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"colors": { | ||
"colorPrimary": "colorGreen300" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"colors": { | ||
"colorPrimary": "colorRed100" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"colors": { | ||
"colorPrimary": "colorGreen100" | ||
} | ||
} |