Giter Site home page Giter Site logo

mattrothenberg / styleguide-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 4.0 327 KB

A project to help Designers build living styleguides with Sass and Hologram.

Home Page: http://acme-styleguide.cfapps.io

License: MIT License

Ruby 3.00% CSS 67.60% JavaScript 16.14% HTML 13.25%
styleguide livingstyleguide sass hologram

styleguide-boilerplate's Introduction

forthebadge

Acme Styleguide

This is an example project that uses hologram to build this style guide. The instructions listed below assume that you have already installed Node / NPM, and have the Apple Developer Tools installed on your machine.

Orientation

Hologram is a Ruby gem that parses specially formatted comments in your Sass/CSS and turns them into a living styleguide.

The two main directories that you will be interacting with are styleguide-theme and styles.

The former directory is home to the Header and Footer of your styleguide, as well as any static assets you might need to theme it (Yes, you can style the styleguide via this directory). Note that the Header and Footer are simple HTML files, wherein you can pull in 3rd party assets (in this case: Font Awesome, and the Roboto Web Font). Hologram is smart enough to spit out the content of your styleguide in between said header and footer, so don't worry about having to know any Ruby!

Where the fun begins is the styles folder, which is home to a list of Sass files. To get your project kickstarted, we've added Bootstrap 4 to this directory. In any case, feel free to write vanilla CSS, or SCSS-flavored Sass -- the only requirement is that any new files you add to the directory are imported in the style.scss file. For example, if you were to add a new file to the directory called _toasts.scss, be sure to add a corresponding statement in style.scss.

@import 'toasts';

In order for that element to be added to the styleguide, add a Hologram Comment to the top of the file.

/*doc
---
title: Toasts
name: toast
category: components
---

Toasts are not only delicious to eat, but they also...

```html_example
<div class="toast">
  <p>I'm a paragraph inside the toast</p>
</div>
```

*/

Gulp / Automation?

As if we needed another tool, there's another one that you should be aware of: Gulp. We use Gulp to perform a bunch of tedious tasks that would otherwise get in the way of us doing what we do best: designing. Namely, it does the following:

  1. Processes and concatenates all of the .scss files inside of the styles directory and chucks them into a dynamically generated built-styles directory.
  2. Runs the hologram command to create the styleguide as per the brand new stylesheet from Step #1. The output of this step is a brand new styleguide-dist directory.
  3. Spins up a web server that points to the styleguide-dist directory described above.
  4. Watches any changes to your .scss files and runs steps 1-3 again.

Installation

Ruby

Recommend using RVM so you don't have to chown to use your system Ruby. Follow the steps at their site to download and restart your shell session.

Node / NPM

https://docs.npmjs.com/getting-started/installing-node

Apple Developer Tools

xcode-select --install

Install Dependencies / Spin up Server

npm install -g gulp-cli
npm install
gem install bundler
bundle install
gulp

A web browser should open at http://localhost:8080

Deploying your styleguide

PWS

  1. Download the CF CLI
  2. $ cf login
  3. $ cf create-space [spacename] [i]
  4. $ cf target -o "[orgname]" -s "[spacename]" [i]
  5. $ cf push to deploy your styleguide using the staticfile buildpack using the manifest
    [i] This can also be managed online via PWS

Heroku

Make sure you have the Heroku CLI downloaded. Then login to heroku and install the static website cli:

heroku login
heroku plugins:install heroku-cli-static

Create a new Heroku site, and set the buildpack config

heroku create
heroku buildpacks:set https://github.com/hone/heroku-buildpack-static

Initialize the static directory. In our case it's the styleguide-dist folder.

heroku static:init

You should ECHO out something like this:

? Enter the directory of your app: styleguide-dist
? Drop `.html` extensions from urls? No
? Path to custom error page from root directory:
{
  "root": "styleguide-dist",
  "clean_urls": false
}

Now deploy! Scale up a web server, open & enjoy :)

heroku static:deploy
heroku ps:scale web=1
heroku open

Here's our same styleguide, running on Heroku => https://arcane-tundra-22168.herokuapp.com/


Visual Regression Testing

Wraith uses a headless browser to create screenshots of webpages on different environments(or at different moments in time) and then creates a diff of the two images; the affected areas are highlighted in blue. For more information visit Wraith's homepage or their Github page.

Install Dependencies

You can use PhantomJS or CasperJS for a headless browser. CasperJS will allow you to pass along a selector to take screenshots of a component.

brew install phantomjs
brew install imagemagick
brew install casperjs

Setup and Use

Add Wraith as a dependency to your Gemfile

bundle

If you're capturing images in your local environment make sure the server is running. To run regression tests against the styleguide:

gulp

Regression Testing Options

For Wraith Capture: Given two domains, Wraith will take screenshots of both and compare them. This is good for comparing test and live versions of the same site.

gulp wraith-capture

alias wraith capture test/configs/capture.yaml

For Wraith History: Compare the same domain over time. This is good for checking that your website continues to look the same (especially useful if your site relies on third-party components).

gulp wraith-history

alias wraith history test/configs/history.yaml

For Wraith Latest: Capture new shots to compare to a baseline image.

gulp wraith-capture

alias wraith latest test/configs/history.yaml

Example of a Failing Test

styleguide-visual-regression.png

styleguide-boilerplate's People

Contributors

abhisharma2 avatar aflanagan avatar aflanagan-trulia avatar g12n avatar jcantrell-trulia avatar jdcantrell avatar mattrothenberg avatar paulfarino avatar stubbornella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

styleguide-boilerplate's Issues

Create wiki?

should we create a wiki area? basically shorten the README and direct folks to wiki instead. Gives more ability to break down the styleguide. wiki could be broken down to:

  1. Orientation
  2. Deployment
  3. Examples (I'm in the midst of using this to create my co's styleguide ๐Ÿ‘ )
  4. External Resources (links to Hologram, et al)
  5. ??

this would keep only the Installation steps in the README - short & sweet. push back if this isn't a good idea, ๐Ÿบ infused Friday thoughts, thats all - ๐Ÿ˜ .

Replace Bootstrap with BassCSS

I've gotten some feedback that it's confusing how some of the files in the styles directory, e.g., _alert.scss are empty, and yet components still get created when the styleguide is built.

This is because I'm pulling in Bootstrap via CDN in the styleguide-theme directory.

To that end, does it make more sense to replace Bootstrap with a library like BassCSS, where the majority of the components have to be rolled by hand? I think it would better illustrate the workflow we encourage Designers to take.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.