-
Notifications
You must be signed in to change notification settings - Fork 647
PageHeader: Initial implementation #2265
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3c6c646
Add PageHeader component
pksjce 349748e
Use styled system array props
pksjce 2e8af50
wip
broccolinisoup 4a337de
initial working implementation - not polished at all
broccolinisoup 4e52c61
Add controls
broccolinisoup 61d1e82
update stories
broccolinisoup 6d042c6
fix linting
broccolinisoup 548de17
address code review feedback
broccolinisoup b5f5e00
make ParentLink polymorphic and use as and aria-label
broccolinisoup 5bc99a7
story examples and features
broccolinisoup bdb0520
add changeset and delete comment out code
broccolinisoup 6542584
do not export viewports as a story
broccolinisoup 70d387f
rename prop visible->hidden
broccolinisoup 518a028
remove defaultValues in storybook - get feedback first
broccolinisoup fe0e696
use theme preval & some rem update & prettier
broccolinisoup 58725ae
prettier lint fix
broccolinisoup 389bfac
try using media query instead of hook
broccolinisoup db61db7
Revert "try using media query instead of hook"
broccolinisoup c86f362
Spacing adjustments
broccolinisoup 1139bb1
align items to top when the title is multi line
broccolinisoup 03c6834
move variant to the parent and provide context & code review feedback
broccolinisoup 65834a7
remove todo for feature stories
broccolinisoup d855974
move Box
broccolinisoup 6629315
remove line-height for min touch size and add a comment
broccolinisoup f1ca9ea
Merge branch 'main' into pk/page-header
broccolinisoup 4e77758
add unit tests and snapshot
broccolinisoup 35542f8
Merge branch 'main' into pk/page-header
broccolinisoup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@primer/react': minor | ||
| --- | ||
|
|
||
| PageHeader: Draft implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,284 @@ | ||
| import React from 'react' | ||
| import {Meta, Story} from '@storybook/react' | ||
| import {Button, IconButton, Breadcrumbs, Link, Text, StateLabel, BranchName, Box} from '..' | ||
| import {UnderlineNav} from '../UnderlineNav2' | ||
| import Label from '../Label' | ||
| import { | ||
| KebabHorizontalIcon, | ||
| GitBranchIcon, | ||
| CodeIcon, | ||
| GitPullRequestIcon, | ||
| PeopleIcon, | ||
| PencilIcon, | ||
| CommentDiscussionIcon, | ||
| CommitIcon, | ||
| ChecklistIcon, | ||
| FileDiffIcon, | ||
| ArrowRightIcon, | ||
| SidebarExpandIcon, | ||
| } from '@primer/octicons-react' | ||
| import {OcticonArgType} from '../utils/story-helpers' | ||
|
|
||
| import {PageHeader} from './PageHeader' | ||
| import Hidden from '../Hidden' | ||
|
|
||
| const meta: Meta = { | ||
| title: 'Drafts/Components/PageHeader', | ||
| parameters: { | ||
| layout: 'fullscreen', | ||
| controls: {expanded: true}, | ||
| }, | ||
| args: { | ||
| hasContextArea: false, | ||
| hasParentLink: true, | ||
| ParentLink: 'Previous page', | ||
| hasContextBar: false, | ||
| hasContextAreaAction: true, | ||
| hasLeadingAction: false, | ||
| hasTitle: true, | ||
| Title: 'Branches', | ||
| 'Title.as': 'h2', | ||
| 'Title.variant': 'medium', | ||
| hasLeadingVisual: false, | ||
| LeadingVisual: GitBranchIcon, | ||
| hasTrailingVisual: false, | ||
| hasTrailingAction: false, | ||
| hasActions: false, | ||
| hasDescription: false, | ||
| hasNavigation: false, | ||
| }, | ||
| argTypes: { | ||
| hasContextArea: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'ContextArea Slot', | ||
| type: {summary: 'string'}, | ||
| }, | ||
| description: | ||
| 'ContextArea is only visible on narrow viewports by default to provide user context of where they are at their journey.', | ||
| }, | ||
| ParentLink: { | ||
| type: 'string', | ||
| if: {arg: 'hasContextArea'}, | ||
| table: { | ||
| category: 'ContextArea Slot', | ||
| }, | ||
| description: 'The default way to let users navigate up in the hierarchy on Narrow viewports.', | ||
| }, | ||
| hasParentLink: { | ||
| type: 'boolean', | ||
| if: {arg: 'hasContextArea'}, | ||
| table: { | ||
| category: 'ContextArea Slot', | ||
| }, | ||
| description: 'Parent ', | ||
| }, | ||
| hasContextBar: { | ||
| type: 'boolean', | ||
| if: {arg: 'hasContextArea'}, | ||
| table: { | ||
| category: 'ContextArea Slot', | ||
| }, | ||
| description: | ||
| 'ContextBar is generic slot for any component above the title region. Use it for custom breadcrumbs and other navigation elements instead of ParentLink.', | ||
| }, | ||
| hasContextAreaAction: { | ||
| type: 'boolean', | ||
| if: {arg: 'hasContextArea'}, | ||
| table: { | ||
| category: 'ContextArea Slot', | ||
| }, | ||
| }, | ||
| hasLeadingAction: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: | ||
| 'A back button can be used as a leading action for local navigation. On Narrow viewports, use parentLink instead.', | ||
| }, | ||
| hasTitle: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: | ||
| 'ContextBar is generic slot for any component above the title region. Use it for custom breadcrumbs and other navigation elements instead of ParentLink.', | ||
| }, | ||
| Title: { | ||
| type: 'string', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| }, | ||
| 'Title.as': { | ||
| control: { | ||
| type: 'select', | ||
| }, | ||
| options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| }, | ||
| 'Title.variant': { | ||
| control: { | ||
| type: 'radio', | ||
| }, | ||
| options: ['large', 'medium', 'subtitle'], | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: | ||
| '`medium` is the most common page title size. Use for static titles in most situations. `large` for for user-generated content such as issues, pull requests, or discussions. `subtitle` when a PageHeader.Title is already present in the page, such as in a SplitPageLayout.', | ||
| }, | ||
| hasLeadingVisual: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| }, | ||
| LeadingVisual: { | ||
| ...OcticonArgType([CodeIcon, GitPullRequestIcon, PeopleIcon]), | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: | ||
| 'Leading visualLeading visuals are optional and appear at the start of the title. They can be octicons, avatars, and other custom visuals that fit a small area.', | ||
| }, | ||
| hasTrailingVisual: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: | ||
| 'Trailing visualTrailing visual and trailing text can display auxiliary information. They are placed at the right of the item, and can denote status, privacy details, etc.', | ||
| }, | ||
| hasTrailingAction: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| }, | ||
| hasActions: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'TitleArea Slot', | ||
| }, | ||
| description: 'Description region/slot', | ||
| }, | ||
| hasDescription: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'Other Slots', | ||
| }, | ||
| description: 'Description region/slot', | ||
| }, | ||
| hasNavigation: { | ||
| type: 'boolean', | ||
| table: { | ||
| category: 'Other Slots', | ||
| }, | ||
| description: 'Description region/slot', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const Template: Story = args => ( | ||
| <Box sx={{padding: 3}}> | ||
| <PageHeader> | ||
| <PageHeader.ContextArea hidden={!args.hasContextArea}> | ||
| <PageHeader.ParentLink href="http://github.com" hidden={!args.hasParentLink}> | ||
| {args.ParentLink} | ||
| </PageHeader.ParentLink> | ||
|
|
||
| <PageHeader.ContextBar hidden={!args.hasContextBar}> | ||
| <Breadcrumbs> | ||
| <Breadcrumbs.Item href="#">...</Breadcrumbs.Item> | ||
| <Breadcrumbs.Item href="#">primer</Breadcrumbs.Item> | ||
| <Breadcrumbs.Item href="#">react</Breadcrumbs.Item> | ||
| <Breadcrumbs.Item href="#">src</Breadcrumbs.Item> | ||
| <Breadcrumbs.Item href="#">PageHeader</Breadcrumbs.Item> | ||
| <Breadcrumbs.Item href="#">PageHeader.tsx</Breadcrumbs.Item> | ||
| </Breadcrumbs> | ||
| </PageHeader.ContextBar> | ||
|
|
||
| <PageHeader.ContextAreaActions hidden={!args.hasContextAreaAction}> | ||
| <Button size="small" leadingIcon={GitBranchIcon}> | ||
| Main | ||
| </Button> | ||
| <IconButton size="small" aria-label="More" icon={KebabHorizontalIcon} /> | ||
| </PageHeader.ContextAreaActions> | ||
| </PageHeader.ContextArea> | ||
| <PageHeader.TitleArea | ||
| variant={{ | ||
| narrow: args['Title.variant'], | ||
| regular: args['Title.variant'], | ||
| wide: args['Title.variant'], | ||
| }} | ||
| > | ||
| <PageHeader.LeadingAction hidden={!args.hasLeadingAction}> | ||
| <IconButton icon={SidebarExpandIcon} variant="invisible" />{' '} | ||
| </PageHeader.LeadingAction> | ||
| <PageHeader.LeadingVisual hidden={!args.hasLeadingVisual}>{<args.LeadingVisual />}</PageHeader.LeadingVisual> | ||
| <PageHeader.Title as={args['Title.as']} hidden={!args.hasTitle}> | ||
| {args.Title} | ||
| </PageHeader.Title> | ||
| <PageHeader.TrailingVisual hidden={!args.hasTrailingVisual}> | ||
| <Label>Beta</Label> | ||
| </PageHeader.TrailingVisual> | ||
| <PageHeader.TrailingAction hidden={!args.hasTrailingAction}> | ||
| <IconButton icon={PencilIcon} variant="invisible" /> | ||
| </PageHeader.TrailingAction> | ||
| <PageHeader.Actions hidden={!args.hasActions}> | ||
| <Hidden on={['narrow']}> | ||
| <Button variant="primary">New Branch</Button> | ||
| </Hidden> | ||
|
|
||
| <Hidden on={['regular', 'wide', 'narrow']}> | ||
| <Button variant="primary">New</Button> | ||
| </Hidden> | ||
| <IconButton aria-label="More" icon={KebabHorizontalIcon} /> | ||
| </PageHeader.Actions> | ||
| </PageHeader.TitleArea> | ||
| <PageHeader.Description hidden={!args.hasDescription}> | ||
| <StateLabel status="pullOpened">Open</StateLabel> | ||
| <Hidden on={['narrow']}> | ||
| <Text sx={{fontSize: 1, color: 'fg.muted'}}> | ||
| <Link href="#" muted sx={{fontWeight: 'bold'}}> | ||
| broccolinisoup | ||
| </Link>{' '} | ||
| wants to merge 3 commits into <BranchName href="#">main</BranchName> from{' '} | ||
| <BranchName href="#">broccolinisoup/switch-to-new-underlineNav</BranchName> | ||
| </Text> | ||
| </Hidden> | ||
| <Hidden on={['regular', 'wide']}> | ||
| <Text sx={{fontSize: 1, color: 'fg.muted'}}> | ||
| <BranchName href="#">main</BranchName> | ||
| <ArrowRightIcon /> | ||
| <BranchName href="#">page-header-initial</BranchName> | ||
| </Text> | ||
| </Hidden> | ||
| </PageHeader.Description> | ||
| <PageHeader.Navigation hidden={!args.hasNavigation}> | ||
| <UnderlineNav aria-label="Pull Request"> | ||
| <UnderlineNav.Item icon={CommentDiscussionIcon} counter="12" aria-current="page"> | ||
| Conversation | ||
| </UnderlineNav.Item> | ||
| <UnderlineNav.Item counter={3} icon={CommitIcon}> | ||
| Commits | ||
| </UnderlineNav.Item> | ||
| <UnderlineNav.Item counter={7} icon={ChecklistIcon}> | ||
| Checks | ||
| </UnderlineNav.Item> | ||
| <UnderlineNav.Item counter={4} icon={FileDiffIcon}> | ||
| Files Changes | ||
| </UnderlineNav.Item> | ||
| </UnderlineNav> | ||
| </PageHeader.Navigation> | ||
| </PageHeader> | ||
| </Box> | ||
| ) | ||
|
|
||
| export const Playground = Template.bind({}) | ||
|
|
||
| export default meta | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.