As front-end developers working on the responsive web there is a growing need to write CSS that is modular in order to effectively maintain and update your sites and applications. A style guide driven approach can go a long way to attaining this goal.
This presentation sketches the advantages of using front-end style guides, what they should contain and do a practical demonstration of creating a style guide using Jekyll, a static site generator.
2. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
WHAT IS A FRONT-END STYLE GUIDE AND WHAT IS IT FOR?
•Style guides are the perfect place to start a website build and
modular base. They bridge the gap between design and
development.
•Style guides show the design elements you have at your disposal.
•Style guides show the design elements you lack.
•Style guides provide an accessible baseline on which to build upon.
•Style guides allow you to test code early in browsers and on
devices.
•Style guides leave a design & build blueprint for future
development.
3. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
WHAT IS A FRONT-END STYLE GUIDE AND WHAT IS IT FOR?
•Style guides set a precedent, demonstrating how designers or
developers expect something to be done in future.
•Style guides are useful when several people are working on the
same codebase
•Style guides encourage consistency
•Style guides make maintaining a site easier
•Style guides use real code and run in the browser
•A style guide can be a living document that grows with a site over
time
•A style guide helps prevent duplication of code and design patterns.
4. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
STYLE GUIDE EXAMPLES
•Clearleft
•Github
•Pattern lab
•Mailchimp
•Atlassian
•Lonely Planet
•And many more
5. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
STYLE GUIDE GENERATION OPTIONS
•KSS - rails
•Tomdoc - ruby
•Pattern Primer - one of many PhP options
•Lots of javascript options
•None of the above
6. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
WHAT IS JEKYLL?
• Jekyll is a parsing engine bundled as a ruby gem
!
• It is used to build static sites from dynamic components
such as templates, partials, liquid code and markdown.
!
• Jekyll is billed as "a simple, blog aware, static site
generator”.
• Powers GitHub pages
7. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
JEKYLL REQUIREMENTS
•Ruby
•Ruby gems
•NodeJS
•Linux, Unix, or Mac OS X
•Not officially supported on Windows but it can be run
•Mac OS X - probably need to install xCode’s command line tools.
8. !
~ $ gem install jekyll
~ $ jekyll new my-awesome-site
~ $ cd my-awesome-site
~/my-awesome-site $ jekyll serve
!
# => Now browse to http://localhost:4000
INSTALLING JEKYLL
NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
9. !
$ jekyll build
# => The current folder will be generated into ./_site
!
$ jekyll build --destination <destination>
# => The current folder will be generated into <destination>
!
$ jekyll build --watch
# => The current folder will be generated into ./_site,
# watched for changes, and regenerated automatically.
BASIC USAGE
NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
The Jekyll gem makes a jekyll executable available to you in your
Terminal window. You can use this command in a number of ways:
10. $ jekyll serve
# => A development server will run at http://localhost:4000/
!
$ jekyll serve --watch
# => Same as `jekyll serve`, but watch for changes and
regenerate automatically.
DEVELOPMENT SERVER
NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
•Jekyll comes with a built-in development server, allowing local
previews of your site.
12. name: Site name
main_title: Site title
markdown: redcarpet
highlighter: pygments
permalink: /:title
CONFIGURATION
NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
Jekyll allows you to configure your sites in many different ways thanks
to the powerful and flexible configuration options.
15. {% highlight css %}
.submit-button:hover {
box-shadow: 0 -2px 10px 0 rgba(0, 0, 0, 0.1);
text-decoration: none;
}
{% endhighlight %}
SYNTAX HIGHLIGHTING
NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
Jekyll has built in support for syntax highlighting of over 100
languages thanks to Pygments.
To use Pygments, you must have Python installed on your system and
set highlighter option to pygments in your site’s configuration file.
16. NEWMEDIALABS.CO.ZA • @URBANRENEWAL • JUSTIN@NEWMEDIALABS.CO.ZA
ISSUES WITH THIS APPROACH
•Not a living style guide
•If CSS, js or HTML changes it needs updating in two places
•Hard to demonstrate responsive layouts
•You are building two sites - your actual site plus your style guide
framework - making it operative that there are no conflicts in your
CSS or HTML.
•Jekyll problems
•Slow
•Build issues