├── .gitignore
├── .jshintrc
├── Gruntfile.js
├── LICENSE
├── README.md
├── package.json
├── tasks
└── pure_grids.js
└── test
├── expected
├── custom_mqs.css
└── custom_units.css
└── pure_grids_test.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | tmp
4 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "curly": true,
3 | "eqeqeq": true,
4 | "immed": true,
5 | "latedef": false,
6 | "newcap": true,
7 | "noarg": true,
8 | "sub": true,
9 | "undef": true,
10 | "boss": true,
11 | "eqnull": true,
12 | "node": true
13 | }
14 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-pure-grids
3 | * https://github.com/yahoo/grunt-pure-grids
4 | *
5 | * Copyright 2013 Yahoo! Inc.
6 | * Licensed under the Yahoo! Inc. BSD license.
7 | */
8 |
9 | 'use strict';
10 |
11 | module.exports = function (grunt) {
12 | // load all npm grunt tasks
13 | require('load-grunt-tasks')(grunt);
14 |
15 | // Project configuration.
16 | grunt.initConfig({
17 | jshint: {
18 | all: [
19 | 'Gruntfile.js',
20 | 'tasks/*.js',
21 | '<%= nodeunit.tests %>'
22 | ],
23 | options: {
24 | jshintrc: '.jshintrc',
25 | reporter: require('jshint-stylish')
26 | }
27 | },
28 |
29 | // Before generating any new files, remove any previously-created files.
30 | clean: {
31 | tests: ['tmp']
32 | },
33 |
34 | // Configuration to be run (and then tested).
35 | pure_grids: {
36 | custom_units: {
37 | dest: 'tmp/custom_units.css',
38 | options: {
39 | units: 12
40 | }
41 | },
42 |
43 | custom_mqs: {
44 | dest: 'tmp/custom_mqs.css',
45 | options: {
46 | units: 12,
47 | mediaQueries: {
48 | sm : 'screen and (min-width: 35.5em)', // 568px
49 | med: 'screen and (min-width: 48em)', // 768px
50 | lrg: 'screen and (min-width: 58em)', // 928px
51 | xl : 'screen and (min-width: 75em)' // 1200px
52 | }
53 | }
54 | }
55 | },
56 |
57 | // Unit tests.
58 | nodeunit: {
59 | tests: ['test/*_test.js']
60 | }
61 |
62 | });
63 |
64 | // Actually load this plugin's task(s).
65 | grunt.loadTasks('tasks');
66 |
67 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this
68 | // plugin's task(s), then test the result.
69 | grunt.registerTask('test', ['clean', 'pure_grids', 'nodeunit']);
70 |
71 | // By default, lint and run all tests.
72 | grunt.registerTask('default', ['jshint', 'test']);
73 |
74 | };
75 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2014 Yahoo! Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 |
14 | * Neither the name of the Yahoo! Inc. nor the
15 | names of its contributors may be used to endorse or promote products
16 | derived from this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # grunt-pure-grids
2 |
3 | > Generate custom grid units for [Pure Grids](http://purecss.io/grids).
4 |
5 | ## Getting Started
6 | This plugin requires Grunt.
7 |
8 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
9 |
10 | ```shell
11 | npm install grunt-pure-grids --save-dev
12 | ```
13 |
14 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
15 |
16 | ```js
17 | grunt.loadNpmTasks('grunt-pure-grids');
18 | ```
19 |
20 | ## The "pure_grids" task
21 |
22 | ### Overview
23 | In your project's Gruntfile, add a section named `pure_grids` to the data object passed into `grunt.initConfig()`.
24 |
25 | ```js
26 | grunt.initConfig({
27 | pure_grids: {
28 | responsive: {
29 | dest: 'path/to/my-responsive-grid.css',
30 | options: {
31 | units: 12, // 12-column grid
32 | mediaQueries: {
33 | sm: 'screen and (min-width: 35.5em)', // 568px
34 | md: 'screen and (min-width: 48em)', // 768px
35 | lg: 'screen and (min-width: 64em)', // 1024px
36 | xl: 'screen and (min-width: 80em)' // 1280px
37 | }
38 | }
39 | }
40 | }
41 | });
42 | ```
43 |
44 | ### Options
45 |
46 | #### options.units
47 | Type: `Integer` || `Array`
48 | Default value: `undefined`
49 |
50 | Determines how many columns your grid should have. If `undefined`, it only generates the media queries for a 5ths and 24ths-column grid (same as Pure's Default Grid).
51 |
52 | #### options.mediaQueries
53 | Type: `Object`
54 | Default value: `undefined`
55 |
56 | Used to generate responsive grids. Pass an object where the `key` denotes the grid key, and the `property` denotes the media query breakpoint (e.g., `{ FOO: 'screen and (min-width: 48em)' }` would generate `.pure-u-FOO-*` class names that become active when the viewport is `>= 48em`).
57 |
58 | #### options.includeOldIEWidths
59 | Type: `Boolean`
60 | Default value: `true`
61 |
62 | Determines whether or not each grid unit should have an accompanying `*width` value, to make it work properly in IE 6/7.
63 |
64 | #### options.includeReducedFractions
65 | Type: `Boolean`
66 | Default value: `true`
67 |
68 | Determines whether or not the output should only include the reduced fractions. Setting this to `true` means that all grid classnames would be provided in their regular **and** reduced fractional form reduced form (ex: `.pure-u-md-2-4` and `.pure-u-md-1-2` will be outputted). Setting this to `false` will only output class names in their regular form where the denominator is always equal to the value provided at `options.units`.
69 |
70 | #### options.decimals
71 | Type: `Integer`
72 | Default value: `4`
73 |
74 | Determines the width accuracy when constructing the individual grid units. You shouldn't need more than 4 decimals, but you may want fewer.
75 |
76 | #### options.selectorPrefix
77 | Type: `String`
78 | Default value: `.pure-u-`
79 |
80 | Determines the prefix for each grid class name.
81 |
82 |
83 |
84 | ### Usage Examples
85 |
86 | #### No Media Queries
87 | In this example, we just create a regular 12-column Pure grid.
88 |
89 | ```js
90 | grunt.initConfig({
91 | pure_grids: {
92 | twelveCols: {
93 | dest: 'path/to/my-grid.css',
94 | options: {
95 | units: 12, //12-column grid
96 | }
97 | }
98 | }
99 | });
100 | ```
101 |
102 | #### Responsive Grid
103 | In this example, we create a 6-column responsive grid with breakpoints at `48em` and `60em`. We also customize the prefix to just be `.col-`.
104 |
105 | ```js
106 | grunt.initConfig({
107 | pure_grids: {
108 | responsive: {
109 | dest: 'path/to/my-responsive-grid.css',
110 | options: {
111 | units: 6, // 6-column grid,
112 | mediaQueries: {
113 | md: 'screen and (min-width: 48em)', //768px
114 | lg: 'screen and (min-width: 60em)' //960px
115 | },
116 | selectorPrefix: '.col-'
117 | }
118 | }
119 | }
120 | });
121 | ```
122 |
123 | In my HTML, I can now write something like this:
124 |
125 | ```html
126 |
127 |
128 |
129 | ..
130 |
131 |