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 47 commits
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
4 changes: 4 additions & 0 deletions docs/.storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
margin: -1rem;
}

.sb-main-fullscreen .theme-wrap .story-wrap {
padding: 0;
}

.sb-main-padded div:not(.theme-wrap) > [data-dark-theme] {
margin: -1rem;
padding: 1rem;
Expand Down
7 changes: 7 additions & 0 deletions docs/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ 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%'
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ NavWithSubItemsLeadingVisual16px.args = {
children={
<ListTemplate
subGroup
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
children={
<>
<ListItemTemplate subItem text="Sub Nav Item" href="/" listSemantic ariaLevel="2" />
Expand Down Expand Up @@ -236,7 +236,7 @@ NavWithSubItemsLeadingVisual20px.args = {
children={
<ListTemplate
subGroup
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
children={
<>
<ListItemTemplate subItem text="Sub Nav Item" href="/" listSemantic ariaLevel="2" />
Expand Down Expand Up @@ -328,7 +328,7 @@ NavWithSubItemsLeadingVisual24px.args = {
children={
<ListTemplate
subGroup
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
children={
<>
<ListItemTemplate subItem text="Sub Nav Item" href="/" listSemantic ariaLevel="2" />
Expand Down Expand Up @@ -671,7 +671,7 @@ NavWithSubItemsLeadingVisual16pxSubSections.args = {
<ListTemplate
subGroup
ariaLabelledBy="group-id-1"
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
children={
<>
<ListItemTemplate
Expand Down Expand Up @@ -701,7 +701,7 @@ NavWithSubItemsLeadingVisual16pxSubSections.args = {
containsSubItem
containsActiveSubItem
subGroup
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
children={
<>
<ListItemTemplate
Expand Down Expand Up @@ -740,7 +740,7 @@ NavWithSubItemsLeadingVisual16pxSubSections.args = {
children={
<ListTemplate
subGroup
ariaLabel="Sub nav descrioption"
ariaLabel="Sub nav decription"
ariaLabelledBy="group-id-2"
children={
<>
Expand Down
204 changes: 204 additions & 0 deletions docs/src/stories/components/Layout/LayoutAlpha.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import React from 'react'
import clsx from 'clsx'

export default {
title: 'Components/Layout/Alpha',
excludeStories: ['LayoutAlphaTemplate'],
argTypes: {
container: {
control: { type: 'select' },
options: ['fluid', 'md', 'lg', 'xl'],
control: {
type: 'inline-radio'
},
description: 'Wrapper around the entire component to define an optional maximum width.',
table: {
category: 'CSS'
}
},
hasDivider: {
control: { type: 'boolean' },
description: 'Whether to show a pane line divider.',
table: {
category: 'CSS'
}
},
gutter: {
options: ['default', 'none', 'condensed', 'spacious'],
control: {
type: 'inline-radio'
},
description: 'Sets the gap between columns.',
table: {
category: 'CSS'
}
},
sidebarPosition: {
options: ['start', 'end'],
control: {
type: 'inline-radio'
},
description: 'Sets the position of the sidebar.',
table: {
category: 'CSS'
}
},
sidebarWidth: {
options: ['default', 'narrow', 'wide'],
control: {
type: 'inline-radio'
},
description: 'Sets the width of the sidebar.',
table: {
category: 'CSS'
}
},
mainWidth: {
options: ['fluid', 'md', 'lg', 'xl'],
control: {
type: 'inline-radio'
},
description: 'Sets the width of the main content area.',
table: {
category: 'CSS'
}
},
flowRowUntil: {
options: ['sm', 'md', 'lg'],
control: {
type: 'inline-radio',
},
description: 'Sets the maximum breakpoint at which the layout will flow as row.',
table: {
category: 'CSS'
}
},
mainChildren: {
description: 'creates a slot for main children',
table: {
category: 'HTML'
}
},
sidebarChildren: {
description: 'creates a slot for sidebar children',
table: {
category: 'HTML'
}
},
}
}

// build every component case here in the template (private api)
export const LayoutAlphaTemplate = ({
container,
hasDivider,
gutter,
sidebarPosition,
sidebarWidth,
mainWidth,
flowRowUntil,
mainChildren,
sidebarChildren
}) => {

// Default values
container = container ?? 'xl';
hasDivider = hasDivider ?? false;
gutter = gutter ?? 'default';
sidebarPosition = sidebarPosition ?? 'end';
sidebarWidth = sidebarWidth ?? 'default';
mainWidth = mainWidth ?? 'full';
flowRowUntil = flowRowUntil ?? 'md';

// Leave `null` values for states that don't require a modifier class
container = (container === 'full') ? null : container;
hasDivider = (hasDivider === false) ? null : hasDivider;
gutter = (gutter === 'default') ? null : gutter;
sidebarWidth = (sidebarWidth === 'default') ? null : sidebarWidth;
mainWidth = (mainWidth === 'full') ? null : mainWidth;
flowRowUntil = (flowRowUntil === 'sm') ? null : flowRowUntil;

return (
<div
// use clsx for multiple classnames
className={clsx(
'Layout',
container && 'container-' + `${container}`,
gutter && 'Layout--gutter-' + `${gutter}`,
sidebarPosition && 'Layout--sidebarPosition-' + `${sidebarPosition}`,
sidebarWidth && 'Layout--sidebar-' + `${sidebarWidth}`,
hasDivider && 'Layout--divided',
flowRowUntil && '' + 'Layout--flowRow-until-' + `${flowRowUntil}`
)}
// use undefined for values that shouldn't be set if false
aria-hidden={hasDivider ? 'true' : undefined}
>
{/* use {children} for wrapper component templates */}
<>
<div className="Layout-main">
{mainWidth ? (
<>
<div className={'Layout-main-centered-' + mainWidth}>
<div className={clsx( mainWidth && 'container-' + mainWidth)}>
{mainChildren}
</div>
</div>
</>
) : (
<>
{mainChildren}
</>
)}
</div>
<div className="Layout-divider"></div>
<div className="Layout-sidebar">{sidebarChildren}</div>
</>
</div>
);
};

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

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

// create a "playground" demo page that may set some defaults and allow story to access component controls
export const Playground = LayoutAlphaTemplate.bind({})
Playground.args = {
container: 'full',
hasDivider: false,
gutter: 'default',
sidebarPosition: 'end',
sidebarWidth: 'default',
mainWidth: 'full',
flowRowUntil: 'md',
mainChildren: mainPlaceholder,
sidebarChildren: sidebarPlaceholder
}
Loading