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

Release 12.6.0 #854

Merged
merged 62 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f36f756
Adding the Header component to primer
jonrohan Jul 22, 2019
7a5a82e
Include GitHub's stylesheet.css in storybook head
vdepizzol Jul 29, 2019
63ce93f
pushed up test spinner
emilybrick Jul 30, 2019
bf821b3
added more toast animation examples
emilybrick Jul 30, 2019
cb694a5
v12.6.0
shawnbot Jul 30, 2019
69bfbd9
removed extra toast examples
emilybrick Jul 31, 2019
9146953
added loading modifer for yellow toast styles
emilybrick Jul 31, 2019
0e1d144
changed loading toast to gray
emilybrick Aug 1, 2019
48f8701
adjusted gray values
emilybrick Aug 1, 2019
82221e8
linter fix
emilybrick Aug 5, 2019
119a159
last linter fix
emilybrick Aug 5, 2019
f2ae84e
Update DEVELOP.md
shawnbot Aug 5, 2019
04099f8
Merge pull request #852 from primer/toast-spinner-test
emilybrick Aug 5, 2019
29d94fc
Merge pull request #855 from primer/develop-updates
shawnbot Aug 6, 2019
db5fb4a
Merge pull request #849 from vdepizzol/patch-2
vdepizzol Aug 6, 2019
636c04f
Update linting.md
shawnbot Aug 6, 2019
e8810fe
Merge pull request #856 from primer/fix-tool-links
shawnbot Aug 7, 2019
4b43636
Merge branch 'master' into header_component
shawnbot Aug 7, 2019
b80de83
use just the ERB bits
shawnbot Jul 22, 2019
7aa05a9
normalize double quotes
shawnbot Jul 22, 2019
b82a3fc
use ERB converts for octicon() and avatar_for()
shawnbot Jul 22, 2019
c0571d6
lint
shawnbot Jul 22, 2019
2a716f9
add @primer/octicons, bump stylelint-config-primer
shawnbot Jul 22, 2019
d73daf5
be smarter in replaceAll()
shawnbot Jul 22, 2019
80829c1
use real avatars
shawnbot Jul 22, 2019
175f7da
tweak eslint disables
shawnbot Jul 23, 2019
94a1963
fix ERB block rendering
shawnbot Jul 23, 2019
3a2077d
import .octicon CSS from @primer/octicons
shawnbot Jul 23, 2019
ee6f0c6
convert octicons "back" to ERB
shawnbot Jul 23, 2019
f0b340a
import @primer/octicons/index.scss in core
shawnbot Aug 7, 2019
f19944d
move @primer/octicons into dependencies
shawnbot Aug 7, 2019
7bb4b44
get loose with octicons dependency version
shawnbot Aug 7, 2019
bc70747
silence the ERB parser
shawnbot Aug 7, 2019
069671f
convert remaining inline SVG examples back to ERB
shawnbot Aug 7, 2019
6fca657
lint
shawnbot Aug 7, 2019
c2a9838
import @primer/octicons/index.scss in core
shawnbot Aug 7, 2019
e67c174
add @primer/octicons as a dependency
shawnbot Aug 7, 2019
7a9ca91
add bundle README generator, template
shawnbot Aug 7, 2019
0a5e90b
regenerate bundle readmes
shawnbot Aug 7, 2019
cf67cdb
Merge pull request #857 from primer/include-octicon-css
shawnbot Aug 7, 2019
8a4accd
Apply suggestions from code review
jonrohan Aug 7, 2019
483dc7b
Merge pull request #859 from primer/generate-bundle-readmes
shawnbot Aug 7, 2019
85b5bba
Merge pull request #847 from primer/remark-erb-convert
shawnbot Aug 7, 2019
0958eec
Apply suggestions from code review
jonrohan Aug 8, 2019
5f4a6e4
Merge branch 'release-12.6.0' into header_component
jonrohan Aug 8, 2019
ca5624f
Generating README from script
jonrohan Aug 8, 2019
9f9d402
Using flex for example and input-dark from #853
jonrohan Aug 8, 2019
475976d
remove extra space
shawnbot Aug 8, 2019
0ab6d46
Merge pull request #845 from primer/header_component
jonrohan Aug 8, 2019
cd53d67
updated blankslate component
ashygee Aug 8, 2019
91171f5
added in deprecation warning for blankslate-clean-background
ashygee Aug 9, 2019
6770950
Update pages/css/components/blankslate.md
ashygee Aug 9, 2019
5db5ff0
updated with emplums suggestions
ashygee Aug 9, 2019
d25a967
Merge branch 'blankslate-update' of https://github.com/primer/css int…
ashygee Aug 9, 2019
4763751
re-added attribute type=button
ashygee Aug 9, 2019
d2c9fe0
Don't let state labels wrap
jonrohan Aug 9, 2019
a9fb400
updated example copy
ashygee Aug 9, 2019
47a9a72
add warning symbol
ashygee Aug 9, 2019
d4e4dff
removed border from default
ashygee Aug 9, 2019
382c78d
Merge branch 'blankslate-update' of https://github.com/primer/css int…
ashygee Aug 9, 2019
6f4e0e5
Merge pull request #861 from primer/blankslate-update
ashygee Aug 12, 2019
334ac79
Merge pull request #863 from primer/state-wrap
jonrohan Aug 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<link rel="stylesheet" href="https://unpkg.com/octicons@8.5.0/build/build.css">
<link rel="stylesheet" href="https://github.com/site/assets/styleguide.css">
<script src="https://github.com/site/assets/styleguide.js" async></script>
22 changes: 10 additions & 12 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The typical Primer workflow looks something like this:
Run `npm install` to install the npm dependencies.

## Docs site
The Primer CSS docs are built with React using [Primer Components](https://primer.style/components) and automatically deployed on every push to this repo using our [primer/deploy action](/primer/deploy). You can run the server locally with:
The Primer CSS docs are built with React using [Primer Components](https://primer.style/components) and automatically deployed on every push to this repo with [Now]. You can run the server locally with:

```sh
npm start
Expand Down Expand Up @@ -73,29 +73,27 @@ This should open up the site in your browser (if not, navigate to `http://localh
### Code blocks
All `html` fenced code blocks in `src/**/*.md` will be rendered as stories and listed under the relevant module's name in the left-hand nav. File changes should trigger a live reload automatically (after a brief delay).

Note: At this time, we do not load any stories from `src/**/stories.js`.

## Scripts
Our [`package.json`](package.json) houses a collection of [run-scripts] that we use to maintain, test, build, and publish Primer CSS, notably:
Our [`package.json`](package.json) houses a collection of [run-scripts] that we use to maintain, test, build, and publish Primer CSS. Run `npm run <script>` with any of the following values for `<script>`:

* `fresh` does a "fresh" npm install (like `npm install -f`)
* `dist` runs `script/dist`, which creates CSS bundles of all the `index.scss` files in `src/`.
* `check-links` runs a link checker on your local development server (`localhost:3000`, started with `npm start`).
* `lint` lints all of our SCSS source files.
* `lint-js` lints the docs site and supporting scripts.
* `lint` lints both our SCSS and JavaScript source files.
* `lint-css` lints our SCSS source files.
* `lint-js` lints the JavaScript source files.
* `now-build` and `now-start` are run on [Now] to build and start the docs site server. `now-test` runs them both in order.
* `test-urls` compares a (pre-generated) list of paths from the [Primer Style Guide](https://styleguide.github.com/primer/) to files in `pages/css`, and lets us know if we've inadvertently deleted or renamed anything.
* `start` runs the documentation site locally (alias: `dev`).
* `test-urls` compares a (pre-generated) list of paths from the **deprecated** [Primer Style Guide](https://styleguide.github.com/primer/) to files in `pages/css`, and lets us know if we've inadvertently deleted or renamed anything.
* `test-migrate` tests the [`primer-migrate`](MIGRATING.md#primer-migrate) command line utility.
* `watch` runs the sync script in watch mode, copying files as they're changed from `src/` to `pages/css/`.

You can list all of the available scripts with:

```sh
npm run
```
The above list may not always be up-to-date. You can list all of the available scripts by calling `npm run` with no other arguments.


[@primer/css]: https://www.npmjs.com/package/@primer/css
[run-scripts]: https://docs.npmjs.com/cli/run-script
[storybook]: https://storybook.js.org/
[now]: https://zeit.co/now
[npm]: https://www.npmjs.com/
[npx]: https://www.npmjs.com/package/npx
91 changes: 91 additions & 0 deletions lib/erb-to-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable no-console */
const visit = require('unist-util-visit')
const cache = new Map()
const ERB_BLOCK_PATTERN = /<%=[^%]+%>/g

module.exports = options => {
const convert = converter(options)
return tree => {
visit(tree, 'code', node => {
const match = node.lang ? node.lang.match(/^[a-z]+/) : null
const lang = match ? match[0] : null
if (lang === 'erb' || lang === 'html') {
const erb = node.value
const html = convert(erb)
const remaining = html ? html.match(ERB_BLOCK_PATTERN) : null
if (html && !remaining) {
node.value = html
node.lang = node.lang.replace(/^erb/, 'html')
} else if (remaining) {
// console.warn(`Unable to convert ${remaining.length} ERB blocks:\n ${remaining.join(' \n')}`)
} else {
// console.warn(`No conversions made in: ${erb}`)
}
} else {
// console.warn(`Unknown code block lang: ${node.lang}`)
}
})
}
}

function converter({methods = {}}) {
return erb => {
const blocks = erb.match(ERB_BLOCK_PATTERN)
if (blocks && blocks.length) {
let html = erb
// console.warn(`Replacing ${blocks.length} ERB block(s)...`)
for (const block of blocks) {
const output = convert(block)
if (output !== block) {
// const count = html.split(block).length - 1
// console.warn(` found ${count} instances of "${block}"`)
html = replaceAll(html, block, output)
// console.warn(html)
}
}
return html
}
}

function convert(block) {
if (cache.has(block)) {
return cache.get(block)
}

// eslint-disable-next-line no-unused-vars
const [_, method, argString] = block.match(/<%= *(\w+)[ (]([^)]+)\)? *%>/)
const parts = argString.split(/, */)
const args = []
const kwargs = {}
let match
for (const part of parts) {
if ((match = part.match(/^:(.+) => (.+)$/))) {
kwargs[unquote(match[1])] = unquote(match[2])
} else if ((match = part.match(/^(.+): (.+)$/))) {
kwargs[unquote(match[1])] = unquote(match[2])
} else {
args.push(unquote(part))
}
}

if (typeof methods[method] === 'function') {
let output = methods[method](args, kwargs)
console.warn(`converted: ${block} -> ${output}`)
const escaped = block.replace('<', '').replace('>', '')
output = `<!--${escaped}-->\n${output}`
cache.set(block, output)
return output
} else {
console.warn(`No such ERB method implemented: "${method}"`)
return block
}
}
}

function replaceAll(str, input, output) {
return str.split(input).join(output)
}

function unquote(str) {
return str.replace(/^\s*"([^"]+)"\s*$/, (_, value) => value)
}
27 changes: 26 additions & 1 deletion lib/mdx-loader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const {getOptions} = require('loader-utils')
const mdx = require('@mdx-js/mdx')
const octicons = require('@primer/octicons')

const emoji = require('remark-emoji')
const images = require('remark-images')
const rehypePrism = require('./rehype-prism')
const textr = require('remark-textr')
const toc = require('remark-toc')
const erbToHTML = require('./erb-to-html')

const mdxExportJSONByDefault = require('mdx-constant')
const grayMatter = require('gray-matter')
Expand All @@ -22,7 +24,30 @@ module.exports = async function(source) {
[toc, {heading: '(table of|section)? contents'}],
images,
emoji,
[textr, {plugins: [typographicBase]}]
[textr, {plugins: [typographicBase]}],
[
erbToHTML,
{
methods: {
octicon: ([icon], attrs) => {
if (octicons[icon]) {
return octicons[icon].toSVG(attrs)
} else {
throw new Error(`No such octicon: "${icon}"`)
}
},
// eslint-disable-next-line camelcase
avatar_for: ([username, size], kwargs) => {
const name = username === 'current_user' ? 'github' : username
const attrs = Object.entries(kwargs)
.map(([key, value]) => ` ${key}="${value}"`)
.join(' ')
const s = size * 2
return `<img src="https://github.com/${name}.png?s=${s}" width="${size}" height="${size}"${attrs}>`
}
}
}
]
],
hastPlugins: [rehypePrism],
compilers: [mdxExportJSONByDefault('frontMatter', data)]
Expand Down
Loading