• Stars
    star
    4,036
  • Rank 10,779 (Top 0.3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 13 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A methodology for documenting CSS and generating styleguides.

Knyle Style Sheets

Inspired by TomDoc, KSS attempts to provide a methodology for writing maintainable, documented CSS within a team. Specifically, KSS is a documentation specification and styleguide format. It is not a preprocessor, CSS framework, naming convention, or specificity guideline.

KSS in a nutshell

The methodology and ideas behind Knyle Style Sheets are contained in SPEC.md. At its core, KSS is a documenting syntax for CSS.

/*
A button suitable for giving stars to someone.

:hover             - Subtle hover highlight.
.stars-given       - A highlight indicating you've already given a star.
.stars-given:hover - Subtle hover highlight on top of stars-given styling.
.disabled          - Dims the button to indicate it cannot be used.

Styleguide 2.1.3.
*/
a.button.star{
  ...
}
a.button.star.stars-given{
  ...
}
a.button.star.disabled{
  ...
}

KSS can also support words as Styleguide section names

// Styleguide Forms.Checkboxes.
// - or -
// Styleguide Forms - Special Checkboxes.

Ruby Library Build Status Code Climate

This repository includes a ruby library suitable for parsing SASS, SCSS, and CSS documented with KSS guidelines. To use the library, include it in your project as a gem from https://rubygems.org/gems/kss. Then, create a parser and explore your KSS.

styleguide = Kss::Parser.new("#{RACK_ROOT}public/stylesheets")

styleguide.section('2.1.1')
# => <Kss::Section>

styleguide.section('2.1.1').description
# => "A button suitable for giving stars to someone."

styleguide.section('2.1.1').modifiers.first
# => <Kss::Modifier>

styleguide.section('2.1.1').modifiers.first.name
# => ':hover'

styleguide.section('2.1.1').modifiers.first.class_name
# => 'pseudo-class-hover'

styleguide.section('2.1.1').modifiers.first.description
# => 'Subtle hover highlight'

You can also initialize the Kss::Parser with a string CSS by using Kss::Parser.new(string)

buttons =<<-'EOS'
  /*
  Your standard form button.

  :hover    - Highlights when hovering.
  :disabled - Dims the button when disabled.

  Styleguide 1.1
  */
  button {
    padding: 5px 15px;
    line-height: normal;
    /* ... */
  }
  button:disabled {
    opacity: 0.5;
  }
EOS
styleguide = Kss::Parser.new(buttons)

styleguide.section('1.1')
# => <Kss::Section>

styleguide.section('1.1').description
# => "Your standard form button."

# ...

The library is also fully TomDoc'd, completing the circle of life.

Generating styleguides

The documenting syntax and ruby library are intended to generate styleguides automatically. To do this, you'll need to leverage a small javascript library that generates class styles for pseudo-class styles (:hover, :disabled, etc).

For an example of how to generate a styleguide, check out the example sinatra application.

Development

To hack on KSS, you'll need to install dependencies with bundle install. Run tests with rake.

To make your life easier, I suggest bundle install --binstubs and adding bin/ to your $PATH. If you don't understand this, just blindly add bundle exec in front of everything you'd normally do, like bundle exec rake.

I apologize on behalf of the Ruby community for this, it's embarrassing and disappointing that dependency management is still so clumsy.

Implementations

The KSS specification has also been implemented in Python, Node.js, PHP and [Java] (https://github.com/revbingo/kss-java)

More Repositories

1

github_textmate_preview

Preview styles for TextMate, GitHub flavored
97
star
2

hemingway

Hemingway is a template for Wordpress
PHP
92
star
3

kneath.github.com

Maybe Warpspire.com or something
JavaScript
85
star
4

textmate-snippets

A collection of snippets I find useful
63
star
5

select-autocompleter

MooTools & Prototype plugin to create editable select tags
JavaScript
43
star
6

watchtower

An example app built with Sinatra, Mustache and MongoDB
Ruby
40
star
7

apprentice

A little Mac app to keep track of how much you write
31
star
8

html-base

A simple base for HTML, CSS & Javascript
JavaScript
28
star
9

knyle-says

Simon Says for the Novation Launchpad
Ruby
21
star
10

lighthouse_burndown

Create burndown charts of your Lighthouse milestones
JavaScript
15
star
11

greed

DEAR GOD DON'T USE THIS. MERB IS DEAD. IF YOU VALUE YOUR LIFE OR YOUR CHILDREN'S LIFE DON'T ATTEMPT TO MAKE THIS WORK. A simple application written in merb to help you manage ad serving across multiple sites
Ruby
14
star
12

timeframe-mootools

Click-draggable. Range-makeable. A better calendar. In MooTools.
JavaScript
13
star
13

notebook

These are my drafts. Works in progress and abandoned ideas.
11
star
14

commits

Example of the great… variety… of commit messages on this planet
7
star
15

learning-webviews

Just so I can share some code w/ people for troubleshooting
Objective-C
3
star
16

galaxy-map

Experiments in react + atom-shell
JavaScript
3
star
17

foli

This is foli's quest. An experiment in enchant.js
JavaScript
2
star
18

sketches

A home for various code sketches, nothing serious
Processing
2
star
19

nightfire

My first web app β€” circa 2001
ASP
2
star