Giter Site home page Giter Site logo

livingstyleguide / livingstyleguide Goto Github PK

View Code? Open in Web Editor NEW
870.0 37.0 83.0 1.31 MB

Easily create front-end style guides with Markdown and Sass/SCSS.

Home Page: https://livingstyleguide.org/

License: Other

Ruby 62.71% HTML 9.89% CSS 27.40%
livingstyleguide sass css front-end frontend style-guide styleguide ruby frontend-components rails

livingstyleguide's Introduction

LivingStyleGuide Build Status

Easily create living style guides/front-end style guides/pattern libraries by adding Markdown documentation to your Sass project. Follow @LSGorg for updates.

preview


Getting Started

Command Line Interface

  1. Setup

    $ gem install livingstyleguide
    
  2. Create sass/styleguide.lsg (replace sass/ with the directory name of your Sass files) with:

    // Replace with your default Sass/SCSS file name:
    @scss application.css.scss
    
    // Set the HTML title of the document:
    @title My Living Style Guide
    
    // Import all your style guide files
    @import sass/**/*.lsg
    
  3. Write documentation for each module sass/partials/_buttons.lsg (to describe _buttons.scss in the same folder):

     # Buttons
    
     ```
     <button class="button">Example button</button>
     ```
    
     ```
     <button class="button -primary">Example button</button>
     ```
    
  4. Call livingstyleguide compile sass/styleguide.lsg public/styleguide.html This will automatically:

    • Combine all Markdown files and convert them to HTML
    • Create a beautiful style guide
    • Saves the style guide as public/styleguide.html
    • Show the HTML source syntax highlighted close to each example

Tips for the Command Line Interface

  • Create your project with or without Compass.
  • This can be easily integrated into non-Ruby build systems.
  • If you omit the input and output filenames, STDIN and STDOUT will be used.

Rails Integration

Be aware: From LSG v2 on Rails 3.x is not supported due to outdated Sprockets and Tilt versions.

  1. Setup: Add this line to your application’s Gemfile:

    gem "livingstyleguide"

    And then execute:

    $ bundle
    $ rails s
    
  2. Create app/assets/stylesheets/styleguide.html.lsg with:

    // Replace with your default Sass/SCSS file name:
    @scss application.css.scss
    
    // Set the HTML title of the document:
    @title My Living Style Guide
    
    // Import all your style guide files
    @import **/*.lsg
    
  3. Write documentation for each module app/assets/stylesheets/partials/_buttons.lsg (to describe _buttons.sass in the same folder):

    # Buttons
    
    ```
    <button class="button">Example button</button>
    ```
    
    ```
    <button class="button -primary">Example button</button>
    ```
    
  4. Open http://localhost:3000/assets/styleguide.html. This will automatically:

    • Combine all Markdown files and convert them to HTML
    • Create a beautiful style guide
    • Show the HTML source syntax highlighted close to each example

Tips for Rails

  • Add the styleguide.html to the precompile list in config/application.rb:

    config.assets.precompile += ["styleguide.html"]
  • There is a Rails example application available on Github.

  • Use sass-rails > v5 to allow Sass > v3.2:

    # Gemfile:
    gem "sass-rails", "~> 5.0.0.beta1"

    See issue #99 for discussions.

Using it with Rails 4

Since Rails 4 non-digest assets are not created anymore. If you want a public sharable url consider using something like Non Stupid Digest Assets

Middleman Integration

  1. Setup: Add this line to your application’s Gemfile:

    gem "livingstyleguide"
    

    And then execute:

    $ bundle
    $ middleman
    
  2. Create source/styleguide.html.lsg with:

    // Replace with your default Sass/SCSS file name:
    @scss application.css.scss
    
    // Set the HTML title of the document:
    @title My Living Style Guide
    
    // Import all your style guide files
    @import css/**/*.lsg
    
  3. Write documentation for each module source/css/partials/_buttons.lsg (to describe _buttons.sass in the same folder):

     # Buttons
    
     ```
     <button class="button">Example button</button>
     ```
    
     ```
     <button class="button -primary">Example button</button>
     ```
    
  4. Open http://localhost:4567/styleguide.html. This will automatically:

    • Combine all Markdown files and convert them to HTML
    • Create a beautiful style guide
    • Show the HTML source syntax highlighted close to each example

Tips for Middleman

  • Don’t put the styleguide.html.lsg into your CSS folder (source/css/). It won’t work.
  • There is a Middleman example application available on Github.
  • A more complex production project can be found online. The complete source of this Middleman project is available on Github. You’ll find a lot of configuration on how to make the style guide look beautiful.

Grunt

See NexwayGroup/grunt-livingstyleguide.

Gulp

See efacilitation/gulp-livingstyleguide.

Broccoli

See livingstyleguide/broccoli-livingstyleguide.

Ember CLI

See livingstyleguide/broccoli-livingstyleguide (comments on Ember CLI can be found there).


Writing the style guide

Just write normal Markdown. The style guide examples are written in code blocks surrounded by three backticks:

```
<h1>This is an example</h1>
```

Just make sure, when you write a headline, put a space between # and the headline. In other words: # Headline, not #Headline.

In addition to Markdown, there are several commands (starting with an @) which automate things to make generating style guides more fun. Commands can be used within and outside of code blocks, but will have a different meaning. Commands available are:

Importing Files

You can import any other *.lsg file at any place within any *.lsg file:

```
// Import a file:
@import folder/file.lsg

// Import a file (`.lsg` will be added by default):
@import folder/file

// Import a file starting with `_` (folder/_file.lsg); this works automatically:
@import folder/file

// Import multiple files:
@import folder/*.lsg
@import folder/*

// Importing from multiple folders:
@import **/*.lsg
@import **/*

// Importing a Haml file (the resulting HTML will be rendered into the style guide):
@import folder/file.haml
@import folder/*.haml
@import **/*.haml
```

All file types supported by Tilt can be imported. By default, @import is looking for *.lsg files.

Writing Examples

A default example outputs the HTML source as:

  • Real HTML in a wrapper to display the results
  • Syntax-highligted code below

Example:

```
<button class="button">Example button</button>
```

There are more commands to generate output. They start with an @ and can be put in the code block:

Colors

You can automatically generate color swatches out of your Sass variables:

@colors {
  $light-red  $gray  $green  $red  $dark-red  $black
}

By clicking the color swatch in the style guide, users can copy the hex code of the color (useful for designers). When pointing the cursor on the variable name, it will be copied on click instead (useful for developers).

The output will respect newlines. The example below will create a 3 × 3 matrix of color swatches and groups shades in columns which might be more easy to understand. - leaves a cell empty in the matrix:

@colors {
  -       $light-red  $gray
  $green  $red        -
  -       $dark-red   $black
}

The LivingStyleGuide also supports CSS colors and Sass functions. All of them will work:

@colors {
  red        #ca1f70              #FFF               rgba(0, 0, 0, 0.5)
  $my-color  my-color-function()  lighten(red, 10%)  darken($my-color, 20%)
}

Haml Examples

This will output the code as HTML but display the syntax highlighted source as Haml (learn how to use Haml by default):

```
@haml
%button.button Example button
```

Manipulating CSS per example

You can add any CSS to each example if it helps to make it better in the style guide only. For example, add some margin between elements:

```
<button class="button">Example button</button>
<button class="button -primary">Example button</button>
@css {
  .button + .button {
    margin-left: 3em;
  }
}
```

This adds 3em margin between both buttons. To avoid this to affect other examples, the CSS code will be scoped to this example only (each example automatically gets a unique id).

If you need the same CSS code for several examples, you can put the CSS outside of the example. This way it will be scoped to the current file:

```
<button class="button">Example button</button>
<button class="button -primary">Example button</button>
```

```
<a class="button">Example button</a>
<a class="button -primary">Example button</a>
```

@css {
  .button + .button {
    margin-left: 3em;
  }
}

For Sass you can also use @sass and @scss:

@sass
  .button + .button
    margin-left: 3em

@scss {
  .button + .button {
    margin-left: 3em;
  }
}

Within the @scss/@sass helper, all variables, mixins, … of your project are available. For example, if my-styles.scss sets $my-project-margin, you can write this:

@scss my-styles.scss

@scss {
  .button + .button {
    margin-left: $my-project-margin;
  }
}

It is possible to add Sass code without scoping (works for @css/scss/sass).

@scss scope: global {
  .code { ... }
}

Or as a shortcut inspired by Sass’ global variables (for @scss/@sass):

@scss !global {
  .code { ... }
}

JavaScript Examples

This will show and execute the JavaScript, e. g. you designed tabs and need few lines of jQuery to bring them alive.

```
@javascript {
  $(".button").click(function() {
    alert("Hello World!");
  });
}
```

CoffeeScript Examples

Same example but using CoffeeScript. It will be executed as JavaScript and displayed as CoffeeScript:

```
@coffee-script
  $(".button").click ->
    alert "Hello World!"
```

Font Examples

Show which fonts should be used on your website—this will output and example text block (A—Z, a—z, 0—9, and some special characters) of the given font. It accepts valid CSS like for font: 32px comic sans ms;.

@font-example 32px comic sans ms

Use your own text (defaults to “ABC…\nabc…\n123…\n!&…” if not set):

@font-example 32px comic sans ms {
  Schweißgequält zündet Typograf Jakob
  verflixt öde Pangramme an.
}

Require Ruby files or Gems

You can require any Ruby file (e.g. for custom commands) or Ruby Gems (e.g. a Compass plugin:

Loads `my-ruby-file.rb`:
@require my-ruby-file

Loads the Susy Gem (must be installed on your system):
@require susy

Output Code

If you just want to output code with no extras (just like in a normal Markdown file), you only need to add the language:

``` html
<div>Some HTML that just gets syntax-higlighted but not put into the document’s DOM</div>
```

No syntax highlighter:

``` plain
<div>Some HTML that just gets syntax-higlighted but not put into the document’s DOM</div>
```

Default Options

You can set options to apply to all commands or all commands giving a name. This is useful, when you depend on Haml or other templating engines. Add a list of default commands to your styleguide.html.lsg:

For example without defaults:

@header
  @haml
  .my-header My Style Guide

```
@haml
.my-example
```

With defaults:

@default type: haml

@header
  .my-header My Style Guide

```
.my-example
```

Working with Existing View Templates

If you want your style guide to work as an API, you might have views already written somewhere else and don’t want to write the same HTML code into the style guide.

First, there is the @data command, which sets local variables to render the view:

```
<h1><%= foo %></h1>
@type erb
@data {
  "foo": "bar"
}
```

This will render as <h1>bar</h1> in the HTML but show the ERB source below. The data is written using JSON or YAML syntax (as JSON is a subset of YAML):

```
<h1><%= foo %></h1>
@type erb
@data format: yaml
  foo: bar
```

If there is already a view template, let’s name it views/headline.html.erb, you can use it:

```
@use views/headline.html.erb
@data {
  "foo": "bar"
}
```

Note: You don’t need to set the @type as this is taken from the view template file suffix.

Tipp: Edge Cases

By repeating using the same template with different data, you can show edge cases—like very long user names or missing values—in your style guide.

Styling the Style Guide

Custom Header

The examples in the screenshot above use custom headers to have an individual look. You can add whatever HTML you want and some Sass to style it to your styleguide.html.lsg:

@header {
  <div class="my-header">
    <img src="my-style-guide-logo.svg" alt="My Style Guide">
    <h1>My Style Guide</h1>
  </div>
}

You can use any templating engine supported by Tilt:

@header type: haml
  .my-header
    %img(src="my-style-guide-logo.svg" alt="My Style Guide")
    %h1 My Style Guide

Custom Footer

See Custom Header, just use @footer.

Custom Head Elements

See Custom Header, just use @head. This way you can add any <meta> tag or link additional files.

Search

Enable search for the style guide:

@search-box

This will add a search box on top of the style guide which commands the content via JavaScript.

You can also customize (e.g. translate) the placeholder for the search box:

@search-box placeholder: Buscar

Custom Settings

Most of the design of the style guide itself, is calculated by few variables in the styleguide.html.lsg:

@style font-family: comic sans ms, arial, sans-serif
@style font-size: 7em
@style background-color: red
@style border-color: $my-color
@style color: #eee
@style code-color: darken(red, 10%)
@style color-swatch-border-radius: 0
  • For a full list of options, have a look at the source (just strip $lsg- from the variables).
  • Every Sass expression is allowed
  • Variables defined in your production Sass are available
  • code-color generates a whole color scheme for syntax highlighting in your corporate colors
  • color-swatch-border-radius: 0 creates squared color swatches

Just play a bit and create an individual style guide which represents your personal taste :)

Including JavaScript

If you need external JavaScript files to be included in the style guide, there are two options: before (in the <head>) or after (just before the closing </body>). It accepts a list of URLs (ending with *.js) or plain JavaScript code:

@javascript-before assets/modernizr.js

@javascript-after http://code.jquery.com/jquery-2.1.3.min.js
@javascript-after assets/application.js
@javascript-after {
  $(function() {
    // custom code
  });
}

If you use @javascript or @coffee-script, your application files and jQuery might need to be included in the javascript-before section.

Using CoffeeScript

Same example as above, just using CoffeeScript. Note, it is using the indented syntax (no colon but indent following lines by two spaces) which works well with CoffeeScript.

@javascript-before assets/modernizr.js

@javascript-after http://code.jquery.com/jquery-2.1.3.min.js
@javascript-after assets/application.js
@javascript-after transpiler: coffee-script
  $ ->
    # custom code

Installation

Add this line to your application’s Gemfile:

gem "livingstyleguide"

And then execute:

$ bundle

Or install it yourself as:

$ gem install livingstyleguide

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Check your changes for coding style:
  • scss-lint -c .scss-style.yml **/*.scss
  • rubocop --config .ruby-style.yml
  1. Commit your changes (git commit -am "Add some feature")
  2. Push to the branch (git push origin my-new-feature)
  3. Create new Pull Request

Code of Conduct

We do follow the Contributor Covenant Code of Conduct; our version including contact information can be found in CODE-OF-CONDUCT.de.


Copyright

Copyright 2012—2017 Nico Hagenburger. See MIT-LICENSE.md for details. Get in touch with @hagenburger on Twitter or open an issue.

livingstyleguide's People

Contributors

anomiseditrix avatar anxhe avatar cjmarkham avatar derfred avatar fanxhe-pair avatar hagenburger avatar hkockerbeck avatar jhilden avatar joostliketoast avatar myabc avatar oliverguenther avatar stephanpavlovic avatar watercycle avatar wikimatze avatar

Stargazers

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

Watchers

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

livingstyleguide's Issues

Some example Markup

Would be cool, to see some example markup, on how to describe a random module with his markup.

Allow Options in Examples

Examples should look like:

~~~ example
@option value
@direct-option
<html><goes><here>
~~~

Example

Instead of:

~~~ haml-example
%button
~~~

It should be:

~~~ example
@haml
%button
~~~

Not compile

I think I did everything as explained but does not compile here.

my file appication.scss and same dir i create the file styleguide.html.lsg ok. My file appication.scss should be so appication.css.scss ?
I tried using that, but the ruby generated an error

My files below

assets/sass/_links_list.md
assets/sass/_links_list.scss

I'm add require "livingstyleguide" in my config.rb and command line compass watch, but when I open the file styleguide.html.lsg in the browser nothing happens.

Appears only settings file source: application.scss title: "My Living Style Guide"

I need a help please.

Search

There should be a search bar on top of the style guide which makes it easy to find the right component.

  • JavaScript only, no jQuery
  • Searches in headlines and text (and maybe source)
  • Hides all non matching examples

Add custom classes to example code

~~~ example
@add-wrapper-class div-example
<div>...</div>
~~~

Would result in:

<div class="livingstyleguide--example div-example">
  <div>...</div>
</div>

Automate combination of Markdown files

Use Sprockets like syntax embedded into Markdown:

---
title: My Living Style Guide

---

# My Living Style Guide

= require coding-style
= require_tree base
= require_tree modules

Groups of colors not supported yet

Currently the colors are generated from the {{variables:base/colors}} line.

Would be nice to have the option to group the colors like:

Fonts:
~~~
@color-example $font-light-color
~~~

Buttons:
~~~
@color-example $button-dark-color
~~~

(ie: "9", opera: "9.5-9.6") isn't a valid CSS value - Error

Hi Nico! :-),

since today i always get this error if i try to enter "livingstyleguide compile {{filename}}". I already uninstalled all gems and installed the livingstyleguide gem again. But it doesn't resolve the error. Could the reason be a brand new sass or compass version? I already tried to install others... :-(.

My scss file only contains this: @import "compass";

Here comes the trace:

livingstyleguide compile styleguide.html.lsg
LivingStyleGuide::VariablesImporter:2817: (ie: "9", opera: "9.5-9.6") isn't a valid CSS value. (Sass::SyntaxError)
    from styleguide.html.lsg:1
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/script/value/map.rb:52:in `to_s'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/script/tree/string_interpolation.rb:84:in `_perform'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/script/tree/node.rb:50:in `perform'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:366:in `visit_prop'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `block in with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `block (2 levels) in visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `map'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `block in visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:173:in `with_environment'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:387:in `visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `block in with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `block (2 levels) in visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `map'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:389:in `block in visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:173:in `with_environment'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:387:in `visit_rule'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `block in with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `map'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:161:in `block in visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:173:in `with_environment'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:160:in `visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:271:in `visit_if'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `block in with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:297:in `block (2 levels) in visit_import'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:297:in `map'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:297:in `block in visit_import'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:88:in `block in with_import'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:88:in `with_import'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:294:in `visit_import'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `block in with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:121:in `with_frame'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/stack.rb:79:in `with_base'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:152:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `map'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:52:in `visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:161:in `block in visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:173:in `with_environment'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:160:in `visit_children'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `block in visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:180:in `visit_root'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/base.rb:36:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:151:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/visitors/perform.rb:8:in `visit'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/root_node.rb:36:in `css_tree'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/tree/root_node.rb:20:in `render'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/sass-3.3.3/lib/sass/engine.rb:274:in `render'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/engine.rb:32:in `css'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/engine.rb:67:in `css'
    from (erb):14:in `get_binding'
    from /Users/ffull/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/erb.rb:849:in `eval'
    from /Users/ffull/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/erb.rb:849:in `result'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/engine.rb:28:in `render'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/tilt_template.rb:93:in `render_living_style_guide'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/tilt_template.rb:18:in `evaluate'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/tilt-2.0.0/lib/tilt/template.rb:97:in `render'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/lib/livingstyleguide/command_line_interface.rb:12:in `compile'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/gems/livingstyleguide-1.0.2/bin/livingstyleguide:6:in `<top (required)>'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/bin/livingstyleguide:23:in `load'
    from /Users/ffull/.rvm/gems/ruby-2.0.0-p451/bin/livingstyleguide:23:in `<main>'

Thanks for your help! :-)

Configuration file

Prefer JSON over YAML as it’s more common for non-Ruby frontend developers.

  • livingstyleguide.json in root directory
  • Move Middleman’s config.rb into the gem and remove it from the project
  • Most properties could be top level or scoped within development or production (build?)
  • Add properties for minify_css, minify_javascript, cache_buster, relative_assets, asset_hash, smusher, fonts_path, fonts_dir, images_path, images_dir

Base command line interface

Create an command line interface which looks close to Rails/Middleman/Compass.

Actions

  • livingstyleguide server starts the development server on port 4567
  • livingstyleguide server -p 3001 starts the development server on port 3001
  • livingstyleguide s alias for livingstyleguide server
  • livingstyleguide build builds the static version
  • livingstyleguide b alias for livingstyleguide build
  • livingstyleguide compile alias for livingstyleguide build
  • livingstyleguide help shows an overview of all available commands
  • livingstyleguide -h alias for livingstyleguide help
  • livingstyleguide --help alias for livingstyleguide help
  • livingstyleguide alias for livingstyleguide help

Those basically wrap the Middleman CLI. Other actions that need further implementation will get their own issue.

Discussion:

  • build (Middleman) vs. compile (Compass)

Inline CSS for examples

``` example
@scss {
  .my-class {
    color: red;
  }
}
<div class="my-class"></div>
```

Output including ID scoping:

<div class="livingstyleguide--example" id="example-1">
  <div class="my-class"></div>
</div>
<style>#example-1 .my-class { color: red }</style>
<pre class="livingstyleguide--code-block">
 <code class="livingstyleguide--code">
   <div class="my-class"></div>
 </code>
</pre>

Escape fonts

Quotation marks must be escaped:

```
@font-example Helvetica, "Helvetica Neue", Arial
```

Results in:

<div class="livingstyleguide--font-example" style="font: Helvetica, "Helvetica Neue", Arial">
  ABCDEFGHIJKLMNOPQRSTUVWXYZ<br>
  abcdefghijklmnopqrstuvwxyz<br>
  0123456789<br>
  !&amp;/()$=@;:,.
</div>

Allow to set min-height for examples

This is useful if the current example element uses position: absolute.

```
@min-height 100px
<div class="my-element">a block that does not provide height to its parent not</div>
```

Problem with hooks 0.3.6 gem

The hooks gem was updates some days ago. Now it breaks the living style guide. Locking the gem in the gem file (gem 'hooks', "0.3.3") solves the problem on my machine.

Compass Integration

Besides using the command line ($> livingstyleguide compile styleguide.html.lsg), it would be good to automatically compile the style guide whenever $> compass compile or $> compass watch is running.

As soon as the LivingStyleGuide is required in config.rb:

# config.rb
require 'livingstyleguide'

$> compass watch should compile all *.html.lsg or *.lsg files in Compass’ Sass source folder and output them to the defined folder.

Application stylesheet needs to specify complete file extension for `@import`

Before using livingstyleguide, I could do this in my Rails app to @import a Sass partial at app/assets/stylesheets/base/_colors.css.sass:

// application.css.sass
@import base/colors

Now I have to write the fulle file extension, otherwise I get an error File to import not found or unreadable:

// application.css.sass
@import base/colors.css.sass

Or the other solution is to rename the partial mv _colors.css.sass _colors.sass

Add example website

I know there is already an example project but an example website to see what it will generally look like in the end would be awesome. Maybe just hosting the example project on some webspace?

Thanks in advance!

Additional gems in Rails applications like Foundation should be listed in the load path

As reported in livingstyleguide/examples#2:

I have a rails 4 app using foundation 5 (gem 'foundation-rails').
The line import "foundation"
inside application.css.scss breaks the Livingstyleguide.

File to import not found or unreadable: foundation.
Load paths: LivingStyleGuide::VariablesImporter Compass::SpriteImporter
/Users/ralph/Development/livingstyleguide-example/rails-example/app/assets/stylesheets
/Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets
/Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/livingstyleguide-0.6.0.alpha.1/stylesheets
(in /Users/ralph/Development/livingstyleguide-example/rails-example/app/assets/stylesheets/styleguide.html.lsg)

Initializer template

Create a basic application by running livingstyleguide new "project-name".

Discussion

  • new (Rails) vs. init (Middleman) vs. create (Compass): As there is also init in Compass which updates existing projects I prefer new.

CoffeeScript examples

~~~
@coffee-script
alert "Hello World"
~~~

=>

<script>
alert("Hello World");
</script>
<pre class="livingstyleguide--code-block">
<code class="livingstyleguide--code">
alert "Hello World"
</code>
</pre>

Less Support?

Hi,
we do not use sass but less.
Any chance that less support will be added? Is it even possible with the current architecture?

Drop Middleman dependency

This causes many problems on non Macs because Middleman requires CoffeeScript which requires a JavaScript runtime.

  • Make sure Sass, Compass and Markdown work as expected
  • Create livingstyleguide-middleman gem which has the current functionality

Problem with redcarpet 3.1.0 gem

A bundle update brings in redcarpet version 3.1.0. This crashed the webserver when I call the livingstyleguide page.
Locking redcarpet to version 3.0.0 in the gem file solved the problem on my machine.

Started GET "/assets/styleguide.html" for 127.0.0.1 at 2014-02-18 10:50:12 +0100
/Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/livingstyleguide-dff7765dfbf6/lib/livingstyleguide/engine.rb:38: [BUG] Segmentation fault
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   the more detail of.

-- Control frame information -----------------------------------------------
c:0079 p:---- s:0473 e:000472 CFUNC  :render
c:0078 p:0054 s:0469 e:000468 METHOD /Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/livingstyleguide-dff7765dfbf6/lib/livingstyleguide/eng
c:0077 p:0009 s:0464 e:000463 METHOD /Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/livingstyleguide-dff7765dfbf6/lib/livingstyleguide/eng
c:0076 p:0119 s:0461 E:0023a0 EVAL   (erb):22 [FINISH]
c:0075 p:---- s:0457 e:000456 CFUNC  :eval
c:0074 p:0045 s:0450 e:000449 METHOD /Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/erb.rb:849
c:0073 p:0078 s:0446 e:000445 METHOD /Users/ralph/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/livingstyleguide-dff7765dfbf6/lib/livingstyleguide/eng
c:

.... 1000 more lines of stacktrace

Default for source

application.lsg.html should try to load application.s[ac]ss.css as default source if undefined.

Default filters

In options:

default_filters:
  - "@haml"
  - "@add-class my-class"

Create setup script

Setup via:

curl -L https://get.livingstyleguide.org | bash
  • Check if Ruby is installed
  • Check if Bundler ist installed
  • Install LivingStyleGuide gem
  • Output first steps
  • Output helpful information if one step fails
  • Set up get.livingstyleguide.org
  • Automate updates of get.livingstyleguide.org

API for different templating languages

Instead of:

~~~ example
...
~~~

~~~ haml-example
...
~~~ 

Use:

~~~ example
...
~~~

~~~ example
@haml
...
~~~

Default engine language should be an option in the settings.

JavaScript examples

~~~
@javascript
alert("Hello World");
~~~

=>

<script>
alert("Hello World");
</script>
<pre class="livingstyleguide--code-block">
<code class="livingstyleguide--code">
alert("Hello World");
</code>
</pre>

Invalidate caches

Sass and Markdown changes won’t be noticed right now, only updates in *.html.lsg.

Implement generators

Use a Rails like CLI:

  • livingstyleguide generate module "button"
  • Alias livingstyleguide g module "button"
  • Generate _source/css/modules/button.scss
  • Generate _source/css/modules/button.md
  • Add @import "modules/button"; to main SCSS file
  • Or use sass-globbing gem

For the @imports:

  • Scan all source/css/*.s?ss files; ignore filenames containing “styleguide”.
  • Ask “Add import to XYZ.scss [Jn]: _”
  • Add import one line after last import statement in file

Allow Haml in examples

Use custom example templates for this.

  • Add haml-example
  • Add haml-layout-example
  • Include *** marker syntax

Discussion

  • Separate Gem?

Custom example types

Currently example, layout-example and javascript-example are supported.

  • Move existing types from plain Ruby into ERB files in e. g. templates/example-types/layout-example.erb.
  • The ERB files should work like layout files in Rails/Middleman.
  • Look up for custom example types in source/templates/example-types/*.
  • Add helper for syntax highlighter (including *** marker syntax).

Example as default code block

Instead of

~~~ example
...
~~~

This should be enough:

~~~
...
~~~

If you really need a code block not displayed as example, use:

~~~ code
...
~~~

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.