Skip to content

Commit 8714be7

Browse files
author
Emily
authored
Merge pull request #349 from primer/q4-cool-zoo
Q4 Cool Zoo Release PR
2 parents c723850 + 66e1c0f commit 8714be7

32 files changed

Lines changed: 227 additions & 160 deletions

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
# Primer Components
1+
<p align="center">
2+
<img width="300px" src="https://user-images.githubusercontent.com/10384315/48589167-39d6b400-e8ef-11e8-9183-c69de4fe477f.png">
3+
</p>
24

3-
[Primer](https://primer.github.io/) React components
5+
<h1 align="center">Primer Components</h1>
6+
7+
<p align="center">React components for the Primer Design System</p>
8+
9+
![npm](https://img.shields.io/npm/v/@primer/components.svg)
10+
![GitHub contributors](https://img.shields.io/github/contributors/primer/components.svg)
11+
![GitHub last commit](https://img.shields.io/github/last-commit/primer/components.svg)
12+
![GitHub](https://img.shields.io/github/license/primer/components.svg)
13+
[![Join us in Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/primer)
414

515
## Status
616

7-
**⚠️ This project is WIP and not ready for production use yet!**
17+
**⚠️ This project is a work in progress and is not ready for production use yet!**
18+
19+
## Documentation
820

9-
Currently we link to the latest build of [Primer CSS] so that we may use current Primer styles to start to build components. This does not include `primer-base` so as to avoid unwanted base overrides.
21+
Our documentation site lives at [primer.style/components](https://primer.style/components). You'll be able to find the information listed in this README as well as detailed docs for each component, our theme, and system props.
1022

1123
## Installation
1224

@@ -18,8 +30,6 @@ npm install @primer/components
1830

1931
## Usage
2032

21-
**If you are upgrading from a version before `1.0.0-beta`, please read the [migration docs](migrating.md).**
22-
2333
All of our components are exported by name from `@primer/components`, so you can import them with:
2434

2535
```js
@@ -31,9 +41,7 @@ import {
3141
} from '@primer/components'
3242
```
3343

34-
### Styling
35-
36-
This project uses [emotion] to generate static CSS for most component styles, but still relies on [Primer CSS] for some classname-based styles that haven't yet been ported over. Components that haven't yet been ported over rely on [a subset of Primer CSS](https://github.com/primer/components/blob/master/src/primer-components.scss) that's globally injected at import time.
44+
Primer Components come with all the necessary CSS built-in, so you don't need to worry about including [Primer CSS].
3745

3846
#### Base styles
3947

contributing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ export default withSystemProps(
8484
Categories of system props are exported from `src/system-props`:
8585

8686
* `COMMON` includes color and spacing (margin and padding) props
87-
* `TYPOGRAPHY` includes `COMMON` and font family, font weight, and line-height
88-
* `POSITION` includes `COMMON` and positioning props
89-
* `FLEX_CONTAINER` includes `COMMON` and flexbox props for containers
90-
* `FLEX_ITEM` includes `COMMON` and flexbox props for items in a flex container
87+
* `TYPOGRAPHY` includes font family, font weight, and line-height props
88+
* `POSITION` includes positioning props
89+
* `FLEX_CONTAINER` includes flexbox props for containers
90+
* `FLEX_ITEM` includes flexbox props for items in a flex container
9191

9292
### Components with only system props
9393

@@ -148,7 +148,7 @@ Alternatively, you can create the component from scratch using `withSystemProps(
148148

149149
```jsx
150150
import classnames from 'classnames'
151-
import {withSystemProps, LAYOUT} from './system-props'
151+
import {withSystemProps, LAYOUT, COMMON} from './system-props'
152152

153153
function FancyBox({flashing, className, is: Tag, ...rest}) {
154154
return (
@@ -163,7 +163,7 @@ FancyBox.propTypes = {
163163
flashing: PropTypes.bool
164164
}
165165

166-
export default withSystemProps(FancyBox, LAYOUT)
166+
export default withSystemProps(FancyBox, [...LAYOUT, ...COMMON])
167167
```
168168

169169
In this case, you will need to deal explicitly with two props passed down from [emotion] and [system-components], respectively:

package-lock.json

Lines changed: 4 additions & 4 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@primer/components",
3-
"version": "6.0.1-beta",
3+
"version": "7.0.0-beta",
44
"description": "Primer react components",
55
"main": "dist/index.umd.js",
66
"module": "dist/index.esm.js",
@@ -36,7 +36,7 @@
3636
"author": "GitHub, Inc.",
3737
"license": "MIT",
3838
"dependencies": {
39-
"@githubprimer/octicons-react": "8.0.0",
39+
"@githubprimer/octicons-react": "8.1.2",
4040
"babel-plugin-macros": "2.4.2",
4141
"classnames": "^2.2.5",
4242
"d3-shape": "^1.2.0",

pages/_app.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import getConfig from 'next/config'
55
import {Layout} from 'mdx-docs'
66
import Octicon, {iconsByName, Pencil} from '@githubprimer/octicons-react'
77
import * as docComponents from './doc-components'
8-
import Index from './index.mdx'
98
import * as primerComponents from '..'
109
import {repository} from '../package.json'
1110

@@ -49,7 +48,7 @@ export default class MyApp extends App {
4948
console.warn(`pathname "${pathname}" doesn't exist in pageMap:`, pageMap)
5049
}
5150
const {Component, page} = this.props
52-
const isIndex = pathname === '/' || pathname === '/components' || pathname === '/components/'
51+
const hasHero = ['/components', '/components/'].includes(pathname)
5352

5453
return (
5554
<BaseStyles>
@@ -61,9 +60,9 @@ export default class MyApp extends App {
6160
<Header />
6261
<Flex display={['block', 'block', 'flex', 'flex']} flexDirection="row-reverse">
6362
<Box width="100%">
64-
{isIndex && <IndexHero />}
63+
{hasHero && <IndexHero />}
6564
<Box color="gray.9" maxWidth={1012} width={'100%'} my={6} mx={'auto'} px={6} className="markdown-body">
66-
{isIndex ? <Index /> : <Component {...page} />}
65+
<Component {...page} />
6766
{filename && (
6867
<Box color="gray.5" borderColor="gray.2" borderTop={1} my={6} pt={2}>
6968
<Text mr={2}>

pages/_document.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import Document, {Head, Main, NextScript} from 'next/document'
2+
import Document, {Main, NextScript} from 'next/document'
33
import {ServerStyleSheet} from 'styled-components'
44
import {extractCritical} from 'emotion-server'
55
import {getAssetPath} from './doc-components'
@@ -11,7 +11,7 @@ export default class MyDocument extends Document {
1111
const page = renderPage(App => props => sheet.collectStyles(<App {...props} />))
1212
return {
1313
...page,
14-
styles: (
14+
styleTags: (
1515
<>
1616
<style id="primer-css">
1717
{utilities}
@@ -25,11 +25,12 @@ export default class MyDocument extends Document {
2525
}
2626

2727
render() {
28-
const {styles} = this.props
28+
const {styleTags} = this.props
2929

3030
return (
3131
<html lang="en">
32-
<Head>
32+
<head>
33+
<title>Primer Components</title>
3334
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-126681523-1" />
3435
<script async href={getAssetPath('analytics.js')} />
3536
<meta charSet="utf8" />
@@ -48,8 +49,8 @@ export default class MyDocument extends Document {
4849
<meta property="og:image:height" content="630" />
4950
<meta property="twitter:card" content="summary_large_image" />
5051
<meta property="twitter:site" content="@githubprimer" />
51-
{styles}
52-
</Head>
52+
{styleTags}
53+
</head>
5354
<body>
5455
<Main />
5556
<NextScript />

pages/components/docs/BorderBox.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ BorderBox components get `COMMON` and `LAYOUT` system props. Read our [System Pr
1414

1515
## Component props
1616

17-
BorderBox does not get any additional props other than the system props mentioned above.
17+
| Prop name | Type | Default | Description |
18+
| :- | :- | :-: | :- |
19+
| border | String | 'borders.1' (from theme) | Sets the border, use theme values or provide your own. |
20+
| borderColor | String | 'gray.2' (from theme) | Sets the border color, use theme values or provide your own. |
21+
| borderRadius | String or Number| 'radii.1' (from theme)| Sets the border radius, use theme values or provide your own. |
22+
| boxShadow | String | | Sets box shadow, use theme values or provide your own. |
1823

1924
export const meta = { displayName: 'BorderBox'}
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
import {COMMON, LAYOUT, TYPOGRAPHY, FLEX_CONTAINER, FLEX_ITEM, POSITION} from '../../../src/system-props.js'
2+
import {PropsList} from '../../doc-components'
3+
14
# System Props
25

36

47
Primer Components utilize what we call "system props" to apply a standard set of props to each component. Using [styled-system](https://github.com/jxnblk/styled-system), groups of props are automatically applied to each component. Most components get the `COMMON` set of props which give the component access to color and space props (margin, padding, color and background color). These groups correspond to the `color` and `space` functions from `styled-system` which can be referenced in the styled system [table of style functions](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#core).
58

69
To check which system props each component includes, check the documentation for that component.
710

11+
12+
813
### System Prop Categories
914

1015
| Category | Included Props | styled-system docs |
1116
|-----|--------|--------|
12-
| `COMMON`| space, color | [styled-system core docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#core) |
13-
| `TYPOGRAPHY`| fontFamily, fontSize, fontWeight, lineHeight & all `COMMON` props | [styled-system typography docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#typography) |
14-
| `LAYOUT` | borders, borderColor, borderRadius, boxShadow, <br/> display, size, width, height, minWidth, minHeight, <br/> maxWidth, maxHeight, verticalAlign & all `COMMON` props | [styled-system layout docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#layout) <br/> [styled-system misc docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#misc) |
15-
| `POSITION` | position, zIndex, top, right, bottom, left | [styled-system position docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#position)
17+
| `COMMON`| <PropsList systemProps={COMMON}/>| [styled-system core docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#core) |
18+
| `TYPOGRAPHY`| <PropsList systemProps={TYPOGRAPHY}/> | [styled-system typography docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#typography) |
19+
| `LAYOUT` | <PropsList systemProps={LAYOUT}/>| [styled-system layout docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#layout) <br/> [styled-system misc docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#misc) |
20+
| `POSITION` | <PropsList systemProps={POSITION}/>| [styled-system position docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#position)
21+
| `FLEX_CONTAINER` | <PropsList systemProps={FLEX_CONTAINER}/> | [styled-system flexbox docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#flexbox) |
22+
| `FLEX_ITEM` | <PropsList systemProps={FLEX_ITEM}/> | [styled-system flexbox docs](https://github.com/jxnblk/styled-system/blob/master/docs/table.md#flexbox) |

pages/components/index.mdx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1-
import Index from '../index.mdx'
1+
# Getting Started
22

3-
<Index />
3+
**⚠️ This project is not production-ready yet!** Public beta planned for October 2018.
4+
5+
Install Primer Components in your application:
6+
7+
```
8+
npm i @primer/components
9+
```
10+
11+
# Usage
12+
13+
All of our components are exported by name from `@primer/components`, so you can import them with:
14+
15+
```js
16+
import {
17+
Box,
18+
Button,
19+
Heading,
20+
Text
21+
} from '@primer/components'
22+
```
23+
24+
## Styling
25+
26+
This project uses [emotion] under the hood to generate static CSS from _some_ component styles, but still relies on [Primer CSS] for some component styles that haven't yet been ported over.
27+
28+
To ensure proper styling, you'll need to link to the most recent build of [Primer CSS] in one of the following ways:
29+
30+
1. If you're using webpack, you can install [style-loader](https://github.com/webpack-contrib/style-loader) and [css-loader](), `import 'primer/build/build.css'` in your bundle, and include the following in your webpack config's `module.rules` list:
31+
32+
```js
33+
{
34+
test: /\.css$/,
35+
use: ['style-loader', 'css-loader']
36+
}
37+
```
38+
39+
1. **For pre-production applications**, you can link directly to [the build on unpkg.com](https://unpkg.com/primer/build/build.css).
40+
41+
1. Otherwise, you can `npm install --save primer` and either or link `node_modules/primer/build/build.css` to your source directory.
42+
43+
44+
[emotion]: https://emotion.sh/
45+
[Primer CSS]: https://github.com/primer/primer

pages/doc-components/PropsList.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
const PropsList = ({systemProps}) => <div>{systemProps.join(', ')}</div>
5+
6+
PropsList.propTypes = {
7+
systemProps: PropTypes.arrayOf(PropTypes.string)
8+
}
9+
10+
export default PropsList

0 commit comments

Comments
 (0)