breakpoint 1.1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2 - August 16th, 2012
4
+ * Added ability to force the 'all' media type to be written by setting `$breakpoint-force-media-all: true;`. Defaults to `false`.
5
+ * Added ability to generate no query fallback code. See the README for full documentaiton.
6
+
3
7
  ## 1.1.1 - July 30, 2012
4
8
  * Added (forgot to include the first time) the ability to query the media type using `breakpoint-get-context('media')`
5
9
 
data/README.markdown CHANGED
@@ -14,15 +14,30 @@ Breakpoint also allows you to get the [context of your media queries](https://gi
14
14
 
15
15
  If you'd prefer the semantic awesomeness of string names to identify your queries as opposed to variables, or want to dynamically generate media queries, check out [Respond-To](https://github.com/snugug/respond-to); a string based naming API for Breakpoint.
16
16
 
17
+ **It is important to note** that due to limitations within the Sass language itself, which themselve stem from some potentially unexpected cascading from doing so, Breakpoint is unable to concat like media queries into a single media query. This means they will be spread out throughout your CSS. This is unfortunate, yes, but currently unavoiadable. That being said, once [Sass Issue #241: Seperate Media/Browser Specific Markup to Separate Style Sheet](https://github.com/nex3/sass/issues/241) hits, be sure we're going to take full advantage of it.
18
+
19
+ ## Table of Contents
20
+
21
+ 1. [Requirements](#requirements)
22
+ 2. [Installation](#installation)
23
+ 3. [Setup](#setup)
24
+ * [Breakpoint Options](#breakpoint-options)
25
+ * [Using Breakpoint](#using-breakpoint)
26
+ 4. [Media Query Context](#media-query-context)
27
+ 5. [No Query Fallback](#no-query-fallback)
28
+ * [Wrapping Selector, Same Stylesheet](#wrapping-selector-same-stylesheet)
29
+ * [No Wrapping Selector, Separate Stylesheet](#no-wrapping-selector-separate-stylesheet)
30
+ * [Wrapping Selector, Separate Stylesheet](#wrapping-selector-separate-stylesheet)
31
+
17
32
  ## Requirements
18
33
 
19
34
  Breakpoint is a Compass extension, so make sure you have [Sass and Compass Installed](http://compass-style.org/install/) in order to use its awesomeness!
20
35
 
21
- Breakpoint also requires Sass 3.2, which is currently in pre-release. Breakpoint should install Sass 3.2 for you when you install it, but in case you are getting errors, open up your terminal and type the following in:
36
+ Breakpoint also requires Sass 3.2. Breakpoint should install Sass 3.2 for you when you install it, but in case you are getting errors, open up your terminal and type the following in:
22
37
 
23
- `gem install sass --pre`
38
+ `gem install sass`
24
39
 
25
- This will install Sass 3.2. If you are compiling with CodeKit, [Chris Coyier has an awesome writeup](http://css-tricks.com/media-queries-sass-3-2-and-codekit/) on how to get CodeKit playing nice with Sass 3.2.
40
+ This will install Sass 3.2. If you are compiling with CodeKit, [Chris Coyier has an awesome writeup](http://css-tricks.com/media-queries-sass-3-2-and-codekit/) on how to get CodeKit playing nice with Sass 3.2, at least until it is updated to 3.2.
26
41
 
27
42
  ## Installation
28
43
 
@@ -297,6 +312,129 @@ Caviats with Media Query context:
297
312
  * If you have `$breakpoint-to-ems` set to true, you will get returns in base ems. You can run non-em based values through `breakpoint-to-base-em($value)` to convert them to base ems.
298
313
  * If you are testing for a prefixed feature (such as `device-pixel-ratio`), you need to test for the prefixed value (`-webkit-device-pixel-ratio`, `min--moz-device-pixel-ratio`, etc…).
299
314
 
315
+ ## No Query Fallback
316
+
317
+ Breakpoint provides a way to generate fallback CSS for if you would like the CSS to apply even if media queries aren't available. There are three methidologies we discovered cover most, if not all, of the stylistic options a user could have in a system like this: a wrapping selector within the same stylesheet, a seperate stylesheet with no wrapping selector, and a seperate stylesheet with a wrapping selector. For both of these, bare in mind that Sass cannot create separate stylesheets automatically ([yet](https://github.com/nex3/sass/issues/241)), so you're going to need to do it by hand, but the tools we've provided are very powerful, so we think you'll like.
318
+
319
+ There are now two new breakpoint flags to set that control no query support, `$breakpoint-no-queries` for specifying that only no query output should be output by Breakpoint and `$breakpoint-no-query-wrappers` for specifying that you want no query wrappers to be printed. Both of the new flags, `$breakpoint-no-queries` and `$breakpoint-no-query-wrappers` default to `false`, toggling them to `true` activates them. For the purposes of clarity in the following code samples, I'm including both flags even though the `false` flags are not explicitly needed. When passing in a wrapper, you must write the whole wrapper and may include a compound wrapper, *i.e.* `'.no-mqs'` or `'#print'` or `'.high-dpi.no-mqs'`. Variables may also be passed in, but they still require the whole wrapper.
320
+
321
+ ### Wrapping Selector, Same Stylesheet
322
+ ```scss
323
+ // style.scss
324
+ $breakpoint-no-queries: false;
325
+ $breakpoint-no-query-wrappers: true;
326
+
327
+ #foo {
328
+ background: red;
329
+ @include breakpoint(567px, $no-query: '.no-mqs') {
330
+ background: green;
331
+ }
332
+ }
333
+ ```
334
+ ```css
335
+ /* style.css */
336
+ #foo {
337
+ background: red;
338
+ }
339
+
340
+ .no-mqs #foo {
341
+ background: green;
342
+ }
343
+
344
+ @media (min-width: 567px) {
345
+ #foo {
346
+ background: green;
347
+ }
348
+ }
349
+ ```
350
+
351
+ ### No Wrapping Selector, Separate Stylesheet
352
+ ```scss
353
+ // _layout.scss
354
+ #foo {
355
+ background: red;
356
+ @include breakpoint(567px, $no-query: true) {
357
+ background: green;
358
+ }
359
+ }
360
+ ```
361
+ ```scss
362
+ // style.scss
363
+ $breakpoint-no-queries: false;
364
+ $breakpoint-no-query-wrappers: false;
365
+
366
+ @import 'layout';
367
+ ```
368
+ ```scss
369
+ // no-mq.scss
370
+ $breakpoint-no-queries: true;
371
+ $breakpoint-no-query-wrappers: false;
372
+
373
+ @import 'layout';
374
+ ```
375
+ ```css
376
+ /* style.css */
377
+ #foo {
378
+ background: red;
379
+ }
380
+
381
+ @media (min-width: 567px) {
382
+ #foo {
383
+ background: green;
384
+ }
385
+ }
386
+ ```
387
+ ```css
388
+ /* no-mq.css */
389
+ #foo {
390
+ background: red;
391
+ background: green;
392
+ }
393
+ ```
394
+
395
+ ### Wrapping Selector, Separate Stylesheet
396
+ ```scss
397
+ // _layout.scss
398
+ #foo {
399
+ background: red;
400
+ @include breakpoint(567px, $no-query: '.no-mq') {
401
+ background: green;
402
+ }
403
+ }
404
+ ```
405
+ ```scss
406
+ // style.scss
407
+ $breakpoint-no-queries: false;
408
+ $breakpoint-no-query-wrappers: false;
409
+
410
+ @import 'layout';
411
+ ```
412
+ ```scss
413
+ // no-mq.scss
414
+ $breakpoint-no-queries: true;
415
+ $breakpoint-no-query-wrappers: true;
416
+
417
+ @import 'layout';
418
+ ```
419
+ ```css
420
+ /* style.css */
421
+ #foo {
422
+ background: red;
423
+ }
424
+
425
+ @media (min-width: 567px) {
426
+ #foo {
427
+ background: green;
428
+ }
429
+ }
430
+ ```
431
+ ```css
432
+ /* no-mq.css */
433
+ .no-mq #foo {
434
+ background: red;
435
+ background: green;
436
+ }
437
+ ```
300
438
 
301
439
  ## License
302
440
 
data/lib/breakpoint.rb CHANGED
@@ -3,8 +3,8 @@ require 'compass'
3
3
  Compass::Frameworks.register("breakpoint", :path => "#{File.dirname(__FILE__)}/..")
4
4
 
5
5
  module Breakpoint
6
- VERSION = "1.1.1"
7
- DATE = "2012-07-29"
6
+ VERSION = "1.2"
7
+ DATE = "2012-08-16"
8
8
  end
9
9
 
10
10
  module Sass::Script::Functions
@@ -3,11 +3,15 @@
3
3
  //////////////////////////////
4
4
  $breakpoint-default-feature: 'min-width' !default;
5
5
  $breakpoint-default-media: 'all' !default;
6
+ $breakpoint-force-media-all: false !default;
6
7
  $breakpoint-default-pair: 'width' !default;
7
8
  $breakpoint-to-ems: false !default;
8
9
  $breakpoint-prefixes: 'webkit' 'moz' !default;
9
10
  $breakpoint-prefixed-queries: 'device-pixel-ratio' 'min-device-pixel-ratio' 'max-device-pixel-ratio' !default;
10
11
 
12
+ $breakpoint-no-queries: false !default;
13
+ $breakpoint-no-query-wrappers: false !default;
14
+
11
15
  //////////////////////////////
12
16
  // Import Breakpoint Helpers
13
17
  //////////////////////////////
@@ -17,7 +21,7 @@ $breakpoint-prefixed-queries: 'device-pixel-ratio' 'min-device-pixel-ratio' 'max
17
21
  //////////////////////////////
18
22
  // Breakpoint Mixin
19
23
  //////////////////////////////
20
- @mixin breakpoint($breakpoint, $media: $breakpoint-default-media) {
24
+ @mixin breakpoint($breakpoint, $media: $breakpoint-default-media, $no-query: false) {
21
25
  // Query and Media String Defaults
22
26
  $query: false !default;
23
27
  $query-holder: false !default;
@@ -38,12 +42,12 @@ $breakpoint-prefixed-queries: 'device-pixel-ratio' 'min-device-pixel-ratio' 'max
38
42
 
39
43
  // Reset Context
40
44
  @include TXkgcmVzZXQhIEdvIGF3YXkh;
41
-
45
+
42
46
  // Set Media Context
43
47
  $context: U2V0IHlvdXIgb3duIGRhbW4gY29udGV4dHMh('media', $media);
44
48
 
45
49
  // Initialize Query String
46
- @if $media != 'all' {
50
+ @if $media != 'all' or $breakpoint-force-media-all {
47
51
  $media-string: "#{$media} ";
48
52
  }
49
53
  @else {
@@ -146,29 +150,42 @@ $breakpoint-prefixed-queries: 'device-pixel-ratio' 'min-device-pixel-ratio' 'max
146
150
  }
147
151
  }
148
152
 
149
- @if not $webkit and not $moz and not $o and not $ms {
150
- @media #{$query} {
151
- @content;
153
+ @if $breakpoint-no-queries {
154
+ @if $no-query {
155
+ $context: U2V0IHlvdXIgb3duIGRhbW4gY29udGV4dHMh('no queries', true);
156
+ @if $breakpoint-no-query-wrappers and type-of($no-query) == string {
157
+ #{$no-query} & {
158
+ @content;
159
+ $context: U2V0IHlvdXIgb3duIGRhbW4gY29udGV4dHMh('no query wrapper', $no-query);
160
+ }
161
+ }
162
+ @else {
163
+ @content;
164
+ }
152
165
  }
153
166
  }
154
167
  @else {
155
- @if $webkit {
156
- @media #{$webkit} {
168
+ @if $breakpoint-no-query-wrappers and type-of($no-query) == string {
169
+ #{$no-query} & {
157
170
  @content;
171
+ $context: U2V0IHlvdXIgb3duIGRhbW4gY29udGV4dHMh('no query wrapper', $no-query);
158
172
  }
159
173
  }
160
- @if $moz {
161
- @media #{$moz} {
174
+ @if $query {
175
+ @media #{$query} {
162
176
  @content;
163
177
  }
164
178
  }
165
- @if $o {
166
- @media #{$o} {
167
- @content;
179
+ @else {
180
+ $pf-queries: $webkit, $moz, $o, $ms;
181
+ $pf-query: ();
182
+
183
+ @each $pfq in $pf-queries {
184
+ @if $pfq {
185
+ $pf-query: append($pf-query, $pfq, comma);
186
+ }
168
187
  }
169
- }
170
- @if $ms {
171
- @media #{$ms} {
188
+ @media #{$pf-query} {
172
189
  @content;
173
190
  }
174
191
  }
metadata CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 1
9
- version: 1.1.1
7
+ - 2
8
+ version: "1.2"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Mason Wendell
@@ -15,13 +14,27 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-07-29 00:00:00 -04:00
17
+ date: 2012-08-16 00:00:00 -04:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: compass
21
+ name: sass
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 2
30
+ - 0
31
+ version: 3.2.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: compass
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
25
38
  requirements:
26
39
  - - ">="
27
40
  - !ruby/object:Gem::Version
@@ -31,7 +44,7 @@ dependencies:
31
44
  - 1
32
45
  version: 0.12.1
33
46
  type: :runtime
34
- version_requirements: *id001
47
+ version_requirements: *id002
35
48
  description: Really simple media queries in Sass
36
49
  email:
37
50
  - mason@zivtech.com