Skip to content

Commit 6c14c72

Browse files
author
Emily
authored
Merge pull request #343 from primer/q4-pumpkin-spice
Q4 Pumpkin Spice Release PR
2 parents d09b9bd + bd9f1de commit 6c14c72

27 files changed

Lines changed: 341 additions & 222 deletions

.github/main.workflow

Lines changed: 0 additions & 21 deletions
This file was deleted.

next.config.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
const {join} = require('path')
22
const withPlugins = require('next-compose-plugins')
33
const mdx = require('@zeit/next-mdx')
4+
const getPageMap = require('next-page-map')
5+
6+
const pageExtensions = ['js', 'jsx', 'md', 'mdx']
7+
const pageMap = getPageMap(join(__dirname, 'pages'), pageExtensions)
48

59
const assetPrefix = process.env.NOW_URL
610

711
module.exports = withPlugins([
812
mdx({extension: /\.mdx?$/})
913
], {
10-
assetPrefix,
11-
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
12-
14+
/*
15+
* Note: Prefixing assets with the fully qualified deployment URL
16+
* makes them available even when the site is served from a path alias, as in
17+
* <https://primer.style/components>
18+
*/
19+
assetPrefix: process.env.NOW_URL,
20+
pageExtensions,
1321
publicRuntimeConfig: {
14-
assetPrefix
22+
assetPrefix,
23+
pageMap
1524
},
1625

1726
webpack(config, {dev}) {

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@primer/components",
3-
"version": "5.0.0-beta",
3+
"version": "6.0.0-beta",
44
"description": "Primer react components",
55
"main": "dist/index.umd.js",
66
"module": "dist/index.esm.js",
@@ -78,6 +78,7 @@
7878
"mdx-docs": "1.0.0-8",
7979
"next": "7.0.2",
8080
"next-compose-plugins": "2.1.1",
81+
"next-page-map": "0.1.0",
8182
"node-sass": "4.9.3",
8283
"primer-forms": "2.1.4",
8384
"primer-layout": "1.4.9",

pages/_app.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React from 'react'
22
import App, {Container} from 'next/app'
3+
import getConfig from 'next/config'
34
import {Layout} from 'mdx-docs'
4-
import Octicon, {iconsByName} from '@githubprimer/octicons-react'
5-
import * as primerComponents from '..'
5+
import Octicon, {iconsByName, Pencil} from '@githubprimer/octicons-react'
66
import * as docComponents from './doc-components'
77
import Index from './index.mdx'
8+
import * as primerComponents from '..'
9+
import {repository} from '../package.json'
810

9-
const {BaseStyles, Box, Flex, Link} = primerComponents
11+
const {pageMap} = getConfig().publicRuntimeConfig
12+
const {BaseStyles, Box, Flex, Link, Text} = primerComponents
1013
const {SideNav, Header, IndexHero, customTheme} = docComponents
1114

1215
const iconComponents = Object.keys(iconsByName).reduce((map, key) => {
@@ -15,6 +18,7 @@ const iconComponents = Object.keys(iconsByName).reduce((map, key) => {
1518
}, {})
1619

1720
const DocLink = props => <Link nounderline {...props} />
21+
const editLinkBase = `https://github.com/${repository}/edit/master/pages`
1822

1923
const components = {
2024
...iconComponents,
@@ -38,6 +42,11 @@ export default class MyApp extends App {
3842

3943
render() {
4044
const {pathname} = this.props.router
45+
const filename = pageMap[pathname]
46+
if (!filename) {
47+
// eslint-disable-next-line no-console
48+
console.warn(`pathname "${pathname}" doesn't exist in pageMap:`, pageMap)
49+
}
4150
const {Component, page} = this.props
4251
const isIndex = pathname === '/' || pathname === '/components' || pathname === '/components/'
4352

@@ -51,6 +60,17 @@ export default class MyApp extends App {
5160
{isIndex && <IndexHero />}
5261
<Box color="gray.9" maxWidth={1012} width={'100%'} my={6} mx={'auto'} px={6} className="markdown-body">
5362
{isIndex ? <Index /> : <Component {...page} />}
63+
{filename && (
64+
<Box color="gray.5" borderColor="gray.2" borderTop={1} my={6} pt={2}>
65+
<Text mr={2}>
66+
<Octicon icon={Pencil} />
67+
</Text>
68+
<DocLink muted href={`${editLinkBase}${filename}`}>
69+
Edit this page
70+
</DocLink>{' '}
71+
on GitHub
72+
</Box>
73+
)}
5474
</Box>
5575
</Box>
5676
<SideNav />

pages/components/docs/Avatar.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ Avatars are images used to represent users and organizations on GitHub. They typ
66
## Default example
77

88
```.jsx
9-
<Avatar src="https://avatars.githubusercontent.com/primer" size={128} />
9+
<Avatar mb={4} src="https://avatars.githubusercontent.com/primer" size={128} />
10+
11+
<Text is='p'>To create a Parent + Child avatar combination, wrap Avatars in AvatarPair:</Text>
12+
13+
<AvatarPair my={4}>
14+
<Avatar src="https://avatars.githubusercontent.com/primer"/>
15+
<Avatar src="https://avatars.githubusercontent.com/primer"/>
16+
</AvatarPair>
1017
```
1118

1219
## System props

pages/components/docs/Box.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Box
22

3-
The Box component serves as a wrapper component for most layout related needs.
3+
The Box component serves as a wrapper component for most layout related needs. Use Box to set values such as `display`, `width`, `height`, and more. See the LAYOUT section of our [System Props](/components/docs/system-props) documentation for the full list of available props. In practice, this component is used frequently as a wrapper around other components to achieve Box Model related styling.
44

55
## Default example
66

77
```.jsx
8-
<Box display="inline-block" width="300px" bg="blue.4">This is a Box</Box>
8+
<Box>
9+
<Label m={1}>Box can be used to create block level elements & more</Label>
10+
</Box>
11+
12+
<Label m={1}>Default label</Label>
913
```
1014

1115
## System props
@@ -14,7 +18,9 @@ Box components get the `COMMON` and `LAYOUT` categories of system props. Read ou
1418

1519
## Component props
1620

17-
Box does not get any additional props other than its system props mentioned above.
21+
| Prop name | Type | Default | Description |
22+
| :- | :- | :-: | :- |
23+
| is | String | `div` | sets the HTML tag for the component|
1824

1925

2026
export const meta = {displayName: 'Box'}

pages/components/docs/Button.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Buttons
22

3+
4+
`Button` is used for actions, like in forms, while `Link` is used for destinations, or moving from one page to another.
5+
6+
In special cases where you'd like to use a `<a>` styled like a Button, use `<Button is='a'>` and provide an `href`.
7+
38
## Default examples
49

510
```.jsx
@@ -15,12 +20,12 @@ Button components get `COMMON` system props. Read our [System Props](/components
1520

1621
## Component props
1722

18-
| Prop name | Type | Description |
19-
| :- | :- | :- |
20-
| is | String | sets the HTML tag for the component, defaults to `button` |
21-
| disabled | Boolean | sets the `disabled` attribute on the Button |
22-
| grouped | Boolean | allows you to use Button in a line of Buttons without duplicate borders |
23-
| onClick | Function | function to be called when Button is clicked |
24-
| size | String | use `sm` for a small Button, or `large` for a large Button
23+
| Prop name | Type | Default | Description |
24+
| :- | :- | :-: | :- |
25+
| is | String | `button` | sets the HTML tag for the component |
26+
| disabled | Boolean | | sets the `disabled` attribute on the Button |
27+
| grouped | Boolean | | allows you to use Button in a line of Buttons without duplicate borders |
28+
| onClick | Function | | function to be called when Button is clicked |
29+
| size | String | | use `sm` for a small Button, or `large` for a large Button
2530

2631
export const meta = {displayName: 'Button'}

pages/components/docs/CircleBadge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CircleBadge components get `COMMON` system props. Read our [System Props](/compo
1818

1919
| Name | Type | Default | Description |
2020
| :- | :- | :-: | :- |
21-
| is | String | | sets the HTML tag for the component, defaults to `div` |
21+
| is | String | `div` | sets the HTML tag for the component |
2222
| size | String or Number | | Use `small`, `medium`, or `large` for default sizes, or provide a custom size |
2323

2424

pages/components/docs/FilterList.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ FilterList components get `COMMON` system props. Read our [System Props](/compon
1818

1919
## Component props
2020

21+
#### FilterList
2122
| Name | Type | Default | Description |
2223
| :- | :- | :-: | :- |
2324
| small | Boolean | false | Used to create a smaller version of the standard FilterList|
2425

26+
#### FilterList.Item
27+
| Name | Type | Default | Description |
28+
| :- | :- | :-: | :- |
29+
| count | Number | | Number to be displayed in the list item |
30+
| is | String |`a`| sets the HTML tag for the component |
31+
| selected | Boolean | | Used to set selected style |
32+
2533
export const meta = {displayName: 'FilterList'}

0 commit comments

Comments
 (0)