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

Implement PageLayout component #1820

Merged
merged 42 commits into from
Feb 7, 2022
Merged

Implement PageLayout component #1820

merged 42 commits into from
Feb 7, 2022

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Jan 25, 2022

This PR implements the PageLayout API discussed in my previous PR.

image

Note to reviewers: The bulk of the implementation lives in src/PageLayout/PageLayout.tsx.

TODO

  • Merge PageLayout API #1813
  • Implement dividers
  • Implement row and column gaps
  • Update documentation examples
  • Implement sx prop
  • Add real-life examples to storybook (pull request page)
  • Export from drafts
  • Test in Chrome
  • Test in Firefox
  • Test in Safari

Out of scope for this PR

  • Implement ref props
  • Add tests
  • Implement content centering logic
  • Test PageLayout in production apps (e.g. Memex or Issues app)

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2022

🦋 Changeset detected

Latest commit: e793f10

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 61.64 KB (0%)
dist/browser.umd.js 62 KB (0%)

'storybook-addon-performance/register',
'@whitespace/storybook-addon-html'
'storybook-addon-performance/register'
// '@whitespace/storybook-addon-html'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revert this before merging 😅

.storybook/main.js Outdated Show resolved Hide resolved
name="divider"
type={`| 'none'
| 'line'`}
defaultValue="'none'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if line is the only real alternative, should this be a boolean instead like showDivider?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed horizontalDividerVariants. Is this missing 'filled'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, filled is only an option at narrow viewports. I chose divider: none | line instead of showDivider: boolean to align with the dividerWhenNarrow prop.

import {Box} from '..'
import {BetterSystemStyleObject, merge, SxProp} from '../sx'

const REGION_ORDER = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: The uppercasing here feels a bit heavy given it's already private and immutable. Should this be an enum instead?

enum RegionOrder {
  Header,
  PageStart,
  Content
  PaneEnd
 ...
} 

medium: '768px',
large: '1012px',
xlarge: '1280px'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, should these come from primitives eventually? I know theme has some breakpoints in there, so how would this correlate back to those in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely 👍

rowGap = 'normal',
columnGap = 'normal',
children,
sx = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should sx have a default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed this to make TypeScript happy with the merge() function

}) => {
return (
<PageLayoutContext.Provider value={{outerSpacing, rowGap, columnGap}}>
<Box sx={merge<BetterSystemStyleObject>({padding: SPACING_MAP[outerSpacing]}, sx)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this lead to a performance issue if we're running this on each render? It feels like it should be hoisted above the return and memoized, given it's a component that will definitely have tons of children. cc. @pksjce what do you think too? Probably overthinking it 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also curious about this! Would love to hear what @pksjce thinks

vdepizzol added a commit to primer/css that referenced this pull request Feb 4, 2022
to match with new conventions discussed in
primer/react#1820
@colebemis colebemis merged commit 50c7bfa into main Feb 7, 2022
@colebemis colebemis deleted the page-layout-impl branch February 7, 2022 18:31
@primer-css primer-css mentioned this pull request Feb 7, 2022
vdepizzol added a commit to primer/css that referenced this pull request Feb 17, 2022
* Rename inner and outerSpacing props to padding

to match with new conventions discussed in
primer/react#1820

* Fix Layout example stories

* Add header and footer slots to SplitPageLayout

Also add initial skeleton for Pull request detail story

* add TreeView to Pull request detail story

* Add padding: none prop

* Ongoing Pull request detail story

* Create fifty-chefs-help.md

* Resolve storybook conflicts

* Resolve storybook conflicts, second try

Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Co-authored-by: Katie Langerman <langermank@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants