• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    CSS
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

stylus driven css library

dookie-css

NPM version

CSS library built on top of the Stylus preprocessor. It provides a couple of useful stylus mixins, utilities and components.

How to install

At first install package into your project:

npm install dookie-css

Express.js (Connect)

For express or connect framework you can simply include dookie middleware method into Stylus' compiler:

var	stylus = require('stylus'),
	dookie = require('dookie-css');

...

app.configure(function(){
	...
	app.use(stylus.middleware({ src: __dirname + '/public', compile: dookie.middleware }));
})

More about Stylus middleware here.

###Other environments

As for pure node.js or some other cases dookie has method called css. Here is an example of simple static server.js using Stylus + dookie:

var stylus = require('stylus'),
    dookie = require('dookie-css');

...

// use stylus for styling
stylus(str)
	.use(dookie.css()) // call dookie.css() function
	.render(function (err, css) {
		if (err) {
			throw err;
		}
		// do smth with 'css'
	});

Check out ./examples folder to see how dookie can be introduced with pure node.js static server or express framework.

So now all dookie utilities can be called within your .styl files and it's time to check lib's documentation.

##Stylus cli plugin

If you prefer use Stylus cli executable for converting Stylus to CSS, you can also use dookie with it. In --use option specify path to dookie.js file, for example:

stylus --use ./node_modules/dookie-css/dookie.js --out ./

Further reading about Stylus cli here.

##Documentation

###Settings

Dookie contains default configuration settings.styl. So this depends on your needs, but it's recommended to create your own _settings.styl (could be named whatever you like) and specify or overwrite existed variables.

######Examples:

Here is custom _settings.styl file which specifies vendors that are needed, and path to the folder with images:

img-path = '../images/'
vendors = webkit moz

Now in your main Stylus file we add @import configuration and start to use dookie easily:

@import '_settings'

...

######List of global settings:

  • img-path - path to the app folder with images (empty by default);

  • vendors - list of vendors you want to use (by default includes webkit, moz, ms, o and official which means unprefixed property);

  • ie-support - set to true to enable special IE properties like filter: alpha(opacity = 100) etc.

  • font-stack - global font-family stack;

  • sans-serif- serif and monospace - default font-families;

  • font-size - global font-size variable;

  • default-color - global font color fallback;

Settings file is also a good place to put your own configuration on the project.

###Reset mixins

These helpers are global (this also means you should use them in mixin form - mixin(args) instead of mixin: args):

reset() - simple base and recommended reset;

normalize() - popular normalize.css reset;

fields-reset() - reset input fields from sometimes annoying browser based styles (on ::required, ::valid, ::invalid, etc. pseudo-classes);

###Common useful helpers

Shorter replacements for display: block | inline-block | none respectively:

block(), inline-block(), hide();

Frequently used text transformation and decoration properties shorthands:

reset-case(), upcase(), lowcase(), nodecorate(), underline(), etc.

Font styles:

bold(), italic(), normal()

#####fs: [your font-size]

font-size shortener;

#####fw: [your font-weight]

font-weight shortener;

######Examples:

h2
	fs: 2em
	fw: 500
	italic()

.link
	block()
	nodecorate()

/* yields => */
h2 {
	font-size: 2em;
	font-weight: 500;
	font-style: italic;
}

.link {
	display: block;
	text-decoration: none;
}

#####clearfix()

basic clearfix, simply add it to your class name or call global mixin base-classes() within your project to have it in .clearfix class;

#####size: [width, height]

cool and useful dimensions shortener, example:

.box
	size: 30px

.longbox
	size: 100px 20px

/* yields => */
.box {
	width: 30px;
	height: 30px;
}

.longbox {
	width: 100px;
	height: 20px;
}

#####bg: [path], [args optional]

background mixin shortener, example:

.logo
	bg: 'logo.png'

.cat
	bg: 'cat.jpg' 100px 80px no-repeat #DDD

/* yields => */
.logo {
	background: url("../images/logo.jpg") no-repeat;
}

.cat {
	background: url("../images/cat.jpg") 100px 80px no-repeat #DDD;
}

#####bg-retina:[path], [args optional]

very similar mixin but adds background-size: contain property for retina displays (use it together with @media all and (-webkit-min-device-pixel-ratio: 1.5));

Note: if you specify images folder in your settings img-path variable it allows you to put only picture file name in all dookie mixins;

#####image-block: [path], [dimensions optional]

mixin that replaces block with image specified in it.

Note: .png images could skip dimensions, because of Stylus native image-size() built-in function, example:

.replacer
	image-block: 'default.png'

/* yields => */
.replacer {
	background: url("../images/default.png") no-repeat;
	font: 0/0 a;
	text-shadow: none;
	color: transparent;
	width: 300px;
	height: 200px;
}

#####text-overflow: [width], [type optional]

useful when long text line need to be overflowed, default type is ellipsis, example:

.description
	text-overflow: 300px

/* yields => */
.description {
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
	width: 300px;
}

#####text-hide()

hiding text mixin;

#####no-select()

disallow user to select element;

#####round()

makes element rounded corners, useful for large ones;

#####opacity: [opacity]

same as native css property but if your settings set ie-support to true mixin adds old-school IE filter property by itself;

#####triangle: [up|down|left|right], [size|default: 10px], [color|default: #000]

cool pure css triangle mixin, example:

.triangle
	triangle: down 15px #F80

/* yields => */
.triangle {
	width: 0;
	height: 0;
	border-left: 15px solid transparent;
	border-right: 15px solid transparent;
	border-top: 15px solid #F80;
}

###Positioning

Dookie allows you to shorten css element positioning while using simply one line property.

#####absolute: [name value], ...

#####relative: [name value], ...

#####fixed: [name value], ...

#####static: [name value], ...

######Example:

.box
	absolute: top 10px left 15px

/* yields => */
.box {
	position: absolute;
	top: 10px;
	right: 15px;
}

###Sprites

Dookie has several helpers to simplify your work with sprites.

#####sprite-grid: [path], [x], [y], [grid]

basic grid helper, [path] to your sprite picture, [x], [y] - square counts where icon is placed and [grid] param is your grid step (also can be as 2 params - gridX and gridY), example:

.sprite-pic
	sprite-grid: 'sprite.png' 1 1 32px


/* yields => */
.sprite-pic {
	background: url("../images/sprite.png") no-repeat;
	background-position: -64px -32px;
}

#####sprite-replace: [path], [x], [y], [grid]

same as previous one but also replaces text within an element with icon from the sprite;

Note: nice article describing these techniques by Niels Matthijs;

###Vendor prefixes

Dookie intelligently simplifies usage of css properties that mostly need to be prefixed. Only thing that you should do is to setup in your _settings.styl which prefixes you want to use (by default all of them are included). List of property mixins:

#####box-shadow: [args...]

#####border-radius: [args...]

#####box-sizing: [args...]

#####animation: [args...]

#####transition: [args...]

#####transformation: [args...]

#####perspective: [args...]

#####backface-visibility: [args...]

#####filters: [args...]

Note: Properties like animation, transition, transform and perspective also include all separate dependent props like animation-name, transition-delay, perspective-origin etc.

#####-prefix: [property], [args...]

It is also good to know that if you need some property to be prefixed, you can use dookie's -prefix method while passing into it property name and value, example:

.box
	-prefix(some-prop, value1 value2)

/* yields => */
.box {
	-webkit-some-prop: value1, value2;
	-moz-some-prop: value1, value2;
	-o-some-prop: value1, value2;
	-ms-some-prop: value1, value2;
	some-prop: value1, value2;
}

###Easings

Custom timing functions useful for ui-transitions, see all of them in action here:

#####ease-in- quad, cubic, quart, quint, sine, expo, circ, back

#####ease-out- quad, cubic, quart, quint, sine, expo, circ, back

#####ease-in-out- quad, cubic, quart, quint, sine, expo, circ, back

######Example:

.animated
	transition: all 300ms ease-in-quad

/* yields => */
.animated {
	-webkit-transition: all 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53);
	-moz-transition: all 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53);
	-o-transition: all 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53);
	-ms-transition: all 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53);
	transition: all 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

###Gradients

#####linear-gradient([start], [stops...])

mixin should be called within the property (background-image or background depends on what you prefer), example:

.gradient
	background-image: linear-gradient(red, orange, yellow 80%)

/* yields => */
.gradient {
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #f00), color-stop(0.33333333333333326, #ffa500), color-stop(0.8, #ff0));
	background-image: -moz-linear-gradient(top, #f00 0%, #ffa500 33.33333333333333%, #ff0 80%);
	background-image: -webkit-linear-gradient(top, #f00 0%, #ffa500 33.33333333333333%, #ff0 80%);
	background-image: -o-linear-gradient(top, #f00 0%, #ffa500 33.33333333333333%, #ff0 80%);
	background-image: -ms-linear-gradient(top, #f00 0%, #ffa500 33.33333333333333%, #ff0 80%);
	background-image: linear-gradient(top, #f00 0%, #ffa500 33.33333333333333%, #ff0 80%);
}

#####radial-gradient([stops...])

same as previous one but radial, example:

.circle
	background-image: radial-gradient(#f1c40f, #f39c12 50%)

/* yields => */
.circle {
	background-image: -webkit-gradient(radial, center center 0px, center center 100%, color-stop(0, #f1c40f), color-stop(0.5, #f39c12), );
	background-image: -moz-radial-gradient(center, ellipse cover, #f1c40f 0%, #f39c12 50%);
	background-image: -webkit-radial-gradient(center, ellipse cover, #f1c40f 0%, #f39c12 50%);
	background-image: -o-radial-gradient(center, ellipse cover, #f1c40f 0%, #f39c12 50%);
	background-image: -ms-radial-gradient(center, ellipse cover, #f1c40f 0%, #f39c12 50%);
	background-image: radial-gradient(ellipse at center, #f1c40f 0%, #f39c12 50%);
}

#####gradient: [colorStart], [colorStop]

shorthand for two colors linear-gradient, example:

.box
	gradient: #F80 #F00

/* yields => */
.box {
	background: #f00;
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #f80), color-stop(1, #f00));
	background-image: -moz-linear-gradient(top, #f80 0%, #f00 100%);
	background-image: -webkit-linear-gradient(top, #f80 0%, #f00 100%);
	background-image: -o-linear-gradient(top, #f80 0%, #f00 100%);
	background-image: -ms-linear-gradient(top, #f80 0%, #f00 100%);
	background-image: linear-gradient(top, #f80 0%, #f00 100%);
}

#####simple-gradient: [color], [strength percents|default: 10%]

generates linear-gradient from one color;

###Global mixins

As reset helpers these mixins are global and should be called not within css selector but in file root.

#####base-classes()

adds couple of useful classes that you might add anyways, full list of them:

.left, .right, .clear, .show, .hide, .bold, .italic, .bullet, .clearfix, .rounded

#####text-selection([highlight color], [text color|default: 'white'])

selection background and text color;

#####border-box()

enable border-box sizing globally;

#####font-face([name], [folder], [weight optional], [style optional])

bulletproof @font-face mixin, keep in mind that font name should be the same as font filename;

######Example:

font-face(DIN, '/fonts')

@font-face
	font-family: 'DIN';
	src: url('DIN.eot');
	src: url('DIN.eot?#iefix') format('embedded-opentype'),
		 url('DIN.woff') format('woff'),
		 url('DIN.ttf') format('truetype'),
		 url('DIN.svg#DIN') format('svg');
	font-weight: normal;
	font-style: normal;

##Test

Together with Stylus and dookie you can easily create tests for your mixins and utilities. Read more how you can test dookie itself with mocha.js and casper.js here - ./test/README.md.

##Contribute

Dookie is in beta yet, so issues or useful pull requests are highly appreciated.

##Why dookie?!

Green Day's Dookie button

Because it's awesome Green Day's album from my childhood :)


MIT Licensed (c) 2013 Dmitri Voronianski

More Repositories

1

flux-comparison

๐Ÿ“ Practical comparison of different Flux solutions
JavaScript
2,785
star
2

oceanic-next-color-scheme

๐Ÿ“ Sublime Text color scheme ready for next generation JavaScript syntax
JavaScript
1,972
star
3

jquery.avgrund.js

Avgrund is jQuery plugin with new modal concept for popups
JavaScript
1,764
star
4

react-swipe

โ†”๏ธ Swipe.js as a React component
JavaScript
1,658
star
5

ngActivityIndicator

Angular provider for preloader animations
CSS
644
star
6

esnextbin

๐Ÿฑ Prototype apps in the browser with next generation JavaScript and NPM modules
JavaScript
463
star
7

ngprogress-lite

Angular provider for slim progress bars
HTML
394
star
8

react-native-effects-view

Use iOS8 UIVisualEffectViews's blur and vibrancy with ReactNative
Objective-C
387
star
9

react-star-rating-component

Basic React component for star (or any other icon based) rating elements
JavaScript
378
star
10

realtime-geolocation-demo

Realtime geolocation with HTML5 API and Socket.io
JavaScript
337
star
11

melchior.js

Chainable Module Definition (CMD) dependency loader for JavaScript
JavaScript
305
star
12

soundcloud-audio.js

๐ŸŽต SoundCloud tracks and playlists with HTML5 Audio API
JavaScript
285
star
13

swipe-js-iso

Universal (a.k.a isomorphic) version of Swipe.js
JavaScript
187
star
14

universal-react-flux-boilerplate

React (0.13.x) + Flux (Flummox) + ReactRouter (0.13.x) + Server Rendering
JavaScript
170
star
15

simon-le-bottle

Getting started with Facebook Messaging Platform
JavaScript
111
star
16

node-tweet-cli

Start making tweets from your bash, zsh, whatever!
JavaScript
83
star
17

xml2obj-stream

XML to JavaScript object low memory streaming parser based on node-expat
JavaScript
63
star
18

griddy.css

๐Ÿ“– Responsive 12 column based grid in 311 Bytes gzipped
HTML
63
star
19

ngKookies

Powerful replacer for built-in Angular's $cookieStore (https://github.com/angular/angular.js/issues/950)
JavaScript
60
star
20

is-express-schema-valid

๐Ÿ express.js middleware that validates body, params, query of request according to JSONSchema and is extremely fast
JavaScript
59
star
21

node-object-encrypter

Encrypt/decrypt javascript objects as base64 strings with optional TTL support
JavaScript
58
star
22

express-api-sample

Sample API ready to be used in different client app boilerplates and playgrounds.
JavaScript
48
star
23

babel-transform-in-browser

Transform ES2015 in browser on the fly with Babel.js
JavaScript
45
star
24

node-tiny-dploy

Simple shell script + PM2 deployer
JavaScript
42
star
25

dumbugger

Automatically google for similar JavaScript errors when thrown.
HTML
38
star
26

node-grvtr

grvtr.js - small node.js gravatar library
JavaScript
32
star
27

node-config-boilerplate

Easy configs for node.js apps
JavaScript
28
star
28

react-pikaday-component

Universal React component wrapper around Pikaday.js datepicker
JavaScript
19
star
29

psi-local-cli

Google PageSpeed Insights CLI for localhost (via ngrok)
JavaScript
18
star
30

data-structures-and-algorithms-in-javascript

Basic data structures and algorithms implemented in JavaScript
JavaScript
16
star
31

Do-I-Know-JS

Javascript patterns uncovered with examples
JavaScript
13
star
32

setup-osx-work-station

๐ŸŽ OS X machine setup shell script
Shell
11
star
33

is-my-schema-valid

Simple function that validates data according to JSONSchema
JavaScript
9
star
34

versionify-assets

Function to get checksum of file and add to url querystring for cache busting
JavaScript
7
star
35

vapor-favicon-middleware

Favicon serving middleware for Vapor applications.
Swift
6
star
36

react-router-hooks-patch

Patch react-router route handler components with static hook methods onEnter/onLeave
JavaScript
6
star
37

uneasy-flux-demo

Practical flux to manage uneasy API scenarios like handling errors or pending requests
JavaScript
5
star
38

create-static

Create static html pages with esnext, scss and nunjucks easily.
JavaScript
5
star
39

c0nfig

Require local configs as if they are in node_modules
JavaScript
5
star
40

EightTracksSwift

8tracks radio client for iOS8 implemented in Swift
Swift
5
star
41

EightTracksReactNative

8tracks radio client for iOS powered by ReactNative
JavaScript
4
star
42

update-to-latest

Simple cli tool for easy update of npm dependencies.
JavaScript
3
star
43

waveform.js

Waveform.js makes drawing SoundCloud waveforms simple
JavaScript
3
star
44

node-shufflerfm

Shuffler.fm API client for Node.js
JavaScript
3
star
45

discogs-wantlist-cli

๐Ÿ“€ Extract releases from Discogs user wantlist without duplicates.
JavaScript
2
star
46

vapor-server-example

Examples of server-side Swift powered by Vapor.
Swift
2
star
47

go2url.xyz

๐ŸŒ Change window.location in a second
HTML
2
star
48

swapi-graphql-react-app

SPA that allows to ๐Ÿ”Ž search for all human characters in ๐ŸŒ  Star Wars saga.
JavaScript
2
star
49

react-waves

Top sounds of the web built with React components
JavaScript
2
star
50

isomorphic-flux-comparison

2
star
51

react-ace-preact-compat-issue

JavaScript
2
star
52

vapor-checksum-assets

Add checksums of .js/.css files to url querystring in Vapor applications for cache busting.
Swift
2
star
53

telepath-mini

Tiny and smart music player for OS X
CSS
2
star
54

multi-translator

Get transations from several dictionaries in one app.
JavaScript
2
star
55

melchior-landing

CSS
2
star
56

luvit-static-server-demo

Static server demo based on luvit.io
Lua
2
star
57

next-13-ninetailed-middleware-issue

TypeScript
1
star
58

soundcloud-api-proxy

๐ŸŽถ Just a simple proxy server for not letting to abuse my SoundCloud client secrets.
JavaScript
1
star
59

vue2-examples

Playing with Vue 2.0 beta
JavaScript
1
star
60

izzit-mac-client

1
star
61

nooop

Just a noop function
JavaScript
1
star
62

universal-react-router-flux-2016

Opionated example of universal app setup
JavaScript
1
star
63

fluid-layout-with-boxes

Small cross-browser hack in pure JS
JavaScript
1
star
64

latest-browsers-api

JSON API to get the latest browser versions.
JavaScript
1
star
65

monqo-query-cli

make mongo shell queries from bash
JavaScript
1
star
66

contrabass.css

CSS utility belt in 1.99 kB
CSS
1
star
67

demo-tracker-app

demo of time tracker app written in angular
JavaScript
1
star
68

hamlet-boilerplate

App template for getting started with Hamlet
JavaScript
1
star
69

angular_tuts

JavaScript
1
star
70

vapor-url-shortener

Basic url shortener API implemented in Swift and Vapor
1
star
71

hash-unhash-exercise

JavaScript
1
star
72

webpack-trouble-demo

Webpack-dev-server + Existing node.js server = Some troubles
JavaScript
1
star