Based on / Using:
- BEM (OOCSS needed because 'components')
- SCSS
- NodeJS(?) ([or generate] static)
- Set up global project FE Structure (ITCSS/SMACSS/etc)
- Build/change (new) component
- Generate new SG
- Test / compare (screenshots/linting/etc.)
We'd need a highly modular structure for this to work. BEM/ITCSS/SMACSS etc. Also: we'd need to make sure we write our CSS properly and work OOCSS.
A 'component' contains: HTML, DATA, CSS and optionally JS.
There should be one(!) 'canonical' variant of something. Using 'production' CSS/JS and HTML.
- Create
components/my-component/my-component.html
template (e.g. handlebars/etc) - Create
components/my-component/my-component.json
with content (data) - Create
components/my-component/my-component.scss
with DSS-Like meta-comments /* @html: my-component.html */ etc. - Create
components/my-component/my-component.js
(e.g. browserified module)
The above could possibly be generated by a script: npm create-component my-component
.
(The component could be @import
ed automatically in e.g. main.scss
)
If you go really modular, you could create a seperate 'package'(.json) for each component. With its own package.json
and tests etc.
Generating a Styleguide should do the following:
-
Loop over all components in
components/
-
(re)Generate new 'production' CSS from SCSS -- Lint/Hint -- Minify -- etc -- Break on Linting/Syntax errors -- Output to
styleguide/my-component/
-
(optionally) re-generate
my-component.js
-- Lint/Hint -- Minify -- etc -- Break on Linting/Syntax errors -- Output tostyleguide/my-component/
-
Compile
my-component.html
from template + data -- Minify -- etc -- Output tostyleguide/my-component/index.html
This compiled styleguide/my-component/index.html
should be stand-alone.
-
Linkable
-
Create screenshot(s)
styleguide/my-component/my-component-xyz.png
ofstyleguide/my-component/index.html
-
re-compile complete styleguide HTML in e.g.
./styleguide/*
-- Add/import new component HTML to SG files
etc. etc,
Thanks @branneman! Everybody seems to be doing the same thing huh… ;-)
I guess that's a good thing: I already learned something from how you've set up your gulp tasks at Mirabeau 😉
The Gist above simply was a braindump for how I'd like to approach 'Styleguide-First' development. I am currently struggling with what would be a most flexible, DRY and robust way.
I'd like to be depending on as few tools as possible. For that reason I'm not so happy with most styleguide 'systems' out there. Also: I'd like to move away from Gulp and use NPM Scripts directly.
Would love to hear your thoughts on this. Thx