UNPKG

5.37 kBMarkdownView Raw
1<p align="center">
2 <img src="http://simplaio.github.io/rucksack/logo.png" alt="rucksack logo" height="325" />
3</p>
4
5<p align="center">
6 <a href="https://npmjs.org/package/rucksack-css"><img src="https://badge.fury.io/js/rucksack-css.svg" alt="NPM version" /></a>
7 <a href="https://travis-ci.org/simplaio/rucksack"><img src="https://travis-ci.org/simplaio/rucksack.svg?branch=master" alt="Build satus" /></a>
8 <a href="https://david-dm.org/simplaio/rucksack"><img src="https://david-dm.org/simplaio/rucksack.svg?theme=shields.io" alt="Dependency Status" /></a>
9</p>
10
11<br/>
12
13A little bag of CSS superpowers, built on [PostCSS][postcss].
14
15Rucksack makes CSS development less painful, with the features and shortcuts it should have come with out of the box.
16
17Made with &#9829; by the folks at [Simpla][simpla].
18
19**Read the full docs at http://simplaio.github.io/rucksack**
20
21--
22
23### Install
24
25```sh
26$ npm install --save rucksack-css
27```
28
29<br/>
30
31### Usage
32
33###### Gulp
34Use [gulp-rucksack][gulp-rucksack]
35
36```js
37var gulp = require('gulp');
38var rucksack = require('gulp-rucksack');
39
40gulp.task('rucksack', function() {
41 return gulp.src('src/style.css')
42 .pipe(rucksack())
43 .pipe(gulp.dest('style.css'));
44});
45```
46
47###### Grunt
48Use [grunt-rucksack][grunt-rucksack]
49
50```js
51require('load-grunt-tasks')(grunt);
52
53grunt.initConfig({
54 rucksack: {
55 compile: {
56 files: {
57 'style.css': 'src/style.css'
58 }
59 }
60 }
61});
62
63grunt.registerTask('default', ['rucksack']);
64```
65
66###### Broccoli
67Use [broccoli-rucksack][broccoli-rucksack]
68
69```js
70var rucksack = require('broccoli-rucksack');
71tree = rucksack(tree, [options]);
72```
73
74###### CLI
75Process CSS directly on the command line
76
77```sh
78$ rucksack src/style.css style.css [options]
79```
80
81###### PostCSS
82Rucksack is built on PostCSS, and can be used as a PostCSS plugin.
83
84```js
85var postcss = require('postcss'),
86 rucksack = require('rucksack-css');
87
88postcss([ rucksack() ])
89 .process(css, { from: 'src/style.css', to: 'style.css' })
90 .then(function (result) {
91 fs.writeFileSync('style.css', result.css);
92 if ( result.map ) fs.writeFileSync('style.css.map', result.map);
93 });
94```
95 See the [PostCSS Docs][postcss] for examples for your environment.
96
97###### Stylus
98Rucksack can be used as a Stylus plugin with [PostStylus][poststylus]
99
100```js
101stylus(css).use(poststylus('rucksack-css'))
102```
103
104See the [PostStylus Docs][poststylus] for more examples for your environment.
105
106--
107
108### Core Features
109
110_Automagical responsive typography_
111```css
112.foo {
113 font-size: responsive;
114}
115```
116![Responsive Type Demo][type-demo]
117
118
119_Shorthand syntax for positioning properties_
120```css
121.foo {
122 position: absolute 0 20px;
123}
124```
125
126_Native clearfix_
127```css
128.foo {
129 clear: fix;
130}
131```
132
133_Input pseudo-elements_
134```css
135input[type="range"]::track {
136 height: 2px;
137}
138```
139
140_Hex shortcuts for RGBA_
141```css
142.foo {
143 color: rgba(#fff, 0.8);
144}
145```
146
147_Shorthand `@font-face` src sets (becomes [FontSpring syntax][fontspring])_
148```css
149@font-face {
150 font-family: 'My Font';
151 font-path: '/path/to/font/file';
152}
153```
154
155_Whole library of modern easing functions_
156```css
157.foo {
158 transition: all 250ms ease-out-cubic;
159}
160```
161
162_Powerful quantity pseudo-selectors_
163```css
164li:at-least(4) {
165 color: blue;
166}
167
168li:between(4,6) {
169 color: red;
170}
171```
172
173_CSS property aliases_
174```css
175@alias {
176 fs: font-size;
177 bg: background;
178}
179
180.foo {
181 fs: 16px;
182 bg: #fff;
183}
184```
185
186--
187
188### Optional Extras
189
190###### Autoprefixing
191Automatically apply vendor prefixes to relevant properties based on data from [CanIUse][caniuse] - via [autoprefixer][autoprefixer].
192
193
194###### Legacy Fallbacks
195Automatically insert legacy fallbacks for modern properties - via [laggard][laggard].
196```css
197/* before */
198.foo {
199 color: rgba(0,0,0,0.8);
200 width: 50vmin;
201}
202
203.foo::before{
204 opacity: 0.8;
205}
206
207/* after */
208.foo {
209 color: rgb(0,0,0);
210 color: rgba(0,0,0,0.8);
211 width: 50vm;
212 width: 50vmin;
213}
214
215.foo:before{
216 opacity: 0.8;
217 -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
218}
219```
220
221--
222
223**Read the full docs at http://simplaio.github.io/rucksack**
224
225--
226
227### Options
228All features in Rucksack can be toggled on or off by passing options on initialization. By default all core features are set to `true`, and optional
229addons are set to `false`.
230
231Core features (default to `true`):
232- `responsiveType`
233- `shorthandPosition`
234- `quantityQueries`
235- `alias`
236- `inputPseudo`
237- `clearFix`
238- `fontPath`
239- `hexRGBA`
240- `easings`
241
242Addons (default to `false`):
243- `fallbacks`
244- `autoprefixer`
245
246###### Error reporting
247Enable reporting, which outputs helpful error and warning messages from the plugins used inside Rucksack to your console, with the `reporter` option. Defaults to `false`.
248
249```js
250// Set in build tool, etc.
251.rucksack({
252 // options
253})
254```
255--
256
257### License
258
259MIT © [Simpla][simpla]
260
261[simpla]: http://simpla.io
262[postcss]: https://github.com/postcss/postcss
263[gulp-rucksack]: https://github.com/simplaio/gulp-rucksack
264[grunt-rucksack]: https://github.com/simplaio/grunt-rucksack
265[broccoli-rucksack]: https://github.com/simplaio/broccoli-rucksack
266[poststylus]: https://github.com/seaneking/poststylus
267[type-demo]: http://simplaio.github.io/rucksack/img/type-demo.gif
268[fontspring]: http://blog.fontspring.com/2011/02/further-hardening-of-the-bulletproof-syntax/
269[caniuse]: http://caniuse.com
270[autoprefixer]: https://github.com/postcss/autoprefixer
271[laggard]: https://github.com/seaneking/laggard