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

Update dependencies to fix weird errors #253

Merged
merged 14 commits into from
Sep 14, 2018
25 changes: 24 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
4. [Component patterns](#component-patterns)
* [Components with only system props](#components-with-only-system-props)
* [Primer CSS components](#primer-css-components)
5. [Glossary](#glossary)
5. [Deployment](#deployment)
6. [Glossary](#glossary)

## Code Style

Expand Down Expand Up @@ -169,6 +170,26 @@ In this case, you will need to deal explicitly with two props passed down from [
* `className`: You _must_ render this prop, otherwise **your component will not be styled.**
* `is`: This is what allows your component to render with arbitrary elements, and even other components. If you don't respect this prop, you should `delete Component.propTypes.is` to signal that it's not available.

## Deployment
We deploy the Primer Components site using [Now]. Install the Now CLI and log in with:

```sh
npm i -g now
now login
```

Once you're logged in, sync your local git repo with the `master` branch and run:

```sh
script/deploy
```

This will create a new deployment and alias it to its production URL, [primer-react.now.sh](https://primer-react.now.sh).

### Path aliasing
This site is served as a subdirectory of [primer.style] using a [path alias](https://zeit.co/docs/features/path-aliases) configured in that repo's [`rules.json`](https://github.com/primer/primer.style/tree/master/rules.json). If you change the production deployment URL for this app, you will also need to change it there and re-deploy that app; otherwise, Now will automatically route requests from [primer.style/components](https://primer.style/components/) to the new deployment whenever you deploy this one to `primer-react.now.sh`.


## Glossary

### System props
Expand Down Expand Up @@ -197,3 +218,5 @@ SpaceDiv.propTypes = {
[system-components]: https://jxnblk.com/styled-system/system-components
[table]: https://jxnblk.com/styled-system/table
[npx]: https://www.npmjs.com/package/npx
[Now]: https://zeit.co/now
[primer.style]: https://primer.style
1 change: 0 additions & 1 deletion now.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"alias": "primer-react.now.sh",
"files": [
"next.config.js",
"now.json",
Expand Down
3,246 changes: 1,783 additions & 1,463 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
"dependencies": {
"@githubprimer/octicons-react": "8.0.0",
"classnames": "^2.2.5",
"clean-tag": "2.0.0",
"d3-shape": "^1.2.0",
"emotion": "9.2.6",
"emotion": "9.2.8",
"emotion-theming": "9.2.6",
"primer-colors": "1.0.1",
"primer-typography": "1.0.1",
Expand All @@ -46,7 +45,7 @@
"react-emotion": "9.2.6",
"styled-system": "2.3.6",
"system-classnames": "^1.0.0-3",
"system-components": "3.0.0"
"system-components": "2.2.3"
},
"devDependencies": {
"@compositor/kit": "^1.0.43",
Expand All @@ -57,8 +56,8 @@
"@zeit/next-sass": "0.2.0",
"babel-core": "7.0.0-bridge.0",
"babel-plugin-add-react-displayname": "0.0.5",
"enzyme": "3.3.0",
"enzyme-adapter-react-16": "1.1.1",
"enzyme": "3.5.1",
"enzyme-adapter-react-16": "1.5.0",
"eslint": "4.19.1",
"eslint-plugin-github": "1.0.0",
"eslint-plugin-jest": "21.15.1",
Expand All @@ -67,7 +66,7 @@
"jest": "23.5.0",
"jest-emotion": "9.2.7",
"mdx-docs": "1.0.0-8",
"next": "6.1.1",
"next": "6.1.2",
"next-compose-plugins": "2.1.1",
"now": "11.3.12",
"primer-buttons": "2.6.0",
Expand Down
13 changes: 1 addition & 12 deletions pages/_document.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import React from 'react'
import Document, {Head, Main, NextScript} from 'next/document'
import {ServerStyleSheet} from 'styled-components'

export default class MyDocument extends Document {
static getInitialProps({renderPage}) {
const sheet = new ServerStyleSheet()
const page = renderPage(App => props => sheet.collectStyles(<App {...props} />))
const styles = sheet.getStyleElement()
return {...page, styles}
}

render() {
const {
styles,
// this comes from the app.setAssetPrefix() call in server.js
// the assetPrefix is set in next.config.js
__NEXT_DATA__: {assetPrefix = ''}
} = this.props

Expand All @@ -29,10 +20,8 @@ export default class MyDocument extends Document {
{/* See: https://github.com/zeit/next-plugins/tree/master/packages/next-sass#usage */}
<link rel="stylesheet" href={asset('/_next/static/style.css')} />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="generator" content="Compositor X0" />
<meta name="og:title" content="Primer React" />
<meta name="description" content="Primer components built with React.js." />
{styles}
</Head>
<body>
<Main />
Expand Down
6 changes: 6 additions & 0 deletions script/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
deployment="${1:-primer-react.now.sh}"
now
now alias $deployment
now scale $deployment 1
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/CircleBadge.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`CircleBadge respects "is" prop 1`] = `
<a
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -21,6 +20,7 @@ exports[`CircleBadge respects "is" prop 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-0 CircleBadge"
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/__snapshots__/Dropdown.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ exports[`Dropdown matches the snapshots 1`] = `
<div
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -48,14 +47,14 @@ exports[`Dropdown matches the snapshots 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-1 BtnGroup"
>
<details
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -72,6 +71,7 @@ exports[`Dropdown matches the snapshots 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="details-reset BtnGroup-form emotion-3"
Expand All @@ -80,7 +80,6 @@ exports[`Dropdown matches the snapshots 1`] = `
<summary
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -97,6 +96,7 @@ exports[`Dropdown matches the snapshots 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-1 btn BtnGroup-item"
Expand Down Expand Up @@ -193,7 +193,6 @@ exports[`Dropdown matches the snapshots 2`] = `
<div
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -210,14 +209,14 @@ exports[`Dropdown matches the snapshots 2`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-1 BtnGroup"
>
<details
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -234,6 +233,7 @@ exports[`Dropdown matches the snapshots 2`] = `
"pl",
"px",
"py",
"css",
]
}
className="details-reset BtnGroup-form emotion-3"
Expand All @@ -242,7 +242,6 @@ exports[`Dropdown matches the snapshots 2`] = `
<summary
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -259,6 +258,7 @@ exports[`Dropdown matches the snapshots 2`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-1 btn BtnGroup-item"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/FilterListItem.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ exports[`FilterListItem renders the given "is" prop 1`] = `
<b
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -23,6 +22,7 @@ exports[`FilterListItem renders the given "is" prop 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="filter-item emotion-0"
Expand All @@ -33,7 +33,6 @@ exports[`FilterListItem respects the "selected" prop 1`] = `
<a
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -50,6 +49,7 @@ exports[`FilterListItem respects the "selected" prop 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="filter-item selected emotion-0"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/Link.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`Link passes href down to link element 1`] = `
<a
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -21,6 +20,7 @@ exports[`Link passes href down to link element 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-0 text-blue"
Expand All @@ -32,7 +32,6 @@ exports[`Link renders without any props 1`] = `
<a
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -49,6 +48,7 @@ exports[`Link renders without any props 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-0 text-blue"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/UnderlineNavLink.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`UnderlineNavLink renders the given "is" prop 1`] = `
<b
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -21,6 +20,7 @@ exports[`UnderlineNavLink renders the given "is" prop 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="UnderlineNav-item no-underline emotion-0"
Expand All @@ -31,7 +31,6 @@ exports[`UnderlineNavLink respects the "selected" prop 1`] = `
<a
blacklist={
Array [
"css",
"color",
"bg",
"m",
Expand All @@ -48,6 +47,7 @@ exports[`UnderlineNavLink respects the "selected" prop 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="UnderlineNav-item no-underline selected emotion-0"
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/__snapshots__/system-props.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ exports[`system props withSystemProps() applies multiple theme values 1`] = `
<b
blacklist={
Array [
"css",
"fontFamily",
"font",
"m",
"mt",
"mr",
Expand All @@ -25,6 +25,7 @@ exports[`system props withSystemProps() applies multiple theme values 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-0"
Expand All @@ -41,7 +42,6 @@ exports[`system props withSystemProps() applies one theme value 1`] = `
<b
blacklist={
Array [
"css",
"m",
"mt",
"mr",
Expand All @@ -56,6 +56,7 @@ exports[`system props withSystemProps() applies one theme value 1`] = `
"pl",
"px",
"py",
"css",
]
}
className="emotion-0"
Expand Down
1 change: 1 addition & 0 deletions src/system-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function withSystemProps(Component, props = COMMON) {

// Set what system props we use on this component
Wrapped.systemProps = props
Wrapped.systemComponent = true

// Copy over non-system keys from components
// eg. Tooltip.js => Tooltip.directions Tooltip.alignments
Expand Down
3 changes: 2 additions & 1 deletion src/utils/test-matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ expect.extend({
toImplementSystemProps(Component, propNames) {
const propKeys = new Set(Object.keys(Component.propTypes))
const expectedPropKeys = propNames.reduce((list, name) => {
const fn = systemProps[name]
const fn = typeof name === 'function' ? name : systemProps[name]
if (!fn) throw new Error(`"${name}" is not a system prop!!`)
return list.concat(Object.keys(fn.propTypes))
}, [])
const missing = expectedPropKeys.filter(key => !propKeys.has(key)).filter(key => !ALIAS_PROP_TYPES.includes(key))
Expand Down