Skip to content

Commit 8b5ebf0

Browse files
authored
Merge pull request #364 from primer/release-9.6.0
Release 9.6.0
2 parents 3190c9c + 880f89f commit 8b5ebf0

File tree

120 files changed

+3342
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3342
-257
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
.sass-cache
33
node_modules
4+
**/package-lock.json
45
*.log
56
build
67
_site

.storybook/.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"env",
4+
"react",
5+
"minify"
6+
]
7+
}

.storybook/Octicon.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import {storiesOf} from '@storybook/react'
3+
import octicons from 'octicons'
4+
import SVGInline from 'react-svg-inline'
5+
6+
const Octicon = (props) => {
7+
const {name} = props
8+
if (name in octicons) {
9+
return <SVGInline svg={octicons[name].toSVG(props)} />
10+
} else {
11+
throw new Error(`No such octicon: "${name}"!`)
12+
}
13+
}
14+
15+
const story = storiesOf('Octicons', module)
16+
17+
Object.keys(octicons).forEach(name => {
18+
story.add(name, () => {
19+
return (
20+
<div>
21+
<Octicon name={name} height="64" />
22+
<Octicon name={name} height="32" />
23+
<Octicon name={name} height="16" />
24+
</div>
25+
)
26+
})
27+
})

.storybook/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@storybook/addon-options/register'

.storybook/config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import { configure, addDecorator } from '@storybook/react'
3+
import { setOptions } from '@storybook/addon-options'
4+
import '../modules/primer-css/index.scss'
5+
6+
setOptions({
7+
name: 'Primer',
8+
url: 'http://primercss.io/',
9+
showDownPanel: false,
10+
})
11+
12+
addDecorator(story => (
13+
<div className='p-4'>
14+
{story()}
15+
</div>
16+
))
17+
18+
const contexts = [
19+
require.context('.', true, /\.js$/),
20+
require.context('../modules', true, /stories.*\.js$/),
21+
]
22+
23+
configure(() => {
24+
contexts.forEach(context => {
25+
context.keys()
26+
.filter(key => !key.includes('node_modules'))
27+
.forEach(context)
28+
})
29+
}, module)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import remark from 'remark'
2+
import parents from 'unist-util-parents'
3+
import select from 'unist-util-select'
4+
import findBefore from 'unist-util-find-before'
5+
import htmlToReact from 'html-to-react'
6+
import parsePairs from 'parse-pairs'
7+
8+
const htmlParser = new htmlToReact.Parser()
9+
10+
const nodeToStory = (node, file) => {
11+
const html = node.value
12+
const element = htmlParser.parse(html)
13+
const pairs = node.lang.replace(/^html\s*/, '')
14+
const attrs = pairs.length ? parsePairs(pairs) : {}
15+
const title = attrs.title || getPreviousHeading(node) ||
16+
`story @ ${file}:${node.position.start.line}`
17+
return {
18+
title,
19+
story: () => element,
20+
attrs,
21+
html,
22+
file,
23+
node,
24+
}
25+
}
26+
27+
const getPreviousHeading = node => {
28+
const heading = findBefore(node.parent, node, 'heading')
29+
return (heading && !heading.used)
30+
? (heading.used = true, heading.children.map(c => c.value).join(''))
31+
: undefined
32+
}
33+
34+
export default req => {
35+
return req.keys().reduce((stories, file) => {
36+
const content = req(file)
37+
const ast = parents(remark.parse(content))
38+
const path = file.replace(/^\.\//, '')
39+
return stories.concat(
40+
select(ast, 'code[lang^=html]')
41+
.map(node => nodeToStory(node, path))
42+
.filter(({attrs}) => attrs.story !== "false")
43+
)
44+
}, [])
45+
}

.storybook/postcss.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// FIXME this should go away when we merge and release:
2+
// <https://github.com/primer/primer-module-build/pull/19>
3+
const plugins = require("primer-module-build/lib/.postcss.json")
4+
delete plugins.use
5+
6+
module.exports = {
7+
plugins,
8+
}

.storybook/preview-head.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="stylesheet" href="https://unpkg.com/primer-css@9.2.0/build/build.css">
2+
<script src="https://github.com/site/assets/styleguide.js" async></script>

.storybook/webpack.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const path = require("path");
2+
3+
const modulesPath = path.resolve(__dirname, "../modules")
4+
5+
module.exports = (config, env) => {
6+
7+
if (env === 'PRODUCTION') {
8+
config.plugins = config.plugins
9+
.filter(plugin => plugin.constructor.name !== 'UglifyJsPlugin')
10+
}
11+
12+
config.module.rules.push(
13+
{
14+
test: /\.md$/,
15+
use: "raw-loader",
16+
},
17+
{
18+
test: /\.scss$/,
19+
loaders: [
20+
"style-loader",
21+
"css-loader",
22+
{
23+
loader: "postcss-loader",
24+
options: {
25+
config: {
26+
path: require.resolve("./postcss.config.js"),
27+
},
28+
},
29+
},
30+
{
31+
loader: "sass-loader",
32+
options: {
33+
includePaths: [
34+
modulesPath,
35+
],
36+
}
37+
},
38+
],
39+
include: modulesPath,
40+
}
41+
)
42+
43+
return config
44+
}

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ env:
99
# github
1010
- secure: "J+1oWjvvXjyrwkY/4IFWKdN/weFmQcPwlRuFG4R0Gb3rYe4nqtC9l68sJvmS8asc8dQMhOhcUZCH6sjvo7l2WD4NuK4umPSbs+rJNUsfbvH4pZjStQIj/3ll1OfQelGDWAYQWhIfciYY4F3Bp0ZWTfKOppLQ2AVIYu1fPVXDdlo="
1111

12-
before_script:
13-
- lerna bootstrap
14-
1512
script:
1613
- npm test
1714

0 commit comments

Comments
 (0)