Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

Automatically generate style guide from SCSS comments #76

Merged
merged 3 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/public/packs
/public/packs-test
/node_modules

/coverage
/design/styleguide

.env
4 changes: 4 additions & 0 deletions app/assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ TL;DR: if you only run `bin/rails s` in local development when you want to work

Asset gems don't work; look for equivalent npm packages instead.

## Styleguide

While running BOTH `bin/rails s` and `bin/webpack-dev-server`, if you visit `/packs/styleguide` you'll be able to view our application's design style guide. We use [kss-node](https://github.com/kss-node/kss-node) to generate it.

## Frameworks

Is `rails-ujs` plus `turbolinks` a framework? Because that's what we're using. That, and as little vanilla JavaScript as is feasible. We might add a [svelte](https://svelte.technology) component or three later if we really need them. We would prefer to design such that we don't need them.
Expand Down
1 change: 0 additions & 1 deletion app/assets/src/stylesheets/00-base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@import "variables";

@import "buttons";
@import "forms";
@import "layout";
@import "lists";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Button
//
// Your standard button suitable for clicking.
//
// :hover - Highlights when hovering.
//
// Markup:
// <button>Button</button>
//
// Style guide: components.button


$_button-background-color: $action-color;
$_button-background-color-hover: shade($action-color, 20%);
$_button-text-color: $white;
Expand Down
1 change: 1 addition & 0 deletions app/assets/src/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "bourbon";
@import "00-base/base";
@import "01-atoms/buttons";
@import "02-molecules/forms";
@import "03-organisms/header";
@import "04-templates/templates";
28 changes: 28 additions & 0 deletions config/webpack/development.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
const environment = require('./environment')
const path = require('path')
const express = require('express')
const KssWebpackPlugin = require('kss-webpack-plugin')

function railsRootJoin (pathname) {
return path.join(__dirname, '..', '..', pathname)
}

function styleguideRelativePath (pathname) {
return path.join(environment.config.output.publicPath, pathname)
}

// Since KssWebpackPlugin needs filenames at configure-time,
// we can't include the hash in development filenames
environment.config.set('output.filename', '[name].js')
const extractTextPlugin = environment.plugins.get('ExtractText')
extractTextPlugin.filename = '[name].css'

environment.plugins.prepend('KSS', new KssWebpackPlugin({
source: railsRootJoin('app/assets/src/stylesheets'),
destination: railsRootJoin('design/styleguide'),
css: styleguideRelativePath('application.css'),
js: styleguideRelativePath('application.js')
}))

environment.config.set('devServer.before', (app) => {
app.use('/packs/styleguide', express.static(railsRootJoin('design/styleguide')))
})

module.exports = environment.toWebpackConfig()
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
},
"private": true,
"scripts": {
"lint": "eslint app/assets"
"lint": "eslint app/assets config/webpack"
},
"dependencies": {
"@rails/webpacker": "^3.2.0",
"bourbon": "^5.0.0-beta.8",
"caniuse-lite": "^1.0.30000784",
"connect": "^3.6.5",
"eslint": "^4.13.1",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"eyeglass": "^1.3.0",
"kss": "^3.0.0-beta.18",
"kss-webpack-plugin": "^1.2.0",
"lodash": "^4.17.4",
"rails-ujs": "^5.1.4",
"webpack": "^3.10.0",
Expand Down
109 changes: 103 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ [email protected]:
dependencies:
lodash "^4.14.0"

async@^1.5.2:
async@^1.4.0, async@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

Expand Down Expand Up @@ -840,7 +840,7 @@ block-stream@*:
dependencies:
inherits "~2.0.0"

bluebird@^3.5.0:
bluebird@^3.3.3, bluebird@^3.5.0:
version "3.5.1"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"

Expand Down Expand Up @@ -1331,6 +1331,15 @@ connect-history-api-fallback@^1.3.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz#b06873934bc5e344fef611a196a6faae0aee015a"

connect@^3.6.5:
version "3.6.5"
resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.5.tgz#fb8dde7ba0763877d0ec9df9dac0b4b40e72c7da"
dependencies:
debug "2.6.9"
finalhandler "1.0.6"
parseurl "~1.3.2"
utils-merge "1.0.1"

console-browserify@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
Expand Down Expand Up @@ -2242,6 +2251,18 @@ fill-range@^2.1.0:
repeat-element "^1.1.2"
repeat-string "^1.5.2"

[email protected]:
version "1.0.6"
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.6.tgz#007aea33d1a4d3e42017f624848ad58d212f814f"
dependencies:
debug "2.6.9"
encodeurl "~1.0.1"
escape-html "~1.0.3"
on-finished "~2.3.0"
parseurl "~1.3.2"
statuses "~1.3.1"
unpipe "~1.0.0"

[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5"
Expand Down Expand Up @@ -2319,6 +2340,10 @@ foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"

foreachasync@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/foreachasync/-/foreachasync-3.0.0.tgz#5502987dc8714be3392097f32e0071c9dee07cf6"

forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
Expand Down Expand Up @@ -2364,6 +2389,13 @@ fs-extra@^0.30.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"

fs-extra@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.1.2.tgz#046c70163cef9aad46b0e4a7fa467fb22d71de35"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"

fs-write-stream-atomic@^1.0.8:
version "1.0.10"
resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9"
Expand Down Expand Up @@ -2535,6 +2567,16 @@ handle-thing@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4"

handlebars@^4.0.0:
version "4.0.11"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc"
dependencies:
async "^1.4.0"
optimist "^0.6.1"
source-map "^0.4.4"
optionalDependencies:
uglify-js "^2.6"

har-schema@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"
Expand Down Expand Up @@ -3180,6 +3222,24 @@ klaw@^1.0.0:
optionalDependencies:
graceful-fs "^4.1.9"

kss-webpack-plugin@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/kss-webpack-plugin/-/kss-webpack-plugin-1.2.0.tgz#3ffb6aa82035cac42fc7067252a34904e6df4cf9"
dependencies:
kss "^3.0.0 || ^3.0.0-beta.14"

"kss@^3.0.0 || ^3.0.0-beta.14", kss@^3.0.0-beta.18:
version "3.0.0-beta.18"
resolved "https://registry.yarnpkg.com/kss/-/kss-3.0.0-beta.18.tgz#832a23bda4cabecf5426b93892c1b618db7ea24e"
dependencies:
bluebird "^3.3.3"
fs-extra "^2.0.0"
glob "^7.0.3"
handlebars "^4.0.0"
marked "^0.3.6"
twig "^0.10.2"
yargs "^6.0.0"

lazy-cache@^0.2.3:
version "0.2.7"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-0.2.7.tgz#7feddf2dcb6edb77d11ef1d117ab5ffdf0ab1b65"
Expand Down Expand Up @@ -3239,6 +3299,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

locutus@^2.0.5:
version "2.0.9"
resolved "https://registry.yarnpkg.com/locutus/-/locutus-2.0.9.tgz#e265af1e85fd19173e74386373888560783a02fc"

lodash._reinterpolate@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
Expand Down Expand Up @@ -3342,6 +3406,10 @@ map-obj@^1.0.0, map-obj@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"

marked@^0.3.6:
version "0.3.9"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.9.tgz#54ce6a57e720c3ac6098374ec625fcbcc97ff290"

math-expression-evaluator@^1.2.14:
version "1.2.17"
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac"
Expand Down Expand Up @@ -3452,7 +3520,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"

"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
"minimatch@2 || 3", minimatch@3.0.x, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
Expand All @@ -3466,6 +3534,10 @@ minimist@^1.1.3, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"

mississippi@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-1.3.0.tgz#d201583eb12327e3c5c1642a404a9cacf94e34f5"
Expand Down Expand Up @@ -3749,6 +3821,13 @@ opn@^5.1.0:
dependencies:
is-wsl "^1.1.0"

optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
dependencies:
minimist "~0.0.1"
wordwrap "~0.0.2"

optionator@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
Expand Down Expand Up @@ -5206,7 +5285,7 @@ source-map-support@^0.4.15:
dependencies:
source-map "^0.5.6"

source-map@^0.4.2:
source-map@^0.4.2, source-map@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
dependencies:
Expand Down Expand Up @@ -5540,6 +5619,14 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"

twig@^0.10.2:
version "0.10.3"
resolved "https://registry.yarnpkg.com/twig/-/twig-0.10.3.tgz#67604e08e1920ebf2faf80a901e256189c8a3c67"
dependencies:
locutus "^2.0.5"
minimatch "3.0.x"
walk "2.3.x"

type-check@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
Expand All @@ -5557,7 +5644,7 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

uglify-js@^2.8.29:
uglify-js@^2.6, uglify-js@^2.8.29:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
dependencies:
Expand Down Expand Up @@ -5695,6 +5782,12 @@ [email protected]:
dependencies:
indexof "0.0.1"

[email protected]:
version "2.3.9"
resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.9.tgz#31b4db6678f2ae01c39ea9fb8725a9031e558a7b"
dependencies:
foreachasync "^3.0.0"

watchpack@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.4.0.tgz#4a1472bcbb952bd0a9bb4036801f954dfb39faac"
Expand Down Expand Up @@ -5835,6 +5928,10 @@ [email protected]:
version "0.0.2"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"

wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
Expand Down Expand Up @@ -5886,7 +5983,7 @@ yargs-parser@^7.0.0:
dependencies:
camelcase "^4.1.0"

yargs@^6.6.0:
yargs@^6.0.0, yargs@^6.6.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208"
dependencies:
Expand Down