-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pass dark mode to theme contex
- Loading branch information
1 parent
6fcfa95
commit 278a178
Showing
36 changed files
with
399 additions
and
269 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
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
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 |
---|---|---|
@@ -1,23 +1,14 @@ | ||
import React, { FC } from 'react'; | ||
import { Source as SourceBlock } from '@component-controls/block-components'; | ||
import { useControlsContext, ControlsContextInputProps } from './BlockContext'; | ||
import { | ||
ImportSource as BaseImportSource, | ||
ImportSourceProps, | ||
} from '@component-controls/blocks'; | ||
import { ThemeProvider } from '../shared/ThemeProvider'; | ||
|
||
export type SourceProps = ControlsContextInputProps & { | ||
/** a title to display */ | ||
title?: string; | ||
}; | ||
|
||
export const ImportSource: FC<SourceProps> = ({ id, name }) => { | ||
const { component } = useControlsContext({ | ||
id, | ||
name, | ||
}); | ||
export const ImportSource: FC<ImportSourceProps> = props => { | ||
return ( | ||
<ThemeProvider> | ||
<SourceBlock> | ||
{component && component.import ? component.import : ''} | ||
</SourceBlock> | ||
<BaseImportSource {...props} /> | ||
</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 |
---|---|---|
@@ -1,23 +1,14 @@ | ||
import React, { FC } from 'react'; | ||
import { StorySource as SourceBlock } from '@component-controls/block-components'; | ||
import { useControlsContext, ControlsContextInputProps } from './BlockContext'; | ||
import { | ||
StorySource as BaseStorySource, | ||
StorySourceProps, | ||
} from '@component-controls/blocks'; | ||
import { ThemeProvider } from '../shared/ThemeProvider'; | ||
|
||
export type SourceProps = ControlsContextInputProps & { | ||
/** a title to display */ | ||
title?: string; | ||
}; | ||
|
||
export const Source: FC<SourceProps> = ({ id, name }) => { | ||
const { source, controls, args, fileSource } = useControlsContext({ | ||
id, | ||
name, | ||
}); | ||
export const Source: FC<StorySourceProps> = props => { | ||
return ( | ||
<ThemeProvider> | ||
<SourceBlock controls={controls} args={args} fileSource={fileSource}> | ||
{source} | ||
</SourceBlock> | ||
<BaseStorySource {...props} /> | ||
</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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { ControlsTable, ControlsTableProps } from './ControlsTable'; | ||
export { Source, SourceProps } from './Source'; | ||
export { Source } from './Source'; | ||
export { ImportSource } from './ImportSource'; | ||
export { BlockContextProvider, BlockContext } from './BlockContext'; | ||
export { BlockContextProvider } from './BlockContext'; |
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
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 |
---|---|---|
@@ -1,54 +1,15 @@ | ||
import React from 'react'; | ||
import { polaris as theme } from '@theme-ui/presets'; | ||
import prismTheme from '@theme-ui/prism/presets/dracula.json'; | ||
import { ThemeProvider as ThemeUIProvider } from 'theme-ui'; | ||
import { lighten } from 'polished'; | ||
import { getLuminance } from 'polished'; | ||
import { ThemeContext, Theme } from '@storybook/theming'; | ||
import { ThemeProvider as ThemeUIProvider } from '@component-controls/blocks'; | ||
|
||
export const ThemeProvider: React.FC = ({ children }) => ( | ||
<ThemeUIProvider | ||
theme={{ | ||
...theme, | ||
|
||
styles: { | ||
...theme.styles, | ||
code: { | ||
...prismTheme, | ||
}, | ||
table: { | ||
margin: 0, | ||
borderCollapse: 'collapse', | ||
fontSize: '14px', | ||
lineHeight: '20px', | ||
textAlign: 'left', | ||
width: '100%', | ||
borderSpacing: '0px', | ||
}, | ||
td: { | ||
padding: '16px 20px', | ||
}, | ||
tr: { | ||
borderTop: '1px solid rgba(0, 0, 0, 0.1)', | ||
}, | ||
}, | ||
buttons: { | ||
primary: { | ||
color: '#333', | ||
bg: '#f3f3f3', | ||
borderRadius: 5, | ||
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 0px 0px 1px inset', | ||
}, | ||
secondary: { | ||
bg: 'highlight', | ||
}, | ||
}, | ||
colors: { | ||
...theme.colors, | ||
accent: '#1EA7FD', | ||
fadedText: lighten(0.25, theme.colors.text), | ||
lightenPrimary: '#F6F9FC', | ||
}, | ||
}} | ||
> | ||
{children} | ||
</ThemeUIProvider> | ||
); | ||
export const ThemeProvider: React.FC = ({ children }) => { | ||
const { background: { content = '#ffffff' } = {} } = React.useContext<Theme>( | ||
ThemeContext as any, | ||
); | ||
return ( | ||
<ThemeUIProvider dark={getLuminance(content) < 0.5}> | ||
{children} | ||
</ThemeUIProvider> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
declare module 'global'; | ||
declare module '@storybook/addon-docs/blocks'; | ||
declare module '@theme-ui/presets'; | ||
declare module '@component-controls/loader/story-store-data'; |
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
Oops, something went wrong.