Skip to content

Commit

Permalink
Tooltip popover theming (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana authored Oct 20, 2020
1 parent b142745 commit 778d365
Show file tree
Hide file tree
Showing 18 changed files with 426 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .storybook/index.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This is the global dassana stylesheet. It should match the global stylesheet in web-orchestrator. */

@import '~normalize.css';
@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400&display=swap');

html,
body,
Expand Down
17 changes: 14 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ const { sideBySide, left, right } = LayoutTypes

const { dark, light } = ThemeType

// Storybook theme needs an extra "type" property to conditionally render a dark or light themed story for Popover and Tooltip components.
export interface SbTheme extends Theme {
type: ThemeType.dark | ThemeType.light
}

const sbThemes = {
[dark]: { ...themes[dark], type: dark },
[light]: { ...themes[light], type: light }
}

const useStyles = createUseStyles({
storyContainer: {
display: 'flex'
Expand Down Expand Up @@ -70,6 +80,7 @@ const StoryWrapper: FC<StoryWrapperProps> = ({
const classes = useStyles()
const wrapperClasses = cn({
dark,
light: !dark,
[classes.storyWrapper]: true
})

Expand Down Expand Up @@ -107,12 +118,12 @@ const ThemeDecorator = (
case sideBySide: {
return (
<div className={classes.storyContainer}>
<ThemeProvider theme={themes[light]}>
<ThemeProvider theme={sbThemes[light]}>
<ThemedBlock side={left}>
<ComponentStory />
</ThemedBlock>
</ThemeProvider>
<ThemeProvider theme={themes[dark]}>
<ThemeProvider theme={sbThemes[dark]}>
<ThemedBlock side={right}>
<ComponentStory />
</ThemedBlock>
Expand All @@ -123,7 +134,7 @@ const ThemeDecorator = (

default: {
return (
<ThemeProvider theme={themes[theme]}>
<ThemeProvider theme={sbThemes[theme as ThemeType]}>
<ThemedCanvasBg />
<StoryWrapper dark={theme === dark}>
<ComponentStory />
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 778d365

Please sign in to comment.