1
1
mirror of https://github.com/primer/css.git synced 2024-12-02 07:53:06 +03:00
css/docs/.storybook/preview.js
Vinicius Depizzol 6b4089d8b3
PageLayout component / Layout beta + storybook (#1737)
* storybook for layout alpha

* the beginning of layout beta

* simplify spacing structure and other things

this is a reminder that all the abstraction can happen in the viewComponent;
there's no need to flood the css with constricted behaviors

* add rowGap & dividers, clean spacing props

* content-width support, sticky pane

* cleanup props

* add preset property

* !default

* component name & settings example

* typo, cleaner header & footer template

* fix preset options

* mobile-friendly responsive behavior

* ongoing flowVertical breakpoint behavior

* finish panePosition + responsive pos & dividers

* panePosition fix

* add splitAsPage, finish responsive divider

* Layout beta ongoing updates (#1779)

- simplify component with better names
- rename it to `PageLayout`
- stylelint cleanup
- finalize responsive variants
- finalize variant-specific region dividers

* add minimum 320px viewport

* fix layout alpha, add layout patterns

* cleanup bg colors, stylint pass

* enable debug bg colors

* colorful regions by default for dubugging

* "Needless disable for primer/no-undefined-vars"

* Stylelint auto-fixes

* line breaks a EOF

* introduce page layout behavior as a sb helper

* children props in specialized components

* cleanup

* typo

* discussions responsive temporary example

* layout alpha descriptions

* pageLayout prop descriptions

* cleanup

* fix conflict

* copy

* responsiveVariant storybook description

* 0 padding on fullscreen storybook layout

* has__divider for boolean props

* cleanup, copy

* cleanup

* cleanup

* cleanup chained selections/descendants

* Stylelint auto-fixes

* inherit values for responsive divider props

* consolidate modifier names for responsive props

Changelog:

### CSS classes
- `PageLayout--variant-stackRegions` → `PageLayout--responsive-stackRegions`
- `PageLayout--variant-separateRegions` → `PageLayout--responsive-separateRegions`
- `PageLayout--variant-stackRegions-panePos-*` →`PageLayout--responsive-panePos-*`
- `PageLayout--variant-separateRegions-primary-*` →`PageLayout--responsive-primary-*`
- `PageLayout-region--hasDivider-*` → `PageLayout-region--dividerNarrow-*`

### Prop names
- `responsivePrimaryRegion` → `primaryRegion`
- `paneResponsivePosition` → `panePositionNarrow`
- `paneResponsiveDivider` → `paneDividerNarrow`
- `headerResponsiveDivider`→ `headerDividerNarrow`
- `footerResponsiveDivider`→ `footerDividerNarrow`

### Args
- `*DividerNarrow` props have new `inherit` value by default

* Create lemon-games-swim.md

* Update lemon-games-swim.md

* cleanup, header+footer dividers as local modifiers

* hasFooterDivider instead of footerDivider

* fix primaryRegion selector

Co-authored-by: Actions Auto Build <actions@github.com>
Co-authored-by: Katie Langerman <langermank@github.com>
2021-12-21 12:51:59 -08:00

151 lines
2.8 KiB
JavaScript

import '../../src/docs.scss'
import '../../src/index.scss'
import '../../src/base/index.scss'
import '../src/stories/helpers/storybook-styles.scss'
import renderToHTML from '../src/stories/helpers/code-snippet-html-helper'
const customViewports = {
minXS: {
name: 'XS (min)',
styles: {
width: '320px',
height: '100%'
}
},
medXS: {
name: 'XS (med)',
styles: {
width: '375px',
height: '100%'
}
},
maxXS: {
name: 'XS (max)',
styles: {
width: '543px',
height: '100%'
}
},
minSM: {
name: 'SM (min)',
styles: {
width: '544px',
height: '100%'
}
},
maxSM: {
name: 'SM (max)',
styles: {
width: '767px',
height: '100%'
}
},
minMD: {
name: 'MD (min)',
styles: {
width: '768px',
height: '100%'
}
},
maxMD: {
name: 'MD (max)',
styles: {
width: '1011px',
height: '100%'
}
},
minLG: {
name: 'LG (min)',
styles: {
width: '1012px',
height: '100%'
}
},
maxLG: {
name: 'LG (max)',
styles: {
width: '1279px',
height: '100%'
}
},
minXL: {
name: 'XL (min)',
styles: {
width: '1280px',
height: '100%'
}
},
medXL: {
name: 'XL (med)',
styles: {
width: '1440px',
height: '100%'
}
}
}
export const parameters = {
actions: {argTypesRegex: '^on[A-Z].*'},
docs: {
transformSource: (src, storyContext) => renderToHTML(storyContext.storyFn)
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
},
expanded: true
},
layout: 'padded',
html: {
root: '#story' // target id for html tab (should be direct parent of <Story /> for easy copy/paste)
},
viewport: {viewports: customViewports}
}
const themes = [
'light',
'light_colorblind',
'light_high_contrast',
'dark',
'dark_dimmed',
'dark_high_contrast',
'dark_colorblind'
]
export const globalTypes = {
theme: {
name: 'Theme',
description: 'Switch themes',
defaultValue: 'light',
toolbar: {
icon: 'circlehollow',
items: [...themes, 'all'],
showName: true
}
}
}
export const decorators = [
(Story, context) => {
return (
<div class="theme-wrap">
{ themes.map((theme) => {
if (context.globals.theme === theme || context.globals.theme === 'all') {
return <div
id="story"
className="story-wrap"
data-color-mode={theme.startsWith('dark') ? 'dark' : 'light'}
data-light-theme={theme.startsWith('light') ? theme : undefined}
data-dark-theme={theme.startsWith('dark') ? theme : undefined}
>
<Story {...context} />
</div>
}
})}
</div>
)
}
]