Debian Codegraph @

debian/missing-sources/bourbon-neat/README.md

raw
1 [![Neat](http://images.thoughtbot.com/bourbon/neat-logo.svg)](http://neat.bourbon.io)
2
3 ## A lightweight, semantic grid framework
4
5 **Note: This branch is an archive of Neat v1. The current release is v2 on
6 `master`.**
7
8 Neat is a fluid grid framework with the aim of being easy enough to use out of the box and flexible enough to customize down the road.
9
10 - **[Demo](http://neat.bourbon.io)**
11 - **[Documentation](http://thoughtbot.github.io/neat-docs/latest)**
12 - **[Changelog](https://github.com/thoughtbot/neat/releases)**
13 - **[Issues & Bugs](https://github.com/thoughtbot/neat/issues)**
14
15 Follow the [@bourbonsass](https://twitter.com/bourbonsass) Twitter account
16 for updates.
17
18 ## Requirements
19
20 - [Sass](https://github.com/sass/sass) 3.3+
21 - :warning: If you need **Sass 3.2 support**, you should [use Neat 1.5.1](#installing-older-versions-of-neat)
22
23 ## Installation
24
25 For command line help, visit our wiki page on Neat’s [command line interface](https://github.com/thoughtbot/neat/wiki/Command-Line-Interface).
26
27 1. Install the Neat gem using the [RubyGems](https://rubygems.org) package manager:
28
29 ```bash
30 gem install neat
31 ```
32
33 Alternatively, you can install Neat with [Bower](http://bower.io).
34
35 2. Install or update Neat’s dependencies:
36
37 ```bash
38 gem install sass # or gem update sass
39 ```
40
41 3. Install the Neat library into the current directory:
42
43 ```bash
44 neat install
45 ```
46
47 4. Import Neat in your stylesheet:
48
49 ```scss
50 @import "neat/neat";
51 ```
52
53 It’s not recommended to add or modify the Neat files so that you can update them easily.
54
55 ## Installation for Ruby on Rails
56
57 1. Add Neat to your Gemfile:
58
59 ```ruby
60 gem 'neat'
61 ```
62
63 2. Then run:
64
65 ```bash
66 bundle install
67 ```
68
69 If you see the error `Bundler could not find compatible versions for gem "sass"`, run:
70
71 ```bash
72 bundle update sass
73 ```
74
75 3. Import Neat in your `application.scss`:
76
77 ```scss
78 @import "neat";
79 ```
80
81 It should be noted that `@import` rules are not compatible with Sprockets directives. You need to use one or the other.
82
83 ## Installing with npm and using a Node-based asset pipeline
84
85 1. Add Neat as a dependency:
86
87 ```bash
88 npm install --save bourbon-neat
89 ```
90
91 1. If you’re using [Eyeglass](http://eyeglass.rocks), skip to Step 3. Otherwise, you’ll need to add Neat to your node-sass `includePaths` option. `require("bourbon-neat").includePaths` is an array of directories that you should pass to node-sass. How you do this depends on how node-sass is integrated into your project.
92
93 1. Import Neat into your Sass files:
94
95 ```scss
96 @import "neat";
97 ```
98
99 ## Installing older versions of Neat
100
101 1. Uninstall any Neat gem versions you already have:
102
103 ```bash
104 gem uninstall neat
105 ```
106
107 2. Reinstall the Neat gem, using the `-v` flag to specify the version you need:
108
109 ```bash
110 gem install neat -v 1.7.0
111 ```
112
113 3. Follow the [instructions above](#installation) to install Neat into your project.
114
115 ## Using Neat
116
117 First off, if you are planning to override the default grid settings (12 columns), it is recommended to create a `_grid-settings.scss` file for that purpose. Make sure to import it right *before* importing Neat:
118
119 ```scss
120 @import "grid-settings";
121 @import "neat/neat"; // or "neat" when in Rails
122 ```
123
124 In your newly created `_grid-settings.scss`, import `neat-helpers` if you are planning to use `new-breakpoint()`, then define your new variables:
125
126 ```scss
127 @import "neat/neat-helpers"; // or "neat-helpers" when in Rails
128
129 // Change the grid settings
130 $column: 90px;
131 $gutter: 30px;
132 $grid-columns: 10;
133 $max-width: 1200px;
134
135 // Define your breakpoints
136 $tablet: new-breakpoint(max-width 768px 8);
137 $mobile: new-breakpoint(max-width 480px 4);
138 ```
139
140 See the [docs](http://thoughtbot.github.io/neat-docs/latest/#variable) for a full list of settings.
141
142 Next, include the `outer-container` mixin in the topmost container (to which the `max-width` setting will be applied):
143
144 ```scss
145 div.container {
146 @include outer-container;
147 }
148 ```
149
150 Then use `span-columns` on any element to specify the number of columns it should span:
151
152 ```scss
153 div.element {
154 @include span-columns(6);
155 }
156 ```
157
158 If the element’s parent isn’t the top-most container, you need to add the number of columns of the parent element to keep the right proportions:
159
160 ```scss
161 div.container {
162 @include outer-container;
163
164 div.parent-element {
165 @include span-columns(8);
166
167 div.element {
168 @include span-columns(6 of 8);
169 }
170 }
171 }
172 ```
173
174 To make your layout responsive, use the `media()` mixin to modify both the grid and the layout:
175
176 ```scss
177 .my-class {
178 @include media($mobile) { // As defined in _grid-settings.scss
179 @include span-columns(2);
180 }
181 }
182
183 // Compiled CSS
184 @media screen and (max-width: 480px) {
185 .my-class {
186 display: block;
187 float: left;
188 margin-right: 7.42297%;
189 width: 46.28851%; // 2 columns of the total 4 in this media context
190 }
191 .my-class:last-child {
192 margin-right: 0;
193 }
194 }
195 ```
196
197 By setting `$visual-grid` to `true` in a file that is imported before
198 `neat-helpers` (or prior to `neat` itself if you are using the default
199 breakpoints), you can display the base grid in the background (default) or as an
200 overlay. You can even change the color and opacity of the grid-lines by
201 overriding the default settings as detailed in the section below.
202
203 The visual grid reflects the changes applied to the grid via the `new-breakpoint()` mixin, as long as the media contexts are defined *before* importing Neat.
204
205 ## FAQ
206
207 #### How do I use `omega()` in a mobile-first workflow?
208
209 Using `omega()` with an `nth-child` pseudo selector in a mobile-first workflow will cause the style to be applied to wider-viewport media queries as well. That is the cascading nature of CSS.
210
211 One solution would be to provide an `omega-reset()` mixin that negates the effect of `omega()` on that specific `nth-child` pseudo selector. While this is often the most suggested solution, it is also a lazy hack that outputs ugly code and can quickly get out of hand in complex layouts. As a general rule, having to *undo* CSS styles is a sign of poor stylesheet architecture (more about [CSS code smells](http://csswizardry.com/2012/11/code-smells-in-css/)).
212
213 The other, more elegant, solution is to use mutually exclusive media queries, also referred to as [media-query
214 splitting](http://simurai.com/blog/2012/08/29/media-query-splitting). This would guarantee that `omega()` styles are only applied where desired.
215
216 ```scss
217 $first-breakpoint-value: 400px;
218 $second-breakpoint-value: 700px;
219 $medium-viewport: new-breakpoint(min-width $first-breakpoint-value max-width $second-breakpoint-value);
220 $large-viewport: new-breakpoint(min-width $second-breakpoint-value + 1);
221
222 .element {
223 @include media($medium-viewport) {
224 @include span-columns(6);
225 @include omega(2n);
226 }
227
228 @include media($large-viewport) {
229 @include span-columns(4);
230 @include omega(3n);
231 }
232 }
233 ```
234
235 If, for some reason, you still think that `omega-reset` is the only way you want to go, check out Josh Fry’s [omega-reset](http://joshfry.me/blog/2013/05/13/omega-reset-for-bourbon-neat).
236
237 #### Why are the elements not properly aligned with the visual grid?
238
239 The visual grid is built using CSS gradients whose stops might contain decimal values depending on the default settings of your grid. In order to render the gradient, browsers round the pixel values since they can’t deal with pixel fractions.
240
241 As a result the visual grid might be few pixels off in some browsers. The result is also inconsistent across browsers. For best results, preview your website on Firefox as it renders closest to the expected outcome.
242
243 At this point, writing an internal rounding mechanism is not high priority.
244
245 #### Framework X has this feature that Neat seems to be missing. Can you add it?
246
247 Unless you [open a pull request](https://github.com/thoughtbot/neat/compare/), the answer is most likely going to be no. Neat is lightweight and simple compared to other grid frameworks, and strives to remain so. We have plans for adding new features in future versions of the framework, but these will be most likely to support new ways of working with layouts on the Web, not patches to existing ones.
248
249 ## Browser support
250
251 - Chrome 10+
252 - Firefox 29+
253 - Internet Explorer 9+ (visual grid is IE 10 only)
254 - Internet Explorer 8 with [selectivizr](http://selectivizr.com) (no `media()` support)
255 - Opera 9.5+
256 - Safari 5.1+
257
258 ## The Bourbon family
259
260 - [Bourbon](https://github.com/thoughtbot/bourbon): A simple and lightweight mixin library for Sass
261 - [Neat](https://github.com/thoughtbot/neat): A lightweight semantic grid framework for Sass and Bourbon
262 - [Bitters](https://github.com/thoughtbot/bitters): Scaffold styles, variables and structure for Bourbon projects
263 - [Refills](https://github.com/thoughtbot/refills): Prepackaged patterns and components built with Bourbon, Neat and Bitters
264
265 ## License
266
267 Copyright © 2012–2015 [thoughtbot, inc](http://thoughtbot.com). Neat is free software, and may be redistributed under the terms specified in the [license](LICENSE.md).
268
269 ## About thoughtbot
270
271 [<img src="http://presskit.thoughtbot.com/images/signature.svg" width="250" alt="thoughtbot logo">][hire]
272
273 Neat is maintained and funded by thoughtbot, inc.
274 The names and logos for thoughtbot are trademarks of thoughtbot, inc.
275
276 We love open source software!
277 See [our other projects][community]
278 or [hire us][hire] to design, develop, and grow your product.
279
280 [community]: https://thoughtbot.com/community?utm_source=github
281 [hire]: https://thoughtbot.com/hire-us?utm_source=github