Commit 8d9b4e4a by Alex Khomenko Committed by GitHub

Display palette and colors for dark and light themes in storybook (#29848)

parent 555d3c27
import React from 'react';
import { Colors } from './Colors';
export default {
title: 'Docs Overview/Colors',
component: Colors,
decorators: [],
parameters: {
options: {
showPanel: false,
},
docs: {},
},
};
export const ColorsDemo = () => {
return <Colors />;
};
import React from 'react';
import { css, cx } from 'emotion';
import darkTheme from '../../themes/dark';
import lightTheme from '../../themes/light';
import { useStyles } from '../../themes';
export const Colors = () => {
const styles = useStyles(getStyles);
const renderColors = (color: any) => {
return Object.entries(color)
.sort((a, b) => a[0].localeCompare(b[0]))
.map(([name, color]: [string, any]) => {
return (
<div key={name} className={styles.wrapper}>
<span className={styles.name}>
{name} ({color})
</span>
<span
className={cx(
styles.color,
css`
background: ${color};
`
)}
/>
</div>
);
});
};
return (
<div className={styles.container}>
<div>
<h2>Light theme</h2>
<h3 className={styles.subheader}>Palette</h3>
{renderColors(lightTheme.palette)}
<h3 className={styles.subheader}>Colors</h3>
{renderColors(lightTheme.colors)}
</div>
<div>
<h2>Dark theme</h2>
<h3 className={styles.subheader}>Palette</h3>
{renderColors(darkTheme.palette)}
<h3 className={styles.subheader}>Colors</h3>
{renderColors(darkTheme.colors)}
</div>
</div>
);
};
const getStyles = () => {
return {
subheader: css`
margin: 20px 0;
`,
container: css`
display: flex;
justify-content: space-around;
width: 100%;
`,
wrapper: css`
display: flex;
align-items: center;
`,
name: css`
width: 250px;
`,
color: css`
display: inline-block;
width: 50px;
height: 50px;
`,
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment