Skip to content

Implement PageLayout component - #1820

Merged
colebemis merged 42 commits into
mainfrom
page-layout-impl
Feb 7, 2022
Merged

Implement PageLayout component#1820
colebemis merged 42 commits into
mainfrom
page-layout-impl

Conversation

@colebemis

@colebemiscolebemis commented Jan 25, 2022

Copy link
Copy Markdown
Contributor

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

changeset-botBot commented Jan 25, 2022

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactPatch

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

github-actionsBot commented Jan 25, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js61.64 KB (0%)
dist/browser.umd.js62 KB (0%)

Comment threadsrc/drafts.ts Outdated
export * from './ActionMenu2'
export * from './DropdownMenu2'
export * from './Label2'
export * from './PageLayout'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we directly put this in the main bundle with alpha maturity because this doesn't cause any breaking changes by being in the main bundle?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Leaving this in drafts for now as we discussed in our engineering sync

@siddharthkpsiddharthkp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really good work!

  • Left a few questions about sx in this PR
  • API feedback is in #1813

Comment threaddocs/content/drafts/PageLayout.mdx Outdated
Comment threaddocs/content/drafts/PageLayout.mdx Outdated
Comment thread.storybook/main.js Outdated
'storybook-addon-performance/register',
'@whitespace/storybook-addon-html'
'storybook-addon-performance/register'
// '@whitespace/storybook-addon-html'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

oops lol

Copy link
Copy Markdown
ContributorAuthor

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 😅

Comment thread.storybook/main.js Outdated
name="divider"
type={`| 'none'
| 'line'`}
defaultValue="'none'"

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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?

enumRegionOrder{Header,PageStart,ContentPaneEnd...}

medium: '768px',
large: '1012px',
xlarge: '1280px'
}

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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

Comment threadsrc/PageLayout/PageLayout.tsx Outdated
}) => {
return (
<PageLayoutContext.Provider value={{outerSpacing, rowGap, columnGap}}>
<Box sx={merge<BetterSystemStyleObject>({padding: SPACING_MAP[outerSpacing]}, sx)}>

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
@colebemis
colebemis merged commit 50c7bfa into mainFeb 7, 2022
@colebemis
colebemis deleted the page-layout-impl branch February 7, 2022 18:31
@primer-cssprimer-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 freeto 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.

3 participants

@colebemis@siddharthkp@rezrah