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

PageHeader API #2272

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
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
114 changes: 114 additions & 0 deletions docs/content/PageHeader.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: PageHeader
componentId: page_header
status: Draft
description: This component can be used independently or inside PageLayout.Header. It helps provide structure and responsive aspects to the Header component.
# source: https://github.com/primer/react/tree/main/src/PageHeader
# storybook: https://primer.style/react/storybook?path=/story/layout-pageheader--default
---

```js
import {PageHeader} from '@primer/react'
```

### Default

```jsx live
<PageHeader>
{/* Visible only in narrow viewport*/}
<PageHeader.ContextNav>
{/* Always renders with a backbutton and is left aligned*/}
<PageHeader.ParentLink href="/code">Code</PageHeader.ParentLink>
</PageHeader.ContextNav>
{/* Visible in all viewports */}
<PageHeader.TitleArea>
<PageHeader.Title>Branches</PageHeader.Title>
<PageHeader.TitleActions>
{/* Visible only in narrow viewport*/}
<Stack direction={{narrow: 'inline', regular: 'none'}}>
<Button variant="primary">New Branch</Button>
</Stack>
{/* Visible only in regular viewport*/}
<Stack direction={{narrow: 'none', regular: 'inline'}}>
<Button variant="primary">New</Button>
</Stack>
{/* Visible in all viewports */}
<IconButton aria-label="More actions" icon={KebabHorizontalIcon} />
</PageHeader.TitleActions>
</PageHeader.TitleArea>
</PageHeader>
```

### With Context Actions and Breadcrumbs

<PageHeader>
Copy link
Contributor

Choose a reason for hiding this comment

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

This example and the following examples don't have the jsx live codefence args. Is this intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope! it was a mistake. Will fix this 👍

{/* Visible only in narrow viewport only*/}
<PageHeader.ContextNav>
{/* Always renders with a backbutton and is left aligned*/}
<PageHeader.ParentLink href="files">Files</PageHeader.ParentLink>
{/* These are right aligned*/}
<PageHeader.ContextNavActions>
{/* Should these buttons be normal sized?*/}
<Button size="small" leadingIcon={GitBranchIcon} trailingIcon={ChevronDownIcon} variant="outline">
main
</Button>
<IconButton size="small" aria-label="More actions" icon={KebabHorizontalIcon} />
</PageHeader.ContextNavActions>
</PageHeader.ContextNav>
{/* Visible only in all viewports */}
<PageHeader.TitleArea>
<PageHeader.Title>
<Breadcrumbs>
<Breadcrumbs.Item href="/">...</Breadcrumbs.Item>
<Breadcrumbs.Item href="/primer">primer</Breadcrumbs.Item>
<Breadcrumbs.Item href="/primer/react">react</Breadcrumbs.Item>
<Breadcrumbs.Item href="/primer/react/PageHeader">PageHeader</Breadcrumbs.Item>
<Breadcrumbs.Item href="/primer/react/PageHeader/index.ts" selected>
index.ts
</Breadcrumbs.Item>
</Breadcrumbs>
</PageHeader.Title>
</PageHeader.TitleArea>
</PageHeader>

### With a description and local navigation

<PageHeader>
<PageHeader.ContextNav>
<PageHeader.ParentLink href="prs">Pull requests</PageHeader.ParentLink>
</PageHeader.ContextNav>
<PageHeader.TitleArea>
<PageHeader.Title>PageLayout component/Layout beta + storybook</PageHeader.Title>
<PageHeader.TitleActions>
<Button>Edit</Button>
<Button leadingIcon={CodeIcon} trailingIcon={ChevronDownIcon}>
Code
</Button>
</PageHeader.TitleActions>
</PageHeader.TitleArea>
<PageHeader.Description>
<StateLabel status="issueOpened">Open</StateLabel>
<Box sx={{display: 'inline-flex'}}>
<Stack direction={{narrow: 'none', regular: 'inline'}}>
<Box>
<b>simurai</b> wants to merge 12 commits from
</Box>
</Stack>
<Box>
<Token>token-mode</Token>
<ArrowRightIcon />
<Token>main</Token>
</Box>
</Box>
</PageHeader.Description>
<PageHeader.LocalNav>
<UnderlineNav>
<UnderlineNav.Link>Overview</UnderlineNav.Link>
<UnderlineNav.Link leadingIcon={CommentDiscussionIcon}>
Conversations
<CounterLabel sx={{ml: 2}}>42</CounterLabel>
</UnderlineNav.Link>
<UnderlineNav.Link leadingIcon={GitCommitIcon}>Commits</UnderlineNav.Link>
</UnderlineNav>
</PageHeader.LocalNav>
</PageHeader>