susy 1.0.4 → 1.0.5.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -14,6 +14,7 @@ sass/susy/_media.scss
14
14
  sass/susy/_padding.scss
15
15
  sass/susy/_settings.scss
16
16
  sass/susy/_support.scss
17
+ sass/susy/_units.scss
17
18
  susy.gemspec
18
19
  templates/project/_base.scss
19
20
  templates/project/manifest.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5.alpha.0
data/sass/_susy.scss CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  // temporary
5
5
  @import "susy/support";
6
+ @import "susy/units";
6
7
 
7
8
  // permanent
8
9
  @import "susy/settings";
@@ -9,6 +9,8 @@ $browser-default-font-size-px : 16px;
9
9
  $browser-default-font-size-percent : 100%;
10
10
  $browser-default-font-size-pt : 12pt;
11
11
 
12
+ $rem-with-px-fallback : true !default;
13
+
12
14
  // ---------------------------------------------------------------------------
13
15
  // Grid Functions
14
16
 
@@ -173,28 +175,34 @@ $browser-default-font-size-pt : 12pt;
173
175
  //
174
176
  // $ems : The initial value to be converted.
175
177
  // $font-size : The current font-size in.
176
- @function absolute-ems(
178
+ @function base-ems(
177
179
  $ems,
178
180
  $font-size: $base-font-size
179
181
  ){
180
- $unit: unit($font-size);
182
+ $font-size : if(unit($ems) == 'rem', $base-font-size, $font-size);
183
+ $unit : unit($font-size);
184
+ $mult : $ems / ($ems * 0 + 1);
185
+
181
186
  @if $unit == 'px' {
182
- @return $font-size / $browser-default-font-size-px * $ems;
187
+ @return $font-size / $browser-default-font-size-px * $mult * 1em;
183
188
  }
184
189
  @else if $unit == '%' {
185
- @return $font-size / $browser-default-font-size-percent * $ems;
190
+ @return $font-size / $browser-default-font-size-percent * $mult * 1em;
186
191
  }
187
192
  @else if $unit == 'em' {
188
- @return $font-size / 1em * $ems;
193
+ @return $font-size / 1em * $mult * 1em;
189
194
  }
190
195
  @else if $unit == 'pt' {
191
- @return $font-size / $browser-default-font-size-pt * $ems;
196
+ @return $font-size / $browser-default-font-size-pt * $mult * 1em;
192
197
  }
193
198
  @else {
194
199
  @warn 'Variable $base-font-size does not have a valid font unit. Valid units for fonts in CSS are px, pt, em, and %.';
195
200
  }
196
201
  }
197
202
 
203
+ // This name will be deprecated...
204
+ @function absolute-ems($ems, $font-size: $base-font-size){ @return base-ems($ems, $font-size); }
205
+
198
206
  // Return a length, after any em-values have been sent through absolute-ems().
199
207
  //
200
208
  // $length : The length value to be checked and adjusted if necessary.
@@ -204,7 +212,7 @@ $browser-default-font-size-pt : 12pt;
204
212
  $font-size: $base-font-size
205
213
  ){
206
214
  @if $length {
207
- @if (unit($length) == 'em') {
215
+ @if (unit($length) == 'em') or (unit($length) == 'rem') {
208
216
  $length: absolute-ems($length,$font-size);
209
217
  }
210
218
  }
data/sass/susy/_grid.scss CHANGED
@@ -26,13 +26,19 @@
26
26
  $width: container-outer-width($columns);
27
27
 
28
28
  @if $container-style == 'static' {
29
- width: $width;
29
+ @include if-rem(width, $width);
30
30
  } @else {
31
31
  @if $container-style == 'fluid' {
32
- width: if(unit($width) == '%', $width, auto);
32
+ @include if-rem(width, if(unit($width) == '%', $width, auto));
33
33
  } @else {
34
- max-width: $width;
35
- @if $legacy-support-for-ie6 { _width: $width; }
34
+ @include if-rem(max-width, $width);
35
+ @if $legacy-support-for-ie6 {
36
+ @if unit($width) == 'rem' {
37
+ _width: round(convert-length($width, px));
38
+ } @else {
39
+ _width: $width;
40
+ }
41
+ }
36
42
  }
37
43
  }
38
44
  }
@@ -45,8 +51,9 @@
45
51
  ){
46
52
  @include pie-clearfix;
47
53
  @include set-container-width($columns);
54
+ @include if-rem(padding-left, $grid-padding);
55
+ @include if-rem(padding-right, $grid-padding);
48
56
  margin: { left: auto; right: auto; }
49
- padding: { left: $grid-padding; right: $grid-padding; }
50
57
  }
51
58
 
52
59
  // Set one or more layouts on a grid-containing element at any number of media-query breakpoints.
@@ -12,7 +12,7 @@
12
12
  $columns,
13
13
  $context : $total-columns,
14
14
  $from : $from-direction
15
- ) {
15
+ ) {
16
16
  margin-#{$from}: space($columns,$context);
17
17
  }
18
18
 
@@ -10,14 +10,14 @@
10
10
 
11
11
  // A debug tool for checking browser support
12
12
  @mixin debug-support-matrix($experimental: true, $ie: true) {
13
- @debug #{'$moz'}$experimental-support-for-mozilla
14
- #{'$webkit'}$experimental-support-for-webkit
15
- #{'$microsoft'}$experimental-support-for-microsoft
16
- #{'$opera'}$experimental-support-for-opera
17
- #{'$khtml'}$experimental-support-for-khtml;
18
- @debug #{'$ie6'}$legacy-support-for-ie6
19
- #{'$ie7'}$legacy-support-for-ie7
20
- #{'$ie8'}$legacy-support-for-ie8;
13
+ @debug #{'$moz-'}$experimental-support-for-mozilla
14
+ #{'$webkit-'}$experimental-support-for-webkit
15
+ #{'$microsoft-'}$experimental-support-for-microsoft
16
+ #{'$opera-'}$experimental-support-for-opera
17
+ #{'$khtml-'}$experimental-support-for-khtml;
18
+ @debug #{'$ie6-'}$legacy-support-for-ie6
19
+ #{'$ie7-'}$legacy-support-for-ie7
20
+ #{'$ie8-'}$legacy-support-for-ie8;
21
21
  }
22
22
 
23
23
  // Capture the current exerimental support settings
@@ -0,0 +1,159 @@
1
+ // @private Default font-size for all browsers
2
+ $browser-default-font-size: 16px;
3
+
4
+ // Base font size in pixels, if not already defined.
5
+ // Should be the same as the font-size of the html element.
6
+ $base-font-size: 16px !default;
7
+
8
+ // Whether to output fallback values in px when outputting rems.
9
+ $rem-with-px-fallback: true !default;
10
+
11
+ // Convert any CSS <length> or <percentage> value to any another.
12
+ //
13
+ // @param $length
14
+ // A css <length> or <percentage> value
15
+ //
16
+ // @param $to-unit
17
+ // String matching a css unit keyword, e.g. 'em', '%', etc.
18
+ //
19
+ // @param $from-context
20
+ // When converting from relative units, the absolute length (in px) to
21
+ // which $length refers (e.g. for $lengths in em units, would normally be the
22
+ // font-size of the current element).
23
+ //
24
+ // @param $to-context
25
+ // For converting to relative units, the absolute length in px to which the
26
+ // output value will refer. Defaults to the same as $from-context, since it is
27
+ // rarely needed.
28
+ @function convert-length(
29
+ $length,
30
+ $to-unit,
31
+ $from-context: $base-font-size,
32
+ $to-context: $from-context
33
+ ) {
34
+
35
+ $from-unit: unit($length);
36
+
37
+ // Optimize for cases where `from` and `to` units are accidentally the same.
38
+ @if $from-unit == $to-unit { @return $length; }
39
+
40
+ // Context values must be in px so we can determine a conversion ratio for
41
+ // relative units.
42
+ @if unit($from-context) != 'px' { @warn "Paremeter $from-context must resolve to a value in pixel units."; }
43
+ @if unit($to-context) != 'px' { @warn "Parameter $to-context must resolve to a value in pixel units."; }
44
+
45
+ // Convert input length to pixels
46
+ $px-length: $length;
47
+
48
+ @if $from-unit != 'px' {
49
+ // Convert relative units using the from-context parameter.
50
+ @if $from-unit == 'em' { $px-length: $length * $from-context / 1em }
51
+ @else if $from-unit == 'rem' { $px-length: $length * $base-font-size / 1rem }
52
+ @else if $from-unit == '%' { $px-length: $length * $from-context / 100% }
53
+ @else if $from-unit == 'ex' { $px-length: $length * $from-context / 2ex }
54
+ // Convert absolute units using Sass' conversion table.
55
+ @else if $from-unit == 'in' or
56
+ $from-unit == 'mm' or
57
+ $from-unit == 'cm' or
58
+ $from-unit == 'pt' or
59
+ $from-unit == 'pc' { $px-length: 0px + $length }
60
+ // Certain units can't be converted.
61
+ @else if $from-unit == 'ch' or
62
+ $from-unit == 'vw' or
63
+ $from-unit == 'vh' or
64
+ $from-unit == 'vmin' {
65
+ @warn "#{$from-unit} units can't be reliably converted; Returning original value.";
66
+ @return $length;
67
+ }
68
+ @else {
69
+ @warn "#{$from-unit} is an unknown length unit. Returning original value.";
70
+ @return $length;
71
+ }
72
+ }
73
+
74
+ // Convert length in pixels to the output unit
75
+ $output-length: $px-length;
76
+ @if $to-unit != 'px' {
77
+ // Relative units
78
+ @if $to-unit == 'em' { $output-length: $px-length * 1em / $to-context }
79
+ @else if $to-unit == 'rem' { $output-length: $px-length * 1rem / $base-font-size }
80
+ @else if $to-unit == '%' { $output-length: $px-length * 100% / $to-context }
81
+ @else if $to-unit == 'ex' { $output-length: $px-length * 2ex / $to-context }
82
+ // Absolute units
83
+ @else if $to-unit == 'in' { $output-length: 0in + $px-length }
84
+ @else if $to-unit == 'mm' { $output-length: 0mm + $px-length }
85
+ @else if $to-unit == 'cm' { $output-length: 0cm + $px-length }
86
+ @else if $to-unit == 'pt' { $output-length: 0pt + $px-length }
87
+ @else if $to-unit == 'pc' { $output-length: 0pc + $px-length }
88
+ // Non-convertible units
89
+ @else if $to-unit == 'ch' or
90
+ $to-unit == 'vw' or
91
+ $to-unit == 'vh' or
92
+ $to-unit == 'vmin' {
93
+ @warn "#{$to-unit} units can't be reliably converted; Returning original value.";
94
+ @return $length;
95
+ }
96
+ @else {
97
+ @warn "#{$to-unit} is an unknown length unit. Returning original value.";
98
+ @return $length;
99
+ }
100
+ }
101
+
102
+ @return $output-length;
103
+ }
104
+
105
+
106
+ // Output a given style rule containing rem values along with an (optional)
107
+ // fallback rule for older browsers (with rem values converted to px).
108
+ //
109
+ // @param $property
110
+ // The css property name.
111
+ //
112
+ // @param $values
113
+ // The value (or space-separated list of values) for the property.
114
+ //
115
+ // @param $use-px-fallback
116
+ // [ true | false ]
117
+ //
118
+ @mixin rem($property, $values, $use-px-fallback: $rem-with-px-fallback) {
119
+ // Create a couple of empty lists as output buffers.
120
+ $px-values: ();
121
+ $rem-values: ();
122
+
123
+ // Loop through the $values list
124
+ @each $value in $values {
125
+ // For each property value, if it's in rem or px, derive both rem and
126
+ // px values for it and add those to the end of the appropriate buffer.
127
+ // Ensure all pixel values are rounded to the nearest pixel.
128
+ @if type-of($value) == number and not unitless($value) and (unit($value) == px or unit($value) == rem) {
129
+ @if unit($value) == px {
130
+ $px-values: join($px-values, round($value));
131
+ $rem-values: join($rem-values, convert-length($value, rem));
132
+ }
133
+ @else {
134
+ $px-values: join($px-values, round(convert-length($value, px)));
135
+ $rem-values: join($rem-values, $value);
136
+ }
137
+ }
138
+ @else {
139
+ $px-values: join($px-values, $value);
140
+ $rem-values: join($rem-values, $value);
141
+ }
142
+ }
143
+
144
+ // Use pixel fallback for browsers that don't understand rem units.
145
+ @if $use-px-fallback {
146
+ #{$property}: $px-values;
147
+ }
148
+
149
+ // Use rem values for everyone else (overrides pixel values).
150
+ #{$property}: $rem-values;
151
+ }
152
+
153
+ @mixin if-rem($property, $values, $use-px-fallback: $rem-with-px-fallback) {
154
+ $has-rem: false;
155
+ @each $value in $values { $has-rem: if(unit($value) == 'rem', true, $has-rem); }
156
+ @if $has-rem { @include rem($property, $values, $use-px-fallback); }
157
+ @else { #{$property}: $values; }
158
+ }
159
+
data/susy.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{susy}
5
- s.version = "1.0.4"
5
+ s.version = "1.0.5.alpha.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Eric Meyer"]
9
- s.date = %q{2012-11-03}
9
+ s.date = %q{2012-11-06}
10
10
  s.description = %q{Susy grids are fluid on the inside, ready to respond at any moment, but contained in the candy shell of your choice, so they respond how and when and where you want them to. We don't design your site or dictate your markup, we just do the math and get out of your way.}
11
11
  s.email = %q{eric@oddbird.net}
12
12
  s.extra_rdoc_files = ["CHANGELOG.mkdn", "LICENSE.txt", "README.md", "lib/susy.rb"]
13
- s.files = ["CHANGELOG.mkdn", "LICENSE.txt", "Manifest", "README.md", "Rakefile", "VERSION", "lib/susy.rb", "sass/_susy.scss", "sass/susy/_background.scss", "sass/susy/_functions.scss", "sass/susy/_grid.scss", "sass/susy/_margin.scss", "sass/susy/_media.scss", "sass/susy/_padding.scss", "sass/susy/_settings.scss", "sass/susy/_support.scss", "susy.gemspec", "templates/project/_base.scss", "templates/project/manifest.rb", "templates/project/screen.scss", "test/config.rb", "test/css/background.css", "test/css/functions.css", "test/css/grid.css", "test/css/margin.css", "test/css/media.css", "test/css/padding.css", "test/scss/background.scss", "test/scss/functions.scss", "test/scss/grid.scss", "test/scss/margin.scss", "test/scss/media.scss", "test/scss/padding.scss"]
13
+ s.files = ["CHANGELOG.mkdn", "LICENSE.txt", "Manifest", "README.md", "Rakefile", "VERSION", "lib/susy.rb", "sass/_susy.scss", "sass/susy/_background.scss", "sass/susy/_functions.scss", "sass/susy/_grid.scss", "sass/susy/_margin.scss", "sass/susy/_media.scss", "sass/susy/_padding.scss", "sass/susy/_settings.scss", "sass/susy/_support.scss", "sass/susy/_units.scss", "susy.gemspec", "templates/project/_base.scss", "templates/project/manifest.rb", "templates/project/screen.scss", "test/config.rb", "test/css/background.css", "test/css/functions.css", "test/css/grid.css", "test/css/margin.css", "test/css/media.css", "test/css/padding.css", "test/scss/background.scss", "test/scss/functions.scss", "test/scss/grid.scss", "test/scss/margin.scss", "test/scss/media.scss", "test/scss/padding.scss"]
14
14
  s.homepage = %q{http://susy.oddbird.net/}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Susy", "--main", "README.md"]
16
16
  s.require_paths = ["lib"]
data/test/css/grid.css CHANGED
@@ -2,10 +2,10 @@
2
2
  *zoom: 1;
3
3
  max-width: 59em;
4
4
  _width: 59em;
5
- margin-left: auto;
6
- margin-right: auto;
7
5
  padding-left: 1em;
8
6
  padding-right: 1em;
7
+ margin-left: auto;
8
+ margin-right: auto;
9
9
  }
10
10
  .container:after {
11
11
  content: "";
@@ -17,10 +17,10 @@
17
17
  *zoom: 1;
18
18
  max-width: 59em;
19
19
  _width: 59em;
20
- margin-left: auto;
21
- margin-right: auto;
22
20
  padding-left: 1em;
23
21
  padding-right: 1em;
22
+ margin-left: auto;
23
+ margin-right: auto;
24
24
  }
25
25
  .complex-container:after {
26
26
  content: "";
@@ -94,10 +94,10 @@
94
94
  *zoom: 1;
95
95
  max-width: 61em;
96
96
  _width: 61em;
97
- margin-left: auto;
98
- margin-right: auto;
99
97
  padding-left: 1em;
100
98
  padding-right: 1em;
99
+ margin-left: auto;
100
+ margin-right: auto;
101
101
  }
102
102
  .container:after {
103
103
  content: "";
data/test/css/media.css CHANGED
@@ -2,10 +2,10 @@
2
2
  *zoom: 1;
3
3
  max-width: 19em;
4
4
  _width: 19em;
5
- margin-left: auto;
6
- margin-right: auto;
7
5
  padding-left: 1em;
8
6
  padding-right: 1em;
7
+ margin-left: auto;
8
+ margin-right: auto;
9
9
  }
10
10
  .layout:after {
11
11
  content: "";
@@ -16,10 +16,10 @@
16
16
  @media (min-width: 29em) {
17
17
  .breakpoint .break6 {
18
18
  max-width: 29em;
19
- margin-left: auto;
20
- margin-right: auto;
21
19
  padding-left: 1em;
22
20
  padding-right: 1em;
21
+ margin-left: auto;
22
+ margin-right: auto;
23
23
  }
24
24
  .breakpoint .break6:after {
25
25
  content: "";
@@ -58,13 +58,44 @@
58
58
  *zoom: 1;
59
59
  max-width: 28em;
60
60
  _width: 28em;
61
- margin-left: auto;
62
- margin-right: auto;
63
61
  padding-left: 1em;
64
62
  padding-right: 1em;
63
+ margin-left: auto;
64
+ margin-right: auto;
65
65
  }
66
66
  .with-settings6-3-2-1:after {
67
67
  content: "";
68
68
  display: table;
69
69
  clear: both;
70
70
  }
71
+
72
+ .with-settings6-3r-2r-1r {
73
+ *zoom: 1;
74
+ max-width: 504px;
75
+ max-width: 28rem;
76
+ _width: 504px;
77
+ padding-left: 18px;
78
+ padding-left: 1rem;
79
+ padding-right: 18px;
80
+ padding-right: 1rem;
81
+ margin-left: auto;
82
+ margin-right: auto;
83
+ }
84
+ .with-settings6-3r-2r-1r:after {
85
+ content: "";
86
+ display: table;
87
+ clear: both;
88
+ }
89
+
90
+ @media (min-width: 33.75em) and (max-width: 67.5em) {
91
+ .break60r-8-30r {
92
+ max-width: 684px;
93
+ max-width: 38rem;
94
+ }
95
+ }
96
+ @media (min-width: 33.75em) and (max-width: 67.5em) {
97
+ .break60-8-30 {
98
+ max-width: 684px;
99
+ max-width: 38rem;
100
+ }
101
+ }
data/test/scss/media.scss CHANGED
@@ -33,3 +33,18 @@
33
33
  @include with-grid-settings(6,3em,2em,1em) {
34
34
  .with-settings6-3-2-1 { @include container; }
35
35
  }
36
+
37
+ $base-font-size: 18px;
38
+
39
+ @include with-grid-settings(6,3rem,2rem,1rem) {
40
+ .with-settings6-3r-2r-1r { @include container; }
41
+
42
+ @include at-breakpoint(60rem 8 30rem) {
43
+ .break60r-8-30r { @include set-container-width; }
44
+ }
45
+ @include at-breakpoint(60em 8 30em) {
46
+ .break60-8-30 { @include set-container-width; }
47
+ }
48
+ }
49
+
50
+ $base-font-size: 16px;
metadata CHANGED
@@ -1,12 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: susy
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 4
9
- version: 1.0.4
8
+ - 5
9
+ - alpha
10
+ - 0
11
+ version: 1.0.5.alpha.0
10
12
  platform: ruby
11
13
  authors:
12
14
  - Eric Meyer
@@ -14,7 +16,7 @@ autorequire:
14
16
  bindir: bin
15
17
  cert_chain: []
16
18
 
17
- date: 2012-11-03 00:00:00 -06:00
19
+ date: 2012-11-06 00:00:00 -07:00
18
20
  default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
@@ -73,6 +75,7 @@ files:
73
75
  - sass/susy/_padding.scss
74
76
  - sass/susy/_settings.scss
75
77
  - sass/susy/_support.scss
78
+ - sass/susy/_units.scss
76
79
  - susy.gemspec
77
80
  - templates/project/_base.scss
78
81
  - templates/project/manifest.rb