breakpoint 0.2 → 0.3

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
+ ## 0.3 - June 18, 2012
4
+ * Rewrote 'device-pixel-ratio' conversions to change from prefixed nightmarish hell to Resolution standard based on the [W3C Unprefixing -webkit-device-pixel-ratio article](http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/)
5
+ * Large README update covering feature set, installation, assumptions, and more.
6
+
3
7
  ## 0.2 - May 24, 2012
4
8
  * Converted from Sass to SCSS
5
9
  * Converted README examples from Sass to SCSS
data/README.markdown CHANGED
@@ -2,28 +2,53 @@
2
2
 
3
3
  **Really simple media queries in Sass**
4
4
 
5
+ Breakpoint aims to make writing media queries in Sass super simple. Create a variable using a simplified syntax based on most commonly used media queries, then call it using the `breakpoint` mixin. Breakpoint handles all of the lifting of writing the media query itself, including cross-browser compatibility issues, so you can focus on what's important: making sure your website looks its best.
5
6
 
6
- ## Setup
7
+ Breakpoint makes the following assumptions:
8
+
9
+ * All queries are assumed to be screen queries. This can be overwritten by specifying the media you'd like to query against as the second parameter in the breakpoint mixin.
10
+ * A single value query is assumed to be against the `min-width` feature. This can be overwritten by adding the feature you'd like to query against.
11
+ * A two value query is assumed to be against the `min-width`/`max-width` feature pair. This can be overwritten by adding the feature you'd like to query against.
12
+ * Unprefixed `device-pixel-ratio` queries are transformed into the standard `resolution` breakpoint based on the [W3C recommendation for how to do so](http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/). This can be overwritten by passing in prefixed the needed prefixed feature.
13
+
14
+ ## Requirements
15
+
16
+ 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!
17
+
18
+ ## Installation
19
+
20
+ `gem install breakpoint`
7
21
 
8
- ```sass
9
- @import "breakpoint"
22
+ #### If creating a new project
23
+ `compass create <my_project> -r breakpoint`
10
24
 
25
+ #### If adding to existing project, in config.rb
26
+ `require 'breakpoint`
27
+
28
+ #### Import the breakpoint partial at the top of your working file
29
+ `@import "breakpoint";`
30
+
31
+
32
+ ## Setup
33
+
34
+ ```scss
11
35
  // create $breakpoint variables like so
12
36
  // assume $breakpoint-default-feature if only a number
13
- $breakpoint1: 500px
14
- $breakpoint2: 30em
37
+ $breakpoint1: 500px;
38
+ $breakpoint2: 30em;
15
39
  // set min-width/max-width if both values are numbers
16
- $breakpoint3: 500px 700px
17
- // set min/max of feature if there are two numbers and a feature
18
- $breakpoint4: 300px 700px height
40
+ $breakpoint3: 500px 700px;
41
+ // set min/max of feature if there are two numbers
42
+ $breakpoint4: 300px 700px 'height';
19
43
  // if one value is a string, assume a feature/value pair
20
- $breakpoint5: min-width 700px
21
- $breakpoint6: max-width 700px
44
+ $breakpoint5: min-width 700px;
45
+ $breakpoint6: max-width 700px;
22
46
  // for multidimensional lists, assume each item is a feature value pair
23
- $breakpoint7: max-width 700px, orientation portrait
47
+ $breakpoint7: max-width 700px, orientation portrait;
24
48
  // handle one-sided features (ie. monochrome)
25
- $breakpoint8: max-width 700px, orientation portrait, monochrome
26
- $breakpoint9: monochrome
49
+ $breakpoint8: max-width 700px, orientation portrait, monochrome;
50
+ $breakpoint9: monochrome;
51
+ $breakpoint10: 2 device-pixel-ratio;
27
52
  ```
28
53
 
29
54
 
@@ -47,11 +72,6 @@ Call the mixin and pass one of your breakpoint variables. You can also call it w
47
72
  content: 'baz';
48
73
  }
49
74
  }
50
- .tgif {
51
- @include breakpoint($breakpoint4) {
52
- content: 'tgif';
53
- }
54
- }
55
75
  .omg {
56
76
  @include breakpoint($breakpoint5) {
57
77
  content: 'omg';
@@ -87,6 +107,16 @@ Call the mixin and pass one of your breakpoint variables. You can also call it w
87
107
  content: 'rhcp';
88
108
  }
89
109
  }
110
+ .tgif {
111
+ @include breakpoint($breakpoint4) {
112
+ content: 'tgif';
113
+ }
114
+ }
115
+ .omgdpr {
116
+ @include breakpoint($breakpoint10) {
117
+ content: 'omgdpr';
118
+ }
119
+ }
90
120
  ```
91
121
 
92
122
  Example generated CSS
@@ -110,12 +140,6 @@ Example generated CSS
110
140
  }
111
141
  }
112
142
 
113
- @media screen and (min-height: 300px) and (max-height: 700px) {
114
- .tgif {
115
- content: "tgif";
116
- }
117
- }
118
-
119
143
  @media screen and (min-width: 700px) {
120
144
  .omg {
121
145
  content: "omg";
@@ -157,24 +181,19 @@ Example generated CSS
157
181
  content: "rhcp";
158
182
  }
159
183
  }
160
- ```
161
-
162
- ### Installation
163
-
164
- 0. [Install Sass and Compass](http://compass-style.org/install/), if you haven't already.
165
- 1. **Terminal**: `gem install breakpoint`
166
- 2. Add `require 'breakpoint'` in Compass's config.rb file
167
-
168
-
169
-
170
-
171
- ## Requirements
172
-
173
- - [Sass](http://sass-lang.com/)
174
- - [Compass](http://compass-style.org/)
175
-
176
184
 
185
+ @media screen and (min-height: 300px) and (max-height: 700px) {
186
+ .tgif {
187
+ content: "tgif";
188
+ }
189
+ }
177
190
 
191
+ @media screen and (resolution: 192dpi) {
192
+ .omgdpr {
193
+ content: "omgdpr";
194
+ }
195
+ }
196
+ ```
178
197
 
179
198
  ## License
180
199
 
@@ -184,5 +203,4 @@ GPL license:
184
203
  http://www.gnu.org/licenses/gpl.html
185
204
 
186
205
  MIT license:
187
- http://www.opensource.org/licenses/mit-license.php
188
-
206
+ http://www.opensource.org/licenses/mit-license.php
data/lib/breakpoint.rb CHANGED
@@ -4,7 +4,7 @@ Compass::Frameworks.register("breakpoint", :path => "#{File.dirname(__FILE__)}/.
4
4
 
5
5
  module Breakpoint
6
6
 
7
- VERSION = "0.2"
8
- DATE = "2012-05-24"
7
+ VERSION = "0.3"
8
+ DATE = "2012-06-21"
9
9
 
10
10
  end
@@ -32,7 +32,7 @@ $breakpoint-default-feature: min-width !default;
32
32
  // Feature/Value Placeholders
33
33
  $feature: false !default;
34
34
  $value: false !default;
35
- // Prefixed Queries
35
+ // Prefixed Queries (We have none for now, mostly to be Future Friendly)
36
36
  $webkit-query-string: false !default;
37
37
  $moz-query-string: false !default;
38
38
  $ms-query-string: false !default;
@@ -53,18 +53,13 @@ $breakpoint-default-feature: min-width !default;
53
53
  @if type-of(nth($breakpoint, 1)) == number and type-of(nth($breakpoint, 2)) == number {
54
54
  // Optionally pass in 3rd parameter
55
55
  @if length($breakpoint) == 3 and breakpoint-min-max(nth($breakpoint, 3)) {
56
- // Device Pixel Ratio is fracking weird, need to handle it three different ways
56
+ // If the feature is device-pixel-ratio, let's convert it to the standard resolution media query!
57
+ // - via http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/
57
58
  @if nth($breakpoint, 3) == 'device-pixel-ratio' {
58
- // Webkit
59
- $webkit-query-string: breakpoint-concatenate($query-string, nth($breakpoint, 1), "-webkit-min-#{nth($breakpoint, 3)}");
60
- $webkit-query-string: breakpoint-concatenate($webkit-query-string, nth($breakpoint, 2), "-webkit-min-#{nth($breakpoint, 3)}");
61
- // Mozilla
62
- $moz-query-string: breakpoint-concatenate($query-string, nth($breakpoint, 1), "min--moz-#{nth($breakpoint, 3)}");
63
- $moz-query-string: breakpoint-concatenate($moz-query-string, nth($breakpoint, 2), "max--moz-#{nth($breakpoint, 3)}");
64
- // Opera
65
- // remove opera support for now.
66
- // $o-query-string: breakpoint-concatenate($query-string, '#{numerator(nth($breakpoint, 1))}/#{denominator(nth($breakpoint, 1))}', "-o-min-#{nth($breakpoint, 3)}");
67
- // $o-query-string: breakpoint-concatenate($o-query-string, '#{numerator(nth($breakpoint, 2))}/#{denominator(nth($breakpoint, 2))}', "-o-max-#{nth($breakpoint, 3)}");
59
+ $value1: 96 * nth($breakpoint, 1) * 1dpi;
60
+ $value2: 96 * nth($breakpoint, 2) * 1dpi;;
61
+ $feature: 'resolution';
62
+ $breakpoint: $value1 $value2 $feature;
68
63
  }
69
64
  // Min/Max for given
70
65
  $query-string: breakpoint-concatenate($query-string, nth($breakpoint, 1), "min-#{nth($breakpoint, 3)}");
@@ -77,8 +72,6 @@ $breakpoint-default-feature: min-width !default;
77
72
  $query-string: breakpoint-concatenate($query-string, nth($breakpoint, 1), "min-width");
78
73
  $query-string: breakpoint-concatenate($query-string, nth($breakpoint, 2), "max-width");
79
74
  }
80
-
81
-
82
75
  }
83
76
  @else if type-of(nth($breakpoint, 1)) == string or type-of(nth($breakpoint, 2)) == string {
84
77
  // if one value is a string, assume a feature/value pair
@@ -91,17 +84,26 @@ $breakpoint-default-feature: min-width !default;
91
84
  $feature: nth($breakpoint, 2);
92
85
  $value: nth($breakpoint, 1);
93
86
  }
94
- // If the feature is device-pixel-ratio, it's gonna be weird
87
+ // If the feature is device-pixel-ratio, let's convert it to the standard resolution media query!
88
+ // - via http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/
95
89
  @if $feature == 'device-pixel-ratio' {
96
- // Webkit
97
- $webkit-query-string: breakpoint-concatenate($query-string, $value, "-webkit-#{$feature}");
98
- // Mozilla
99
- $moz-query-string: breakpoint-concatenate($query-string, $value, "-moz-#{$feature}");
100
- // Opera
101
- // remove opera support for now.
102
- // $o-query-string: breakpoint-concatenate($query-string, '#{numerator($value)}/#{denominator($value)}', "-o-#{$feature}");
90
+ $value: 96 * $value * 1dpi;
91
+ $feature: 'resolution';
92
+ $query-string: breakpoint-concatenate($query-string, $value, $feature);
93
+ }
94
+ @else if $feature == 'min-device-pixel-ratio' {
95
+ $value: 96 * $value * 1dpi;
96
+ $feature: 'min-resolution';
97
+ $query-string: breakpoint-concatenate($query-string, $value, $feature);
98
+ }
99
+ @else if $feature == 'max-device-pixel-ratio' {
100
+ $value: 96 * $value * 1dpi;
101
+ $feature: 'max-resolution';
102
+ $query-string: breakpoint-concatenate($query-string, $value, $feature);
103
+ }
104
+ @else {
105
+ $query-string: breakpoint-concatenate($query-string, $value, $feature);
103
106
  }
104
- $query-string: breakpoint-concatenate($query-string, $value, $feature);
105
107
  }
106
108
  @else if type-of(nth($breakpoint, 1)) == list {
107
109
  // for multidimensional lists, assume each item is a feature value pair
@@ -121,6 +123,7 @@ $breakpoint-default-feature: min-width !default;
121
123
  @media #{$query-string} {
122
124
  @content;
123
125
  }
126
+ // We have no prefixed query strings, this is mostly to be Future Friendly for now.
124
127
  @if $webkit-query-string {
125
128
  @media #{$webkit-query-string} {
126
129
  @content;
@@ -136,12 +139,11 @@ $breakpoint-default-feature: min-width !default;
136
139
  @content;
137
140
  }
138
141
  }
139
- // remove opera support for now.
140
- // @if $o-query-string {
141
- // @media #{$o-query-string} {
142
- // @content;
143
- // }
144
- // }
142
+ @if $o-query-string {
143
+ @media #{$o-query-string} {
144
+ @content;
145
+ }
146
+ }
145
147
  }
146
148
 
147
149
  @function breakpoint-concatenate($query-string, $new-value, $feature: $breakpoint-default-feature) {
metadata CHANGED
@@ -1,12 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breakpoint
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 2
9
- version: "0.2"
7
+ - 3
8
+ version: "0.3"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Mason Wendell
@@ -15,17 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-05-24 00:00:00 Z
17
+ date: 2012-06-21 00:00:00 -04:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: compass
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
24
  requirements:
26
25
  - - ">="
27
26
  - !ruby/object:Gem::Version
28
- hash: 45
29
27
  segments:
30
28
  - 0
31
29
  - 12
@@ -48,6 +46,7 @@ files:
48
46
  - CHANGELOG.markdown
49
47
  - lib/breakpoint.rb
50
48
  - stylesheets/_breakpoint.scss
49
+ has_rdoc: true
51
50
  homepage: http://thecodingdesigner.com
52
51
  licenses: []
53
52
 
@@ -57,20 +56,16 @@ rdoc_options: []
57
56
  require_paths:
58
57
  - lib
59
58
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
59
  requirements:
62
60
  - - ">="
63
61
  - !ruby/object:Gem::Version
64
- hash: 3
65
62
  segments:
66
63
  - 0
67
64
  version: "0"
68
65
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
66
  requirements:
71
67
  - - ">="
72
68
  - !ruby/object:Gem::Version
73
- hash: 23
74
69
  segments:
75
70
  - 1
76
71
  - 3
@@ -79,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
74
  requirements: []
80
75
 
81
76
  rubyforge_project:
82
- rubygems_version: 1.8.17
77
+ rubygems_version: 1.3.6
83
78
  signing_key:
84
79
  specification_version: 3
85
80
  summary: An easy to use system for writing and managing media queries.