forked from primer/design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose dotcom shared components (primer#557)
* Expose dotcom shared components * Update content/github-staff/github-shared-components.mdx Co-authored-by: Emily Brick <emilybrick@github.com> * Change format of shared_components.json * Renaming * Fix link styles; rearrange shared components page * Stop using outdated shared deploy config * Add ListView component to fallback recipe file * Pull data from github master branch * Remove unnecessary console.log; remove unused ToC item * D'oh, fix other ToC link * Stop grouping shared components alphabetically --------- Co-authored-by: Emily Brick <emilybrick@github.com>
1 parent
ef0b103
commit f22d3b1
Showing
11 changed files
with
717 additions
and
74,541 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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,25 @@ | ||
[ | ||
{ | ||
"component": "ItemPicker", | ||
"storyIds": [], | ||
"meta": { | ||
"id": "item-picker", | ||
"name": "Item picker", | ||
"path": "ui/packages/item-picker/components/ItemPicker.tsx", | ||
"status": "draft" | ||
} | ||
}, | ||
{ | ||
"component": "ListView", | ||
"storyIds": [ | ||
"shared-components-listview--docs", | ||
"shared-components-listview--list" | ||
], | ||
"meta": { | ||
"id": "list-view", | ||
"name": "List view", | ||
"path": "ui/packages/list-view/src/ListView.tsx", | ||
"status": "draft" | ||
} | ||
} | ||
] |
This file contains 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
This file contains 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,102 @@ | ||
import {HEADER_HEIGHT} from '@primer/gatsby-theme-doctocat/src/components/header' | ||
import TableOfContents from '@primer/gatsby-theme-doctocat/src/components/table-of-contents' | ||
import {Box, Heading, Label, Link, Text} from '@primer/react' | ||
import React from 'react' | ||
import {BaseLayout} from '../components/base-layout' | ||
import {graphql, useStaticQuery} from 'gatsby' | ||
import { H3 } from '@primer/gatsby-theme-doctocat/src/components/heading' | ||
import {LinkExternalIcon} from '@primer/octicons-react' | ||
|
||
function SharedComponentStatusLabel({status}) { | ||
const variant = (() => { | ||
if (status === 'draft') { | ||
return 'attention' | ||
} else { | ||
return 'default' | ||
} | ||
})() | ||
|
||
return <Label sx={{marginLeft: '5px'}} variant={variant}>{status}</Label> | ||
} | ||
|
||
function SharedComponentLink({component}) { | ||
const urlForComponent = (component) => { | ||
return `https://ui.githubapp.com/storybook/?path=/story/${component.storyIds[0]}` | ||
} | ||
|
||
if (component.storyIds.length > 0) { | ||
return <Box> | ||
<Link target="_blank" href={urlForComponent(component)}> | ||
{component.component} <LinkExternalIcon/> | ||
</Link> | ||
| ||
<SharedComponentStatusLabel status={component.status}></SharedComponentStatusLabel> | ||
</Box> | ||
} else { | ||
return <Box> | ||
<Link target="_blank" href={`https://github.com/github/github/blob/master/${component.path}`}> | ||
{component.component} <LinkExternalIcon/> | ||
</Link> | ||
<SharedComponentStatusLabel status={component.status}></SharedComponentStatusLabel> | ||
</Box> | ||
} | ||
} | ||
|
||
export default function DotcomSharedComponentsLayout({pageContext, children}) { | ||
const data = useStaticQuery(graphql` | ||
query DotcomSharedComponentsPageQuery { | ||
allSharedComponent { | ||
nodes { | ||
component | ||
storyIds | ||
status | ||
path | ||
} | ||
} | ||
} | ||
`) | ||
|
||
const {title, description} = pageContext.frontmatter | ||
|
||
const tableOfContents = { | ||
items: [ | ||
{url: '#related-reading', title: 'Related reading'}, | ||
{url: '#shared-components', title: 'Components'} | ||
], | ||
} | ||
|
||
return ( | ||
<BaseLayout title={title} description={description}> | ||
<Box sx={{maxWidth: 1200, width: '100%', p: [4, 5, 6, 7], mx: 'auto'}}> | ||
<Heading as="h1" sx={{fontSize: 7}}>{title}</Heading> | ||
<Text as="p" sx={{fontSize: 3, m: 0, mb: 3, maxWidth: '60ch'}}> | ||
{description} | ||
</Text> | ||
<Box sx={{display: 'flex', flexDirection: 'row-reverse', alignItems: 'start', gap: [null, 7, 8, 9]}}> | ||
<Box | ||
sx={{ | ||
width: 220, | ||
flex: '0 0 auto', | ||
position: 'sticky', | ||
top: HEADER_HEIGHT + 24, | ||
maxHeight: `calc(100vh - ${HEADER_HEIGHT}px - 24px)`, | ||
display: ['none', null, 'block'], | ||
}} | ||
> | ||
<Heading as="h3" sx={{fontSize: 1, display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading"> | ||
On this page | ||
</Heading> | ||
<TableOfContents aria-labelledby="toc-heading" items={tableOfContents.items} /> | ||
</Box> | ||
<Box sx={{'flexGrow': 1}}> | ||
{children} | ||
|
||
{data.allSharedComponent.nodes.map(component => { | ||
return <SharedComponentLink component={component} /> | ||
})} | ||
</Box> | ||
</Box> | ||
</Box> | ||
</BaseLayout> | ||
) | ||
} |
This file contains 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