Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageLayout component / Layout beta + storybook #1737

Merged
merged 56 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9fd9354
storybook for layout alpha
vdepizzol Nov 2, 2021
e7f1742
Merge branch 'main' of https://github.com/primer/css into layout-stories
vdepizzol Nov 3, 2021
cbd3da7
the beginning of layout beta
vdepizzol Nov 8, 2021
66bebe1
simplify spacing structure and other things
vdepizzol Nov 9, 2021
f3e6953
add rowGap & dividers, clean spacing props
vdepizzol Nov 10, 2021
bd151ed
content-width support, sticky pane
vdepizzol Nov 10, 2021
4270c7b
cleanup props
vdepizzol Nov 10, 2021
debfde9
add preset property
vdepizzol Nov 12, 2021
e24b05b
!default
vdepizzol Nov 13, 2021
896dd94
component name & settings example
vdepizzol Nov 15, 2021
93faca8
typo, cleaner header & footer template
vdepizzol Nov 15, 2021
a73f383
fix preset options
vdepizzol Nov 15, 2021
368bcf6
mobile-friendly responsive behavior
vdepizzol Nov 16, 2021
22ddcdf
ongoing flowVertical breakpoint behavior
vdepizzol Nov 16, 2021
06ab457
finish panePosition + responsive pos & dividers
vdepizzol Nov 23, 2021
28a9e40
panePosition fix
vdepizzol Nov 23, 2021
398c874
add splitAsPage, finish responsive divider
vdepizzol Nov 23, 2021
5faad0a
Layout beta ongoing updates (#1779)
vdepizzol Dec 8, 2021
df66858
add minimum 320px viewport
vdepizzol Dec 9, 2021
2605797
fix layout alpha, add layout patterns
vdepizzol Dec 9, 2021
1115ebc
cleanup bg colors, stylint pass
vdepizzol Dec 9, 2021
ede115c
enable debug bg colors
vdepizzol Dec 9, 2021
b655c33
colorful regions by default for dubugging
vdepizzol Dec 9, 2021
d116b21
"Needless disable for primer/no-undefined-vars"
vdepizzol Dec 9, 2021
c75e91b
Stylelint auto-fixes
actions-user Dec 9, 2021
dc9a79d
line breaks a EOF
vdepizzol Dec 9, 2021
e9ec951
Merge branch 'layout-stories' of https://github.com/primer/css into l…
vdepizzol Dec 9, 2021
a326a8d
introduce page layout behavior as a sb helper
vdepizzol Dec 9, 2021
fef80f4
children props in specialized components
vdepizzol Dec 10, 2021
56afe07
cleanup
vdepizzol Dec 10, 2021
bbfcee3
typo
vdepizzol Dec 10, 2021
fda8c21
discussions responsive temporary example
vdepizzol Dec 10, 2021
59bb220
layout alpha descriptions
vdepizzol Dec 11, 2021
dc06b5e
pageLayout prop descriptions
vdepizzol Dec 11, 2021
3657b2a
cleanup
vdepizzol Dec 11, 2021
9d0eb1b
Merge branch 'main' into layout-stories
vdepizzol Dec 11, 2021
1737cfd
fix conflict
vdepizzol Dec 11, 2021
1c2dcad
copy
vdepizzol Dec 14, 2021
aa6eba5
responsiveVariant storybook description
vdepizzol Dec 15, 2021
a1f4107
Merge branch 'main' of https://github.com/primer/css into layout-stories
vdepizzol Dec 16, 2021
e0abc21
0 padding on fullscreen storybook layout
vdepizzol Dec 16, 2021
b4332b2
has__divider for boolean props
vdepizzol Dec 16, 2021
7491602
cleanup, copy
vdepizzol Dec 16, 2021
fb8c477
cleanup
vdepizzol Dec 16, 2021
afa6061
cleanup
vdepizzol Dec 16, 2021
0ce4caa
cleanup chained selections/descendants
vdepizzol Dec 16, 2021
3a98c9c
Stylelint auto-fixes
actions-user Dec 16, 2021
a652d73
inherit values for responsive divider props
vdepizzol Dec 21, 2021
4e707a6
consolidate modifier names for responsive props
vdepizzol Dec 21, 2021
e8eb697
Create lemon-games-swim.md
langermank Dec 21, 2021
f039894
Update lemon-games-swim.md
langermank Dec 21, 2021
8bd4a3d
Merge branch 'main' into layout-stories
vdepizzol Dec 21, 2021
e351cea
cleanup, header+footer dividers as local modifiers
vdepizzol Dec 21, 2021
3fd332c
Merge branch 'layout-stories' of https://github.com/primer/css into l…
vdepizzol Dec 21, 2021
8641c30
hasFooterDivider instead of footerDivider
vdepizzol Dec 21, 2021
0f5f357
fix primaryRegion selector
vdepizzol Dec 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
the beginning of layout beta
  • Loading branch information
vdepizzol committed Nov 8, 2021
commit cbd3da75455640fbc553f2dd3674d1e7332c7540
390 changes: 390 additions & 0 deletions docs/src/stories/components/Layout/LayoutBeta.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,390 @@
import React from 'react'
import clsx from 'clsx'

export default {
title: 'Components/Layout/Beta',
excludeStories: ['ComponentTemplateName'],
argTypes: {

// Wrapper

wrapperSizing: {
options: [0, 1, 2, 3],
mapping: ['', 'container-md', 'container-lg', 'container-xl'],
control: {
type: 'select',
labels: ['fluid', 'md', 'lg', 'xl']
},
description: 'Define the maximum width of the component. `fluid` sets it to full-width. Refer to [container utilities](https://primer.style/css/objects/grid#containers) for reference.',
table: {
category: 'Wrapper'
},
default: 1
},

// break it into `outerSpacing` + `innerSpacing`?

spacingBehavior: {
options: [0, 1, 2],
mapping: ['', 'wrapper', 'regions'],
control: {
type: 'select',
labels: ['None', 'Around wrapper', 'Around regions']
},
description: 'Sets how the `Layout` component will handle its spacing. `aroundWrapper` applies margins around the entire component, while `aroundRegions` uses `padding` inside each region.',
table: {
category: 'Wrapper'
}
},
spacingDensity: {
options: [0, 1, 2],
mapping: ['', 'condensed', 'spacious'],
control: {
type: 'select',
labels: ['Default', 'Condensed', 'Spacious']
},
description: '',
table: {
category: 'Wrapper'
}
},
hasDivider: {
control: { type: 'boolean' },
description: 'true/false toggle to show divider',
table: {
category: 'Wrapper'
}
},

/*
gutterHorizontal: {
options: [0, 1, 2],
mapping: ['', 'none', 'condensed', 'spacious'],
control: {
type: 'select',
labels: ['Default', 'None', 'Condensed', 'Spacious']
},
description: '',
table: {
category: 'Wrapper'
}
},
*/

// Responsive

// `flowHorizontal` should be set automatically depending on viewport size
// according to `responsiveBehaviorAt`. This manual property is here to
// emulate responsive behavior while this isn't hooked up.

flowHorizontal: {
control: { type: 'boolean' },
description: "TEMPORARY way to toggle between mobile-friendly and desktop-friendly behaviors. This should be automatically defined according to the viewport size based on `responsiveBehaviorAt`.",
table: {
category: 'Responsive'
}
},

responsiveBehavior: {
options: [0, 1],
mapping: ['flowVertical', 'splitAsPages'],
control: {
type: 'select',
labels: ['flowVertical', 'splitAsPages']
},
description: '`responsiveBehavior` defines how the layout component adapts to smaller viewports. `flowVertical` presents the content in a vertical flow, with `pane` and `content` vertically arranged. `splitAsPages` presents `pane` and `content` as different pages on smaller viewports.',
table: {
category: 'Responsive'
}
},
responsiveBehaviorAt: {
options: [0, 1, 2, 3],
mapping: ['xs', 'sm', 'md', 'lg'],
control: {
type: 'select',
labels: ['xs', 'sm', 'md', 'lg']
},
description: 'Defines in which breakpoint the responsive behavior will kick in',
table: {
category: 'Responsive'
}
},
responsiveShowPaneFirst: {
control: { type: 'boolean' },
description: 'Defines if the pane should be shown first in the responsive layout. If `responsiveBehavior` is set to `flowVertical`, `pane` appears above `content`. If set to `splitAsPages`, `pane` will appear as a landing page. Use only in the first page of the section.',
table: {
category: 'Responsive'
}
},

// Pane

panePosition: {
options: [0, 1],
mapping: ['start', 'end'],
control: {
type: 'radio',
labels: ['start', 'end']
},
table: {
category: 'Pane'
}
},
paneWidth: {
options: [0, 1, 2],
mapping: ['', 'narrow', 'wide'],
control: {
type: 'radio',
labels: ['default', 'narrow', 'wide']
},
table: {
category: 'Pane'
}
},

// Content

contentWidth: {
options: [0, 1, 2, 3],
mapping: ['', 'md', 'lg', 'xl'],
control: {
type: 'select',
labels: ['Fluid', 'md', 'lg', 'xl']
},
table: {
category: 'Content'
}
},

// Children

hasHeader: {
control: { type: 'boolean' },
table: {
category: 'Children'
}
},

hasFooter: {
control: { type: 'boolean' },
table: {
category: 'Children'
}
},

headerChildren: {
description: 'creates a slot for header children',
table: {
category: 'HTML'
}
},
contentChildren: {
description: 'creates a slot for content children',
table: {
category: 'HTML'
}
},
paneChildren: {
description: 'creates a slot for pane children',
table: {
category: 'HTML'
}
},
footerChildren: {
description: 'creates a slot for footer children',
table: {
category: 'HTML'
}
}
}
}

const layoutClassName = 'LayoutBeta';

// Component output sample

/*

<div class="Layout"
data-spacing-behavior="wrapper"
data-spacing-density="condensed"

data-pane-position="end"

data-flow-horizontal="true"
data-responsive-behavior="splitAsPages"
data-responsive-behavior-at="md"
data-responsive-show-pane-first="true"
>

</div>



*/

// build every component case here in the template (private api)
export const ComponentTemplateName = ({

// Wrapper
wrapperSizing,
spacingBehavior,
spacingDensity,
hasDivider,

panePosition,
paneWidth,
contentWidth,

// Responsive
flowHorizontal,
responsiveBehavior,
responsiveBehaviorAt,

// Pending options
// - divider styles on mobile (including shallow)
// - optional header/footer dividers
// - content/pane light gray backgrounds

// Children
hasHeader,
hasFooter,

// Children
headerChildren,
contentChildren,
paneChildren,
footerChildren
}) => (
<div
// use clsx for multiple classnames
className={clsx(
layoutClassName,
flowHorizontal && layoutClassName + '--flowHorizontal',
spacingBehavior && layoutClassName + '--spacing-' + `${spacingBehavior}`,
spacingDensity && layoutClassName + '--density-' + `${spacingDensity}`,
responsiveBehavior && layoutClassName + '--responsive-' + `${responsiveBehavior}`,
panePosition && layoutClassName + '--panePos-' + `${panePosition}`,
paneWidth && layoutClassName + '--paneWidth-' + `${paneWidth}`,
hasDivider && layoutClassName + '--hasDivider'
)}
data-spacing-behavior={spacingBehavior ? spacingBehavior : undefined}
data-spacing-density={spacingDensity ? spacingDensity : undefined}
data-pane-position={panePosition ? panePosition : 'end'}
data-pane-width={paneWidth ? paneWidth : undefined}
data-content-width={contentWidth ? contentWidth : undefined}

data-responsive-behavior={responsiveBehavior ? responsiveBehavior : 'flowVertical'}
data-responsive-behavior-at={responsiveBehaviorAt ? responsiveBehaviorAt : undefined}

// use undefined for values that shouldn't be set if false
aria-hidden={hasDivider ? 'true' : undefined}
>
{/* use {children} for wrapper component templates */}
<>
<div className={clsx(
layoutClassName + '-regions',
wrapperSizing && wrapperSizing
)}>

{/* Header */}
{hasHeader ? (
<>
<div className={layoutClassName + '-header'}>
{headerChildren}
</div>
</>
) : ''}

{/* content */}
<div className={layoutClassName + '-content'}>
{contentWidth ? (
<>
<div className={layoutClassName + '-content-centered-' + contentWidth}>
<div className={'container-' + contentWidth}>
{contentChildren}
</div>
</div>
</>
) : (
<>
{contentChildren}
</>
)}
</div>

{/* pane */}
<div className={layoutClassName + '-pane'}>{paneChildren}</div>

{/* footer TODO */}
{hasFooter ? (
<>
<div className={layoutClassName + '-footer'}>
{footerChildren}
</div>
</>
) : ''}
</div>
</>
</div>
)

const panePlaceholder =
<>
<div style={
{
width: '100%',
height: '100%',
backgroundColor: '#DDF4FF',
border: '1px solid #80CCFF',
padding: '16px',
borderRadius: '6px'
}
}>
pane
</div>
</>;

const contentPlaceholder =
<>
<div style={
{
width: '100%',
height: '100%',
backgroundColor: '#FFEFF7',
border: '1px solid #FFADDA',
padding: '16px',
borderRadius: '6px'
}
}>
content
</div>
</>;

// create a "playground" demo page that may set some defaults and allow story to access component controls
export const Playground = ComponentTemplateName.bind({})
Playground.args = {
flowHorizontal: true,

// Wrapper
wrapperSizing: 0, // fluid
spacingBehavior: 1, // wrapper
spacingDensity: 0, // default
hasDivider: false,

// Responsive
responsiveBehavior: 0, // flowVertical
responsiveBehaviorAt: 0, // md

// Children
hasHeader: false,
hasFooter: false,
contentChildren: 'content',
paneChildren: 'pane',
headerChildren: 'header',
footerChildren: 'footer'
}

Playground.parameters = {
layout:'fullscreen',
};
Loading