-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10070 from storybookjs/tech/improvements
Tech/improvements
- Loading branch information
Showing
13 changed files
with
333 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { styled } from '@storybook/theming'; | ||
|
||
export const SideBySide = styled.div({ | ||
display: 'grid', | ||
gridColumnGap: 30, | ||
gridTemplateColumns: '1fr 1fr', | ||
|
||
position: 'absolute', | ||
width: '100vw', | ||
height: '100vh', | ||
overflow: 'auto', | ||
top: 0, | ||
left: 0, | ||
|
||
'& > *': { | ||
padding: 20, | ||
}, | ||
}); |
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,123 @@ | ||
import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs/blocks'; | ||
|
||
import { themes, ThemeProvider, convert, ensure } from '@storybook/theming'; | ||
|
||
import { SideBySide } from './SideBySide'; | ||
|
||
<Meta title="Basics/ColorPalette" /> | ||
|
||
<SideBySide> | ||
<div style={{background: '#202020' }}> | ||
<ThemeProvider theme={ensure(themes.dark)}> | ||
|
||
Dark theme Colors | ||
|
||
<ColorPalette> | ||
{Object.entries(convert(themes.dark).color).map(([k,v]) => { | ||
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={{ [k]: v }} | ||
/> | ||
); | ||
} else if (typeof v === 'object') { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={Object.entries(v).reduce((acc, [key, value]) => (typeof value === 'string' && (value.match(/^#/) || value.match(/^rgb/) || key.match(/color/i))) ? {...acc, [key]: value} : acc, {})} | ||
/> | ||
); | ||
} | ||
return null; | ||
})} | ||
</ColorPalette> | ||
|
||
Dark theme Backgrounds | ||
|
||
<ColorPalette> | ||
{Object.entries(convert(themes.dark).background).map(([k,v]) => { | ||
if(k === 'color'){ | ||
return null | ||
} | ||
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={{ [k]: v }} | ||
/> | ||
); | ||
} else if (typeof v === 'object') { | ||
const colors = Object.entries(v).reduce((acc, [key, value]) => (typeof value === 'string' && (value.match(/^#/) || value.match(/^rgb/) || key.match(/color/i))) ? {...acc, [key]: value} : acc, {}); | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={colors} | ||
/> | ||
); | ||
} | ||
return null; | ||
})} | ||
</ColorPalette> | ||
</ThemeProvider></div> | ||
<div styles={{ background: '#eeeeee'}}> | ||
|
||
Light theme Colors | ||
|
||
<ColorPalette> | ||
{Object.entries(convert(themes.light).color).map(([k,v]) => { | ||
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={{ [k]: v }} | ||
/> | ||
); | ||
} else if (typeof v === 'object') { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={Object.entries(v).reduce((acc, [key, value]) => (typeof value === 'string' && (value.match(/^#/) || value.match(/^rgb/) || key.match(/color/i))) ? {...acc, [key]: value} : acc, {})} | ||
/> | ||
); | ||
} | ||
return null; | ||
})} | ||
</ColorPalette> | ||
|
||
Light theme Backgrounds | ||
|
||
<ColorPalette> | ||
{Object.entries(convert(themes.light).background).map(([k,v]) => { | ||
if(k === 'color'){ | ||
return null | ||
} | ||
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) { | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={{ [k]: v }} | ||
/> | ||
); | ||
} else if (typeof v === 'object') { | ||
const colors = Object.entries(v).reduce((acc, [key, value]) => (typeof value === 'string' && (value.match(/^#/) || value.match(/^rgb/) || key.match(/color/i))) ? {...acc, [key]: value} : acc, {}); | ||
return ( | ||
<ColorItem | ||
key={k} | ||
title={k} | ||
colors={colors} | ||
/> | ||
); | ||
} | ||
return null; | ||
})} | ||
</ColorPalette> | ||
</div> | ||
</SideBySide> |
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.