stratum 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@
5
5
  @import "css3/calc";
6
6
  @import "css3/columns";
7
7
  @import "css3/flex";
8
+ @import "css3/gradients";
8
9
  @import "css3/transform";
9
10
  @import "css3/transition";
10
11
  @import "css3/user-select";
@@ -14,6 +14,10 @@
14
14
  // - Firefox 20+
15
15
  // - Opera 12.1+
16
16
 
17
+ // Not supported
18
+ // - IE < 10
19
+ // - Opera Mini
20
+
17
21
  @mixin flex-container {
18
22
  display: -webkit-flex;
19
23
  display: -ms-flexbox;
@@ -0,0 +1,288 @@
1
+ // CSS Gradients
2
+ // -------------
3
+
4
+ // Vendor prefixes:
5
+ // - Firefox: 3.6+
6
+ // - Chrome 10+
7
+ // - Safari 5.1+
8
+ // - iOS Safari 3.2+
9
+ // - Android 2.1+
10
+ // - Blackberry 7+
11
+
12
+ // No prefixes
13
+ // - Firefox 16+
14
+ // - Opera 12.1
15
+ // - Chrome 26+
16
+ // - IE 10+
17
+
18
+ // Not supported
19
+ // - IE < 10
20
+ // - Opera Mini
21
+
22
+ $vendor-prefixes-background: webkit moz spec !default;
23
+
24
+
25
+ // Parse CSS functions
26
+ // -------------------
27
+ // linear-gradient
28
+ @function linear-gradient($values...) {
29
+ @return append(linear, $values);
30
+ }
31
+ // linear-gradient
32
+ // ---------------
33
+ @function radial-gradient($values...) {
34
+ @return append(radial, $values);
35
+ }
36
+
37
+
38
+ // Reverse direction keyword
39
+ // -------------------------
40
+ // used to convert between standards and pre-standards modes
41
+ @function -gradient-reverse-direction-keywords($-keywords...) {
42
+ $-direction-keywords: null;
43
+
44
+ @if type-of($-keywords) == arglist {
45
+ // convert arglist into list
46
+ @each $-kw in $-keywords { $-keywords: $-kw }
47
+ }
48
+
49
+ @each $-keyword in $-keywords {
50
+ @if $-keyword == top {
51
+ $-direction-keywords: #{unquote($-direction-keywords) bottom};
52
+ }
53
+ @if $-keyword == bottom {
54
+ $-direction-keywords: #{unquote($-direction-keywords) top};
55
+ }
56
+ @if $-keyword == left {
57
+ $-direction-keywords: #{unquote($-direction-keywords) right};
58
+ }
59
+ @if $-keyword == right {
60
+ $-direction-keywords: #{unquote($-direction-keywords) left};
61
+ }
62
+ @if $-keyword == center {
63
+ $-direction-keywords: #{unquote($-direction-keywords) center};
64
+ }
65
+ }
66
+
67
+ @return $-direction-keywords;
68
+ }
69
+
70
+
71
+ // Parse gradient directions
72
+ // -------------------------
73
+ @function -parse-direction($-keywords, $-prefix: to, $-mode: standard, $-reverse: true) {
74
+ $-direction-old-syntax: $-keywords;
75
+ $-direction-new-syntax: #{$-prefix -gradient-reverse-direction-keywords($-direction-old-syntax)};
76
+ @if not $-reverse {
77
+ $-direction-new-syntax: #{$-prefix $-direction-old-syntax};
78
+ }
79
+
80
+ // Convert back to non-standard direction keywords
81
+ @if index(to at, nth($-keywords, 1)) {
82
+ $-direction-old-syntax: -gradient-reverse-direction-keywords($-direction-old-syntax);
83
+ $-direction-new-syntax: $-keywords;
84
+
85
+ // get keywords sans standard `at/to` prefix
86
+ $-non-standard-direction: ();
87
+ @for $-i from 2 to length($-keywords) + 1 {
88
+ $-non-standard-direction: append($-non-standard-direction, nth($-keywords, $-i));
89
+ }
90
+ // use the same keyword if $-reverse if false
91
+ @if not $-reverse {
92
+ $-direction-old-syntax: $-non-standard-direction;
93
+ }
94
+ }
95
+ // Convert to standard direction keywords
96
+ @else {
97
+ @if type-of($-keywords) == number {
98
+ $-direction-new-syntax: $-direction-old-syntax;
99
+ }
100
+ }
101
+
102
+ @if $-mode == standard {
103
+ @return $-direction-new-syntax;
104
+ } @else {
105
+ @return $-direction-old-syntax;
106
+ }
107
+ }
108
+
109
+
110
+ // Outputs linear gradient value for specific vendor
111
+ // -------------------------------------------------
112
+ @function -linear-gradient($-vendor, $values...) {
113
+ @if type-of($values) == arglist {
114
+ // convert arglist into list
115
+ @each $-value in $values { $values: $-value }
116
+ }
117
+
118
+ $-direction: top;
119
+ $-combined-background: ();
120
+ $-stops: ();
121
+
122
+ @each $-value in $values {
123
+ // Gradient stops
124
+ @if type-of(nth($-value, 1)) == color
125
+ or (type-of(nth($-value, 1)) == string and nth($-value, 1) == transparent) {
126
+ $-stops: append($-stops, $-value, comma);
127
+ }
128
+ // Direction provided
129
+ @else if index(string number list, type-of($-value)) {
130
+ $-direction: $-value;
131
+ }
132
+ }
133
+
134
+ $-direction: -parse-direction($-direction, to, if($-vendor == "spec", standard, old));
135
+ $-prefixed-gradients: vendor-prefix(linear-gradient, #{$-direction, $-stops}, $-vendor);
136
+ $-combined-background: append($-combined-background, $-prefixed-gradients, comma);
137
+
138
+ // background-color: mix(nth($-stops, 1), nth($-stops, length($-stops)));
139
+ @return $-combined-background;
140
+ }
141
+
142
+
143
+ // Outputs radial gradient value for specific vendor
144
+ // -------------------------------------------------
145
+ @function -radial-gradient($-vendor, $values...) {
146
+ @if type-of($values) == arglist {
147
+ // convert arglist into list
148
+ @each $-value in $values { $values: $-value }
149
+ }
150
+
151
+ $-shape: null;
152
+ $-shape-size: ();
153
+ $-extend-keyword: null;
154
+ $-position: center;
155
+ $-combined-background: ();
156
+ $-stops: ();
157
+
158
+ @each $-value in $values {
159
+ // Gradient stops
160
+ @if type-of(nth($-value, 1)) == color
161
+ or (type-of(nth($-value, 1)) == string and nth($-value, 1) == transparent) {
162
+ $-stops: append($-stops, $-value, comma);
163
+ }
164
+ // Gradient parameters
165
+ // Simple (one parameter)
166
+ @else if type-of($-value) == string {
167
+ // Shape
168
+ @if index(circle ellipse, $-value) {
169
+ $-shape: $-value;
170
+ // Position
171
+ } @else if index(center top bottom left right, $-value) {
172
+ $-position: $-value;
173
+ }
174
+ }
175
+ // Complex (list of parameters)
176
+ @else if type-of($-value) == list {
177
+ $-pos: ();
178
+ @each $-v in $-value {
179
+ // Extend keywords
180
+ @if index(cover contain closest-side closest-corner farthest-side farthest-corner, $-v) {
181
+ // Early drafts
182
+ @if $-v == cover and $-vendor == spec {
183
+ $-extend-keyword: farthest-corner;
184
+ } @else if $-v == contain and $-vendor == spec {
185
+ $-extend-keyword: closest-side;
186
+ }
187
+ // Current standard
188
+ @else {
189
+ $-extend-keyword: $-v;
190
+ }
191
+ }
192
+ // Position keywords
193
+ @else if index(center top bottom left right, $-v) {
194
+ $-pos: append($-v, $-pos);
195
+ }
196
+ // Numbers
197
+ @else if type-of($-v) == number {
198
+ // Position percentage
199
+ @if unit($-v) == "%" {
200
+ $-pos: append($-pos, $-v);
201
+ }
202
+ // Shape size
203
+ @if index(px em ex mm cm, unit($-v)) {
204
+ $-shape-size: append($-shape-size, $-v);
205
+ }
206
+ }
207
+ // Shape
208
+ @else if index(ellipse circle, $-v) {
209
+ $-shape: $-v;
210
+ }
211
+ }
212
+ $-position: if(length($-pos) > 0, $-pos, $-position);
213
+ }
214
+ }
215
+
216
+ $-gradient-params: #{$-position, $-extend-keyword if($-shape-size, $-shape-size, $-shape)};
217
+
218
+ @if $-vendor == spec {
219
+ $-position: -parse-direction($-position, at, if($-vendor == "spec", standard, old), $-reverse: false);
220
+ $-gradient-params: #{$-shape-size $-shape $-extend-keyword $-position};
221
+ }
222
+
223
+ $-prefixed-gradients: vendor-prefix(radial-gradient, #{$-gradient-params, $-stops}, $-vendor);
224
+ $-combined-background: append($-combined-background, $-prefixed-gradients, comma);
225
+
226
+ // background-color: mix(nth($-stops, 1), nth($-stops, length($-stops)));
227
+ @return $-combined-background;
228
+ }
229
+
230
+
231
+ // Background shorthand mixin
232
+ // --------------------------
233
+ // Can take comma-separated gradients and background images
234
+ // If one gradient is specified, a colour fallback can be given as the first parameter
235
+ // e.g. `background(#ddd, linear-gradient(#eee, #ccc))`
236
+ // Colour background can also be provided with image e.g. `..., #ddd url(...) no-repeat 50%`
237
+ @mixin background($values...) {
238
+ @each $-vendor in $vendor-prefixes-background {
239
+ $-color: null;
240
+ $-combined-background: ();
241
+
242
+ // Extract individual backgrounds from string
243
+ @each $-value in $values {
244
+ // Look for colours
245
+ @if type-of($-value) == color {
246
+ $-color: $-value;
247
+ }
248
+ // Look for linear/radial gradient
249
+ @if index(linear radial, nth($-value, 1)) {
250
+ $-type: nth($-value, 1);
251
+ $-params: nth($-value, 2);
252
+ @if $-type == linear {
253
+ $-combined-background: append($-combined-background, -linear-gradient($-vendor, $-params), comma);
254
+ }
255
+ @if $-type == radial {
256
+ $-combined-background: append($-combined-background, -radial-gradient($-vendor, $-params), comma);
257
+ }
258
+ }
259
+ // Look for image URL
260
+ @else if index(string list, type-of($-value)) {
261
+ $-combined-background: append($-combined-background, $-value);
262
+ }
263
+ }
264
+
265
+ // Add fallback colour if only one gradient is specified
266
+ $-color-fallback: if(length($-combined-background) == 1, $-color, null);
267
+
268
+ background: #{unquote($-color-fallback) $-combined-background};
269
+ }
270
+ }
271
+
272
+
273
+ // Linear gradient mixin
274
+ // ---------------------
275
+ @mixin linear-gradient($values...) {
276
+ @each $-vendor in $vendor-prefixes-background {
277
+ background-image: -linear-gradient($-vendor, $values);
278
+ }
279
+ }
280
+
281
+
282
+ // Radial gradient mixin
283
+ // ---------------------
284
+ @mixin radial-gradient($values...) {
285
+ @each $-vendor in $vendor-prefixes-background {
286
+ background-image: -radial-gradient($-vendor, $values);
287
+ }
288
+ }
@@ -1,12 +1,17 @@
1
1
  // Generate CSS triangles
2
2
  // ----------------------
3
3
 
4
+ // $size can be:
5
+ // one value - base; sides are created 2/3 of base length
6
+ // two values - base and two sides (e.g. 12px 10px)
7
+ // three values - base and each side (e.g. 12px 4px 7px; base left right)
8
+
4
9
  @mixin triangle($position: top, $color: black, $size: 16px) {
5
10
  $-dimensions: null;
6
11
  $-colors: null;
7
- $-height: nth($size, 1);
8
- $-left: $-height / 1.5;
9
- $-right: $-height / 1.5;
12
+ $-base: nth($size, 1);
13
+ $-left: $-base / 1.5;
14
+ $-right: $-base / 1.5;
10
15
 
11
16
  // sides width specified
12
17
  @if length($size) == 2 {
@@ -19,35 +24,35 @@
19
24
  }
20
25
 
21
26
  @if $position == top {
22
- $-dimensions: 0 $-right $-height $-left;
27
+ $-dimensions: 0 $-right $-base $-left;
23
28
  $-colors: transparent transparent $color;
24
29
  }
25
30
  @if $position == top-right {
26
- $-dimensions: 0 $-height $-height 0;
31
+ $-dimensions: 0 $-base $-base 0;
27
32
  $-colors: transparent $color transparent transparent;
28
33
  }
29
34
  @if $position == right {
30
- $-dimensions: $-left 0 $-right $-height;
35
+ $-dimensions: $-left 0 $-right $-base;
31
36
  $-colors: transparent transparent transparent $color;
32
37
  }
33
38
  @if $position == bottom-right {
34
- $-dimensions: 0 0 $-height $-height;
39
+ $-dimensions: 0 0 $-base $-base;
35
40
  $-colors: transparent transparent $color;
36
41
  }
37
42
  @if $position == bottom {
38
- $-dimensions: $-height $-left 0 $-right;
43
+ $-dimensions: $-base $-left 0 $-right;
39
44
  $-colors: $color transparent transparent;
40
45
  }
41
46
  @if $position == bottom-left {
42
- $-dimensions: $-height 0 0 $-height;
47
+ $-dimensions: $-base 0 0 $-base;
43
48
  $-colors: transparent transparent transparent $color;
44
49
  }
45
50
  @if $position == left {
46
- $-dimensions: $-left $-height $-right 0;
51
+ $-dimensions: $-left $-base $-right 0;
47
52
  $-colors: transparent $color transparent transparent;
48
53
  }
49
54
  @if $position == top-left {
50
- $-dimensions: $-height $-height 0 0;
55
+ $-dimensions: $-base $-base 0 0;
51
56
  $-colors: $color transparent transparent transparent;
52
57
  }
53
58
 
@@ -16,3 +16,23 @@
16
16
  }
17
17
  }
18
18
  }
19
+
20
+
21
+ @function vendor-prefix($property, $value, $prefixes) {
22
+ $-allowed-prefixes: moz, webkit, ms, o, spec;
23
+
24
+ @each $-prefix in $prefixes {
25
+ $-result: invalid;
26
+
27
+ @each $-allowed-prefix in $-allowed-prefixes {
28
+ @if $-prefix == $-allowed-prefix {
29
+ $-result: if($-prefix == "spec", "", "-#{$-prefix}-");
30
+ }
31
+ }
32
+ @if($-result != invalid) {
33
+ @return unquote("#{$-result}#{$property}(#{$value})");
34
+ } @else {
35
+ @warn("Prefix '-#{$-prefix}' is invalid");
36
+ }
37
+ }
38
+ }
@@ -1,3 +1,3 @@
1
1
  module Stratum
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stratum
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-16 00:00:00.000000000 Z
12
+ date: 2013-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70094945051220 !ruby/object:Gem::Requirement
16
+ requirement: &70096668512440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70094945051220
24
+ version_requirements: *70096668512440
25
25
  description: Stratum is a collection of SASS mixins and utilities for your web development
26
26
  needs.
27
27
  email: tyom@semonov.com
@@ -44,6 +44,7 @@ files:
44
44
  - assets/stylesheets/css3/_calc.scss
45
45
  - assets/stylesheets/css3/_columns.scss
46
46
  - assets/stylesheets/css3/_flex.scss
47
+ - assets/stylesheets/css3/_gradients.scss
47
48
  - assets/stylesheets/css3/_transform.scss
48
49
  - assets/stylesheets/css3/_transition.scss
49
50
  - assets/stylesheets/css3/_user-select.scss