Skip to content

Commit

Permalink
[storybook] Add tone selection to container
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent 6394669 commit 3843dd8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
12 changes: 11 additions & 1 deletion packages/@sanity/storybook/src/components/centeredContainer.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
align-items: center;
justify-content: center;

& > * {
@nest & > * {
min-width: 0;
}

@nest &[data-tone='component'] {
background-color: var(--component-bg);
color: var(--component-text-color);
}

@nest &[data-tone='navbar'] {
background-color: var(--main-navigation-color);
color: var(--main-navigation-color--inverted);
}
}
20 changes: 16 additions & 4 deletions packages/@sanity/storybook/src/components/centeredContainer.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import classNames from 'classnames'
import {color, number} from 'part:@sanity/storybook/addons/knobs'
import {number, select} from 'part:@sanity/storybook/addons/knobs'
import React from 'react'

import styles from './centeredContainer.css'

export function CenteredContainer({children, className: classNameProp, style, ...restProps}) {
const backgroundColor = color('View color', 'rgba(255, 255, 255, 0', 'test')
const fontSize = number('Font size (rem)', 1, {range: true, min: 0.5, max: 3, step: 0.25})
const fontSize = number(
'Font size (rem)',
1,
{range: true, min: 0.5, max: 3, step: 0.25},
'Container'
)
const className = classNames(styles.root, classNameProp)
const tone =
select(
'Background tone',
{'': '(none)', component: 'Component', navbar: 'Navbar'},
'component',
'Container'
) || undefined

return (
<div
{...restProps}
className={className}
style={{backgroundColor, fontSize: `${fontSize}rem`, ...(style || {})}}
data-tone={tone}
style={{fontSize: `${fontSize}rem`, ...(style || {})}}
>
{children}
</div>
Expand Down

0 comments on commit 3843dd8

Please sign in to comment.