Skip to content

Commit 50113d9

Browse files
shawnbotjackson.flint.gonzales
and
jackson.flint.gonzales
authored
Release 2.0.0 (#40)
* 2.0.0 * add reports workflow w/preactjs/compressed-size-action (#41) * Stub out site refactor (#26) * 1.1.0 * just watch all of src for css changes * style input placeholders (text-slate-light) * add 48px spacer * add "action" color alias (to bright blue) * add "inherit" to textColor (text-inherit) * switch default borderWidth from 4px to 3px * add "xl" breakpoint (1090px) * reset body margin + padding; add default link color * enable flexWrap + overflow in tailwind * bump postcss, nix unused plugins * delete fractal config * uninstall fractal; install eleventy * rebuild package-lock * install js-yaml * delete fractal.js * stub out docs dir, docs.css * add eleventy config * bump postcss deps w/npm audit * rename "build-site" script -> "build-docs" * use eslint-config-sfgov * add eleventy nav plugin * ignore more vim swapfiles * nix postcss-scss * reorganize top-level CSS imports * rewrite button docs * fix up watching /dist * set up remark plugin * delete fractal.css * set markdownTemplateEngine to "njk" * rename preview.js to docs.js * add examples dataset + pagination render * wrap main template area w/margins * add default { layout: "base" } via global data * add type="text/javascript" * add text between headings + button code examples * set HTML template engine to Nunjucks * add CSS override for [hidden] * fix tokens data export * add 2px to spacing scale * add "design system" to header, hide search * add "component" tag to buttons page * stub out components and tokens index pages * flesh out colors page * move font imports to fonts.css * add "Monospace body" type specimen * add fontFamily.mono to the theme * apply .text-small to .font-mono * delete .body class declaration (dupe of .text-body) * add highlight.js styles * add "position" to tailwind config * add base styles for <pre> and <code> * add "inherit" to fontFamily tokens * break out each button example * fix link hrefs and padding in header * improve responsive padding in main layout * build out code copy and preview links * add 4px borderRadius * install classnames * add sfgov-icons and clipboard-copy-element scripts * fix up <code> and <pre> base styles * tidy up color docs * fix up eslint config * move typography to /docs/components * move spacing docs from src/components/spacing to docs/components * set up eleventy nav for /components + /tokens * add new slate colors * use new slate colors * simplify font css loading * move fontFamily.inherit into theme.js * delete fractal button page + preview template * rework example parsing, add /examples/ listing * add group-hover variant to display in tailwind config * make autolink header links nicer * use node 14+ * fix code block ids * run npm audit fix * tokens -> foundations, update top-level nav * extract search include * nix inline TOC from components page * stub out nav and toc includes, base layout * enable flexDirection tailwind plugin * stub out prose heading styles * responsive layout * delete unused includes * move typography from /components to /foundations * add stuff to Overview page * upgrade eleventy-navigation * add metadata to component pages * add metadata to foundation pages * stub out breadcrumb * rework page templates * stub out TOC * add computed eleventy data for components and foundations * add remark-toc, remark-behead * rework remark plugin setup * add TOC heading to buttons page * enable Tailwind "inset" config * swap eleventy-plugin-toc in for remark-toc * nix remark-toc, toc-rename * nix TOC heading on buttons page * move typography to markdown * install remark-gfm * add responsive variant to tw flexDirection * add spacing scale to tw width and height configs * add 11ty toc plugin, custom nav * migrate spacing docs to markdown * ename remark-gfm * make code example plugins more resilient * stub out kbd component page * delete unused nav.yml * delete remark prose plugin * fix theme data export * reset toc wrapper * add 24px spacer for body line height * add 2-, 3- and 4-pixel border widths * tidy up buttons metadata * migrate typography page to markdown w/examples * delete h1 from overview page * tidy up color metadata * rework toc, page title layout * stub out prose and toc styles * add "develop" npm script w/NODE_ENV=development * add force-reloader for eleventy config * rework code frame layout * swap eleventy-plugin-toc for custom plugin * tidy up metadata * nix .toc styles * rework toc include * nix top margin on first prose heading * improve TOC layout * add back highlight.js colors 😬 * use "Page title | Site title" document title convention * add sf.gov favicon * swap left nav pr-100 for mr-60 * add filesize template filter * stub out prose table styles * exclude code blocks w/static="true" from examples * style non-example code blocks with same classes * stub out usage page, manifest data (with file sizes) * more subdued prose table styles * more subdued code block styles (no border) * use font-regular in autolink headers ("#") * simplify button example markup * make child nav links block * fix :first-of-type top margin reset, add .hljs-comment styles * add browser support + IE sections to usage * move CSS docs to separate page * stub out React usage page * tweak css bundle usage * use variables on react usage page * fix typo on typography page * fix up spacing * update README * install rehype-raw * add rehype-raw to enable HTML in markdown 🙃 * make the TOC sticky * nix eleventyNavigation from index.md * only reset top margin on .prose > :first-child * set https_only: true in static.json * upgrade babel packages * use node 14.x * add repo_url template filter * stub out Development (usage) docs * fix up example open and copy buttons * add shellcheck reference * install nunjucks, hast utilities * move template filters into lib/eleventy/filters * set up remark "presets" * replace code example markup with template * add remark plugin to interpolate standalone code examples w/nunjucks * iterate over tokens in spacing examples * better spacing on typography examples * move nunjucks env into lib/eleventy/nunjucksEnv * install remark-directive * add swatch directives * migrate color docs to markdown w/directives * simplify autolink-headings plugin * add custom filters to nunjucksEnv * fix branch substitution in repo_url filter * add generated timestamp to site data * add git metadata * add build-meta include * better git metadata * add local_time template filter * format generated timestamp in Pacific time * add unpkg + GitHub links to header * add Versioning section to usage docs * try "America/Los_Angeles" instead of "US/Pacific" * update color docs to match Figma * fix wrapping of swatches * tweak heading spacing in prose (docs only) * add better heading classes * simplify readme development docs live in on the site now, so we can simplify this * Create docs.md * nix .prose margin reset for <pre> * 1.4.0 * nix "project" field from package.json Co-authored-by: jackson.flint.gonzales <[email protected]> * Improve page git metadata (#42) * use dotenv in development * move git CLI helper to lib/git * use common nunjucks env in code-example-frame * replace local_time template filter with local_date * install dotenv, @octokit/rest * improve computed git metadata * make git metadata fetching more efficient Co-authored-by: jackson.flint.gonzales <[email protected]>
1 parent 23c5d73 commit 50113d9

Some content is hidden

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

91 files changed

+7689
-7206
lines changed

.eleventy.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const dev = process.env.NODE_ENV === 'development'
2+
if (dev) {
3+
require('dotenv').config()
4+
}
5+
6+
const remark = require('@fec/eleventy-plugin-remark')
7+
const remarkConfig = require('./lib/remark').eleventyPluginConfig
8+
const navigation = require('./lib/eleventy/nav')
9+
const yaml = require('js-yaml')
10+
const toc = require('./lib/eleventy/toc')
11+
const filters = require('./lib/eleventy/filters')
12+
13+
module.exports = config => {
14+
if (dev) {
15+
const reloadOnChange = require('./lib/eleventy/reload')
16+
reloadOnChange(__filename, ['lib/**/*.js'])
17+
}
18+
19+
config.addPlugin(navigation)
20+
config.addPlugin(remark, remarkConfig)
21+
config.addPlugin(toc, {
22+
ignore: 'h1',
23+
startLevel: 3
24+
})
25+
26+
for (const [name, filter] of Object.entries(filters)) {
27+
config.addFilter(name, filter)
28+
}
29+
30+
config.addDataExtension('yml', contents => yaml.safeLoad(contents))
31+
32+
config.setUseGitIgnore(false)
33+
config.addWatchTarget('./dist')
34+
config.addPassthroughCopy('dist')
35+
36+
return {
37+
dir: {
38+
input: 'docs',
39+
output: 'public'
40+
},
41+
htmlTemplateEngine: 'njk',
42+
markdownTemplateEngine: 'njk'
43+
}
44+
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.*.js

.eslintrc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module.exports = {
2+
plugins: ['sfgov'],
3+
extends: [
4+
'plugin:sfgov/recommended',
5+
'plugin:sfgov/node'
6+
],
27
env: {
3-
browser: true,
4-
commonjs: true,
58
es2021: true,
69
node: true
710
},
8-
extends: [
9-
'standard'
10-
],
1111
parserOptions: {
1212
ecmaVersion: 12
1313
},

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- uses: actions/checkout@v2
99
- uses: actions/setup-node@v1
1010
with:
11-
node-version: 12
11+
node-version: 14
1212

1313
- run: npm ci
1414
- run: npm run lint

.github/workflows/reports.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Reports
2+
on: [pull_request]
3+
4+
jobs:
5+
reports:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: preactjs/compressed-size-action@v2
10+
with:
11+
repo-token: ${{ github.token }}
12+
pattern: 'dist/**/*.{css,js}'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
**/.*.sw?
12
*.tgz
2-
.*.sw?
33
.env
44
dist/
55
node_modules/

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# design-system
2-
The new design system for the City &amp; County of San Francisco
1+
# San Francisco Design System
2+
3+
This is the design system for [SF.gov](https://sf.gov) and the City &amp; County of San Francisco.
4+
5+
Design and developer documentation is available at [design-system.sf.gov](https://design-system.sf.gov).

docs/_data/assets.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
styles: [
3+
{ href: '/dist/css/sfds.css' },
4+
{ href: '/dist/css/fonts.css' },
5+
{ href: '/dist/css/docs.css' }
6+
],
7+
scripts: [
8+
{ src: '/dist/js/docs.js' },
9+
{ src: 'https://unpkg.com/@sfgov/[email protected]/dist/sfgov-icons.umd.js', defer: true },
10+
{ src: 'https://unpkg.com/@github/[email protected]/dist/index.umd.js', defer: true }
11+
]
12+
}

docs/_data/eleventyComputed.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const pkg = require('../../package.json')
2+
const { git } = require('../../lib/git')
3+
const { Octokit } = require('@octokit/rest')
4+
const { branch } = require('./git')
5+
6+
const github = new Octokit({ auth: process.env.GITHUB_TOKEN })
7+
8+
const gitMetaCache = new Map()
9+
10+
module.exports = {
11+
git: {
12+
commit (data) {
13+
const path = data.page.inputPath.replace(/^\.\//, '')
14+
return getLastCommit(path)
15+
}
16+
}
17+
}
18+
19+
async function getLastCommit (path) {
20+
let meta
21+
if (gitMetaCache.has(path)) {
22+
return await gitMetaCache.get(path)
23+
}
24+
25+
console.info('getting last commit for', path)
26+
if (process.env.NODE_ENV === 'development') {
27+
meta = getLastCommitFromGit(path)
28+
} else if (github) {
29+
const promise = getLastCommitFromGitHub(path)
30+
// put the promise in the cache so that simultaneous requests for the same
31+
// path await the same request
32+
gitMetaCache.set(path, promise)
33+
meta = await promise
34+
}
35+
gitMetaCache.set(path, meta)
36+
return meta
37+
}
38+
39+
function getLastCommitFromGit (path) {
40+
const log = git('log', '-1', '--', path)
41+
const [first, second, third] = log.split('\n')
42+
return {
43+
sha: match(first, /^commit ([a-f0-9]+)/, 1),
44+
author: match(second, /Author: +.*<([^@]+)@users\.noreply\.github\.com>/, 1),
45+
date: match(third, /Date: +(.+)/, 1)
46+
}
47+
}
48+
49+
async function getLastCommitFromGitHub (path) {
50+
const [owner, repo] = pkg.repository.split('/')
51+
let res, commits
52+
try {
53+
res = await github.rest.repos.listCommits({
54+
owner,
55+
repo,
56+
path,
57+
sha: branch,
58+
per_page: 1
59+
})
60+
commits = res.data
61+
} catch (error) {
62+
console.warn('error loading commits for "%s"', path, error)
63+
gitMetaCache.set(path, null)
64+
return null
65+
}
66+
67+
if (commits?.length) {
68+
const [{ sha, commit, author }] = commits
69+
const meta = {
70+
sha,
71+
date: commit.author?.date,
72+
author: {
73+
name: commit.author?.name,
74+
login: author.login
75+
}
76+
}
77+
// console.info('caching git meta for "%s"', path, meta)
78+
return meta
79+
} else {
80+
console.warn('unable to get commit for "%s"', path, res)
81+
return null
82+
}
83+
}
84+
85+
function match (str, pattern, index = 1) {
86+
const m = str ? str.match(pattern) : null
87+
return m ? m[index] : null
88+
}

docs/_data/examples.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const globby = require('globby')
2+
const remark = require('remark')
3+
const visit = require('unist-util-visit')
4+
const interpolateCode = require('../../lib/remark/interpolate-code')
5+
const codeExample = require('../../lib/remark/code-example')
6+
const { readFileSync } = require('fs')
7+
8+
module.exports = getExamples
9+
10+
async function getExamples () {
11+
const examples = []
12+
const mds = await globby('docs/**/*.md')
13+
const processor = remark()
14+
.use(require('remark-slug'))
15+
.use(interpolateCode)
16+
.use(codeExample)
17+
.use(() => (tree, file) => {
18+
visit(tree, 'code', (node, index, parent) => {
19+
if (node.data?.id && node.data?.meta?.static !== 'true') {
20+
examples.push({
21+
code: node.value,
22+
...node.data
23+
})
24+
}
25+
})
26+
})
27+
28+
for (const path of mds) {
29+
await processor.process({
30+
path,
31+
contents: readFileSync(path, 'utf8')
32+
})
33+
}
34+
35+
return examples
36+
}

docs/_data/git.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const pkg = require('../../package.json')
2+
const { git } = require('../../lib/git')
3+
4+
const repoUrl = `https://github.com/${pkg.repository}`
5+
const {
6+
HEROKU_BRANCH: branch = git('symbolic-ref', '--short', 'HEAD'),
7+
HEROKU_SLUG_COMMIT: sha = git('rev-parse', 'HEAD'),
8+
HEROKU_PR_NUMBER: pr
9+
} = process.env
10+
11+
module.exports = {
12+
repo: repoUrl,
13+
defaultBranch: 'main',
14+
pr: pr ? `${repoUrl}/pull/${pr}` : null,
15+
branch,
16+
sha
17+
}

docs/_data/layout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'base'

docs/_data/manifest.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const globby = require('globby')
2+
const { stat } = require('fs').promises
3+
4+
module.exports = async function loadManifest () {
5+
const paths = await globby('dist/**/*.{css,js}')
6+
return Promise.all(
7+
paths.map(path => {
8+
return stat(path)
9+
.then(({ size }) => ({
10+
path,
11+
size
12+
}))
13+
.catch(() => ({ path, size: undefined }))
14+
})
15+
).then(results => results.reduce((map, { path, size }) => {
16+
map[path] = { size }
17+
return map
18+
}, {}))
19+
}

docs/_data/package.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../package.json')

docs/_data/site.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
title: 'San Francisco Design System',
3+
generated: new Date()
4+
}

docs/_data/theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../src/theme')

docs/_data/tokens.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../src/tokens')

docs/_includes/banner.njk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="max-w-xl mx-auto">
2+
<!-- banner -->
3+
<div class="flex bg-yellow-3 rounded" style="overflow: hidden;">
4+
<div class="w-1/2 p-40 text-slate">
5+
<div>Latest</div>
6+
<h1 class="title-lg my-40">
7+
Get updates about the COVID-19 vaccine
8+
</h1>
9+
<a class="btn btn-inverse mb-20" href="javascript:void(0)">Learn more</a>
10+
</div>
11+
<div class="w-1/2" style="position: relative;">
12+
<img style="position: absolute; width: auto; height: 100%; object-fit: cover;"
13+
src="https://sf.gov/sites/default/files/styles/836x484/public/2021-02/Geraldine%20McCowanLHHWeb.jpg?itok=ijhjZjoJ"
14+
aria-describedby="campaign-image-caption">
15+
</div>
16+
</div>
17+
<div class="text-slate-light text-small text-right mt-4">
18+
“Mama G gets her COVID-19 vaccine at Laguna Honda, so she can resume her art” by Laguna Honda Hospital
19+
</div>
20+
</div>

docs/_includes/base.njk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
layout: skeleton
3+
---
4+
{% include 'header.njk' %}
5+
6+
{% set toc = content | toc %}
7+
8+
{% block main %}
9+
<div class="px-20 max-w-xl mx-auto mt-40 mb-100">
10+
<div class="lg:flex justify-end">
11+
<div class="lg:w-1/4 lg:mr-60 mb-40">
12+
{% block nav %}
13+
{% include 'nav.njk' %}
14+
{% endblock %}
15+
</div>
16+
<div class="lg:w-3/4">
17+
{% block content %}
18+
{% include 'title.njk' %}
19+
{% if toc %}
20+
<div class="flex justify-start flex-row-reverse">
21+
<div class="none lg:block lg:w-1/4 mb-40 ml-40">
22+
{% include 'toc.njk' %}
23+
</div>
24+
<div class="lg:w-3/4">
25+
{% include 'main.njk' %}
26+
</div>
27+
</div>
28+
{% else %}
29+
{% include 'main.njk' %}
30+
{% endif %}
31+
{% endblock %}
32+
{% include 'build-meta.njk' %}
33+
</div>
34+
</div>
35+
</div>
36+
{% endblock %}
37+
38+
{% include 'footer.njk' %}
39+
{% include 'scripts.njk' %}

docs/_includes/breadcrumb.njk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% set crumbs = page | ancestors(collections.all, '/') %}
2+
{% if crumbs.length %}
3+
<div class="text-small mb-8">
4+
{% for ancestor in crumbs | reverse %}
5+
<a href="{{ ancestor.data.page.url }}" class="text-slate no-underline">{{ ancestor.data.title }}</a>
6+
{% if not loop.last %} / {% endif %}
7+
{% endfor %}
8+
</div>
9+
{% endif %}

docs/_includes/build-meta.njk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="mt-60 text-slate-light">
2+
{% set branch = git.branch if git.pr else git.defaultBranch %}
3+
<a href="{{ page.inputPath | repo_url(branch) }}">Edit on GitHub</a>
4+
{% if git.commit %}
5+
| last updated
6+
<a
7+
class="text-inherit"
8+
href="{{ '' | repo_url }}/commit/{{ git.commit.sha }}"
9+
>{{ git.commit.date | local_date }}</a>
10+
{% if git.commit.author %}
11+
by <a
12+
class="text-inherit"
13+
href="https://github.com/{{ git.commit.author.login }}"
14+
>{{ git.commit.author.name | default('@' + git.commit.author.login) }}</a>
15+
{% endif %}
16+
{% endif %}
17+
</div>

0 commit comments

Comments
 (0)