foundation-rails 6.2.4.0 → 6.3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/Rakefile +2 -0
  4. data/bower.json +2 -2
  5. data/lib/foundation/rails/version.rb +1 -1
  6. data/lib/generators/foundation/templates/_settings.scss +117 -70
  7. data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -1
  8. data/vendor/assets/_vendor/normalize-scss/sass/_normalize.scss +3 -0
  9. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_import-now.scss +11 -0
  10. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_normalize-mixin.scss +676 -0
  11. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_variables.scss +36 -0
  12. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_vertical-rhythm.scss +61 -0
  13. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_purge.scss +38 -0
  14. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_remove.scss +31 -0
  15. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_replace.scss +46 -0
  16. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_to-list.scss +27 -0
  17. data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_missing-dependencies.scss +25 -0
  18. data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_true.scss +13 -0
  19. data/vendor/assets/js/foundation.abide.js.es6 +28 -0
  20. data/vendor/assets/js/foundation.accordion.js.es6 +1 -1
  21. data/vendor/assets/js/foundation.accordionMenu.js.es6 +9 -1
  22. data/vendor/assets/js/foundation.core.js.es6 +4 -4
  23. data/vendor/assets/js/foundation.drilldown.js.es6 +128 -14
  24. data/vendor/assets/js/foundation.dropdown.js.es6 +48 -42
  25. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +20 -18
  26. data/vendor/assets/js/foundation.equalizer.js.es6 +12 -6
  27. data/vendor/assets/js/foundation.interchange.js.es6 +3 -2
  28. data/vendor/assets/js/foundation.js.es6 +2 -1
  29. data/vendor/assets/js/foundation.magellan.js.es6 +28 -9
  30. data/vendor/assets/js/foundation.offcanvas.js.es6 +90 -123
  31. data/vendor/assets/js/foundation.orbit.js.es6 +61 -10
  32. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +2 -0
  33. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +52 -12
  34. data/vendor/assets/js/foundation.reveal.js.es6 +48 -48
  35. data/vendor/assets/js/foundation.slider.js.es6 +124 -42
  36. data/vendor/assets/js/foundation.sticky.js.es6 +11 -9
  37. data/vendor/assets/js/foundation.tabs.js.es6 +164 -35
  38. data/vendor/assets/js/foundation.toggler.js.es6 +3 -0
  39. data/vendor/assets/js/foundation.tooltip.js.es6 +20 -10
  40. data/vendor/assets/js/foundation.util.box.js.es6 +2 -2
  41. data/vendor/assets/js/foundation.util.keyboard.js.es6 +37 -0
  42. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +16 -0
  43. data/vendor/assets/js/foundation.util.motion.js.es6 +7 -1
  44. data/vendor/assets/js/foundation.util.nest.js.es6 +10 -5
  45. data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +6 -4
  46. data/vendor/assets/js/foundation.util.triggers.js.es6 +54 -36
  47. data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js.es6 +240 -0
  48. data/vendor/assets/scss/_global.scss +25 -450
  49. data/vendor/assets/scss/components/_accordion-menu.scss +8 -4
  50. data/vendor/assets/scss/components/_accordion.scss +43 -22
  51. data/vendor/assets/scss/components/_badge.scss +17 -9
  52. data/vendor/assets/scss/components/_breadcrumbs.scss +7 -5
  53. data/vendor/assets/scss/components/_button-group.scss +54 -6
  54. data/vendor/assets/scss/components/_button.scss +27 -16
  55. data/vendor/assets/scss/components/_callout.scss +3 -2
  56. data/vendor/assets/scss/components/_card.scss +121 -0
  57. data/vendor/assets/scss/components/_close-button.scss +54 -13
  58. data/vendor/assets/scss/components/_drilldown.scss +19 -5
  59. data/vendor/assets/scss/components/_dropdown-menu.scss +23 -18
  60. data/vendor/assets/scss/components/_dropdown.scss +14 -7
  61. data/vendor/assets/scss/components/_flex-video.scss +1 -63
  62. data/vendor/assets/scss/components/_float.scss +1 -1
  63. data/vendor/assets/scss/components/_label.scss +16 -8
  64. data/vendor/assets/scss/components/_media-object.scss +2 -3
  65. data/vendor/assets/scss/components/_menu.scss +68 -33
  66. data/vendor/assets/scss/components/_off-canvas.scss +231 -80
  67. data/vendor/assets/scss/components/_orbit.scss +8 -6
  68. data/vendor/assets/scss/components/_pagination.scss +42 -22
  69. data/vendor/assets/scss/components/_progress-bar.scss +1 -1
  70. data/vendor/assets/scss/components/_responsive-embed.scss +66 -0
  71. data/vendor/assets/scss/components/_reveal.scss +17 -11
  72. data/vendor/assets/scss/components/_slider.scss +6 -1
  73. data/vendor/assets/scss/components/_sticky.scss +3 -3
  74. data/vendor/assets/scss/components/_switch.scss +47 -36
  75. data/vendor/assets/scss/components/_table.scss +83 -23
  76. data/vendor/assets/scss/components/_tabs.scss +54 -23
  77. data/vendor/assets/scss/components/_thumbnail.scss +17 -4
  78. data/vendor/assets/scss/components/_title-bar.scss +5 -6
  79. data/vendor/assets/scss/components/_tooltip.scss +15 -12
  80. data/vendor/assets/scss/components/_top-bar.scss +11 -8
  81. data/vendor/assets/scss/forms/_checkbox.scss +2 -1
  82. data/vendor/assets/scss/forms/_error.scss +10 -6
  83. data/vendor/assets/scss/forms/_fieldset.scss +7 -7
  84. data/vendor/assets/scss/forms/_input-group.scss +17 -11
  85. data/vendor/assets/scss/forms/_label.scss +2 -0
  86. data/vendor/assets/scss/forms/_meter.scss +9 -10
  87. data/vendor/assets/scss/forms/_progress.scss +9 -9
  88. data/vendor/assets/scss/forms/_range.scss +20 -15
  89. data/vendor/assets/scss/forms/_select.scss +26 -8
  90. data/vendor/assets/scss/forms/_text.scss +19 -16
  91. data/vendor/assets/scss/foundation.scss +19 -3
  92. data/vendor/assets/scss/grid/_classes.scss +31 -14
  93. data/vendor/assets/scss/grid/_column.scss +10 -24
  94. data/vendor/assets/scss/grid/_flex-grid.scss +84 -76
  95. data/vendor/assets/scss/grid/_grid.scss +0 -16
  96. data/vendor/assets/scss/grid/_gutter.scss +53 -5
  97. data/vendor/assets/scss/grid/_layout.scss +3 -3
  98. data/vendor/assets/scss/grid/_position.scss +3 -3
  99. data/vendor/assets/scss/grid/_row.scss +24 -19
  100. data/vendor/assets/scss/settings/_settings.scss +117 -70
  101. data/vendor/assets/scss/typography/_base.scss +110 -44
  102. data/vendor/assets/scss/typography/_helpers.scss +1 -0
  103. data/vendor/assets/scss/typography/_print.scss +7 -3
  104. data/vendor/assets/scss/typography/_typography.scss +0 -2
  105. data/vendor/assets/scss/util/_breakpoint.scss +28 -19
  106. data/vendor/assets/scss/util/_color.scss +69 -16
  107. data/vendor/assets/scss/util/_flex.scss +20 -3
  108. data/vendor/assets/scss/util/_math.scss +72 -0
  109. data/vendor/assets/scss/util/_mixins.scss +63 -26
  110. data/vendor/assets/scss/util/_selector.scss +3 -2
  111. data/vendor/assets/scss/util/_unit.scss +61 -4
  112. data/vendor/assets/scss/util/_util.scss +1 -0
  113. data/vendor/assets/scss/util/_value.scss +33 -0
  114. metadata +17 -2
@@ -38,27 +38,6 @@ $header-font-style: normal !default;
38
38
  /// @type String | List
39
39
  $font-family-monospace: Consolas, 'Liberation Mono', Courier, monospace !default;
40
40
 
41
- /// Sizes of headings at various screen sizes. Each key is a breakpoint, and each value is a map of heading sizes.
42
- /// @type Map
43
- $header-sizes: (
44
- small: (
45
- 'h1': 24,
46
- 'h2': 20,
47
- 'h3': 19,
48
- 'h4': 18,
49
- 'h5': 17,
50
- 'h6': 16,
51
- ),
52
- medium: (
53
- 'h1': 48,
54
- 'h2': 40,
55
- 'h3': 31,
56
- 'h4': 25,
57
- 'h5': 20,
58
- 'h6': 16,
59
- ),
60
- ) !default;
61
-
62
41
  /// Color of headers.
63
42
  /// @type Color
64
43
  $header-color: inherit !default;
@@ -71,6 +50,47 @@ $header-lineheight: 1.4 !default;
71
50
  /// @type Number
72
51
  $header-margin-bottom: 0.5rem !default;
73
52
 
53
+ /// Styles for headings at various screen sizes. Each key is a breakpoint, and each value is a map of heading styles.
54
+ /// @type Map
55
+ $header-styles: (
56
+ small: (
57
+ 'h1': ('font-size': 24),
58
+ 'h2': ('font-size': 20),
59
+ 'h3': ('font-size': 19),
60
+ 'h4': ('font-size': 18),
61
+ 'h5': ('font-size': 17),
62
+ 'h6': ('font-size': 16),
63
+ ),
64
+ medium: (
65
+ 'h1': ('font-size': 48),
66
+ 'h2': ('font-size': 40),
67
+ 'h3': ('font-size': 31),
68
+ 'h4': ('font-size': 25),
69
+ 'h5': ('font-size': 20),
70
+ 'h6': ('font-size': 16),
71
+ ),
72
+ ) !default;
73
+
74
+ // $header-styles map is built from $header-sizes in order to ensure downward compatibility
75
+ // when $header-sizes is depreciated, $header-styles needs to get !default values like settings.scss
76
+ @function build_from_header-sizes($header-sizes) {
77
+ @warn 'Note, that $header-sizes has been replaced with $header-styles. $header-sizes still works, but it is going to be depreciated.';
78
+ $header-styles: ();
79
+ @each $size, $headers in $header-sizes {
80
+ $header-map: ();
81
+ @each $header, $font-size in $headers {
82
+ $header-map: map-merge($header-map, ($header: ('font-size': $font-size)));
83
+ }
84
+ $header-styles: map-merge($header-styles, ($size: $header-map));
85
+ }
86
+ @return $header-styles;
87
+ }
88
+
89
+ // If it exists $headers-sizes is used to build $header-styles. See the documentation.
90
+ @if variable-exists(header-sizes) {
91
+ $header-styles: build_from_header-sizes($header-sizes);
92
+ }
93
+
74
94
  /// Text rendering method of headers.
75
95
  /// @type String
76
96
  $header-text-rendering: optimizeLegibility !default;
@@ -203,6 +223,10 @@ $cite-font-size: rem-calc(13) !default;
203
223
  /// @type Color
204
224
  $cite-color: $dark-gray !default;
205
225
 
226
+ /// Pseudo content for `<cite>` elements.
227
+ /// @type String
228
+ $cite-pseudo-content: '\2014 \0020' !default;
229
+
206
230
  /// Font family for `<kbd>` elements.
207
231
  /// @type String | List
208
232
  $keystroke-font: $font-family-monospace !default;
@@ -254,9 +278,10 @@ $abbr-underline: 1px dotted $black !default;
254
278
 
255
279
  // Paragraphs
256
280
  p {
281
+ margin-bottom: $paragraph-margin-bottom;
282
+
257
283
  font-size: inherit;
258
284
  line-height: $paragraph-lineheight;
259
- margin-bottom: $paragraph-margin-bottom;
260
285
  text-rendering: $paragraph-text-rendering;
261
286
  }
262
287
 
@@ -288,26 +313,55 @@ $abbr-underline: 1px dotted $black !default;
288
313
  h5,
289
314
  h6 {
290
315
  font-family: $header-font-family;
291
- font-weight: $header-font-weight;
292
316
  font-style: $header-font-style;
317
+ font-weight: $header-font-weight;
293
318
  color: $header-color;
294
319
  text-rendering: $header-text-rendering;
295
- margin-top: 0;
296
- margin-bottom: $header-margin-bottom;
297
- line-height: $header-lineheight;
298
320
 
299
321
  small {
300
- color: $header-small-font-color;
301
322
  line-height: 0;
323
+ color: $header-small-font-color;
302
324
  }
303
325
  }
304
326
 
305
- // Heading sizes
306
- @each $size, $headers in $header-sizes {
327
+ // Heading styles
328
+ @each $size, $headers in $header-styles {
307
329
  @include breakpoint($size) {
308
- @each $header, $font-size in $headers {
330
+ @each $header, $header-defs in $headers {
331
+ $font-size-temp: 1rem;
309
332
  #{$header} {
310
- font-size: rem-calc($font-size);
333
+
334
+ @if map-has-key($header-defs, font-size) {
335
+ $font-size-temp: rem-calc(map-get($header-defs, font-size));
336
+ font-size: $font-size-temp;
337
+ } @else if map-has-key($header-defs, fs) {
338
+ $font-size-temp: rem-calc(map-get($header-defs, fs));
339
+ font-size: $font-size-temp;
340
+ } @else if $size == $-zf-zero-breakpoint {
341
+ font-size: $font-size-temp;
342
+ }
343
+ @if map-has-key($header-defs, line-height) {
344
+ line-height: unitless-calc(map-get($header-defs, line-height), $font-size-temp);
345
+ } @else if map-has-key($header-defs, lh) {
346
+ line-height: unitless-calc(map-get($header-defs, lh), $font-size-temp);
347
+ } @else if $size == $-zf-zero-breakpoint {
348
+ line-height: unitless-calc($header-lineheight, $font-size-temp);
349
+ }
350
+
351
+ @if map-has-key($header-defs, margin-top) {
352
+ margin-top: rem-calc(map-get($header-defs, margin-top));
353
+ } @else if map-has-key($header-defs, mt) {
354
+ margin-top: rem-calc(map-get($header-defs, mt));
355
+ } @else if $size == $-zf-zero-breakpoint {
356
+ margin-top: 0;
357
+ }
358
+ @if map-has-key($header-defs, margin-bottom) {
359
+ margin-bottom: rem-calc(map-get($header-defs, margin-bottom));
360
+ } @else if map-has-key($header-defs, mb) {
361
+ margin-bottom: rem-calc(map-get($header-defs, mb));
362
+ } @else if $size == $-zf-zero-breakpoint {
363
+ margin-bottom: rem-calc($header-margin-bottom);
364
+ }
311
365
  }
312
366
  }
313
367
  }
@@ -315,9 +369,10 @@ $abbr-underline: 1px dotted $black !default;
315
369
 
316
370
  // Links
317
371
  a {
372
+ line-height: inherit;
318
373
  color: $anchor-color;
319
374
  text-decoration: $anchor-text-decoration;
320
- line-height: inherit;
375
+
321
376
  cursor: pointer;
322
377
 
323
378
  &:hover,
@@ -335,23 +390,25 @@ $abbr-underline: 1px dotted $black !default;
335
390
 
336
391
  // Horizontal rule
337
392
  hr {
393
+ clear: both;
394
+
338
395
  max-width: $hr-width;
339
396
  height: 0;
340
- border-right: 0;
397
+ margin: $hr-margin;
398
+
341
399
  border-top: 0;
400
+ border-right: 0;
342
401
  border-bottom: $hr-border;
343
402
  border-left: 0;
344
- margin: $hr-margin;
345
- clear: both;
346
403
  }
347
404
 
348
405
  // Lists
349
406
  ul,
350
407
  ol,
351
408
  dl {
352
- line-height: $list-lineheight;
353
409
  margin-bottom: $list-margin-bottom;
354
410
  list-style-position: $list-style-position;
411
+ line-height: $list-lineheight;
355
412
  }
356
413
 
357
414
  // List items
@@ -361,8 +418,8 @@ $abbr-underline: 1px dotted $black !default;
361
418
 
362
419
  // Unordered lists
363
420
  ul {
364
- list-style-type: $list-style-type;
365
421
  margin-#{$global-left}: $list-side-margin;
422
+ list-style-type: $list-style-type;
366
423
  }
367
424
 
368
425
  // Ordered lists
@@ -407,34 +464,43 @@ $abbr-underline: 1px dotted $black !default;
407
464
  color: $cite-color;
408
465
 
409
466
  &:before {
410
- content: '\2014 \0020';
467
+ content: $cite-pseudo-content;
411
468
  }
412
469
  }
413
470
 
414
471
  // Abbreviations
415
472
  abbr {
473
+ border-bottom: $abbr-underline;
416
474
  color: $body-font-color;
417
475
  cursor: help;
418
- border-bottom: $abbr-underline;
419
476
  }
420
477
 
478
+ // Figures
479
+ figure {
480
+ margin: 0;
481
+ }
482
+
421
483
  // Code
422
484
  code {
485
+ padding: $code-padding;
486
+
487
+ border: $code-border;
488
+ background-color: $code-background;
489
+
423
490
  font-family: $code-font-family;
424
491
  font-weight: $code-font-weight;
425
492
  color: $code-color;
426
- background-color: $code-background;
427
- border: $code-border;
428
- padding: $code-padding;
429
493
  }
430
494
 
431
495
  // Keystrokes
432
496
  kbd {
433
- padding: $keystroke-padding;
434
497
  margin: 0;
498
+ padding: $keystroke-padding;
499
+
435
500
  background-color: $keystroke-background;
436
- color: $keystroke-color;
501
+
437
502
  font-family: $keystroke-font;
503
+ color: $keystroke-color;
438
504
 
439
505
  @if has-value($keystroke-radius) {
440
506
  border-radius: $keystroke-radius;
@@ -48,6 +48,7 @@ $stat-font-size: 2.5rem !default;
48
48
  .subheader {
49
49
  margin-top: $subheader-margin-top;
50
50
  margin-bottom: $subheader-margin-bottom;
51
+
51
52
  font-weight: $subheader-font-weight;
52
53
  line-height: $subheader-lineheight;
53
54
  color: $subheader-color;
@@ -6,8 +6,9 @@
6
6
  /// @type Boolean
7
7
  /// @group global
8
8
  $print-transparent-backgrounds: true !default;
9
+ $print-hrefs: true !default;
9
10
 
10
- // scss-lint:disable all
11
+ // sass-lint:disable-all
11
12
 
12
13
  @mixin foundation-print-styles {
13
14
  .show-for-print { display: none !important; }
@@ -18,8 +19,9 @@ $print-transparent-backgrounds: true !default;
18
19
  background: transparent !important;
19
20
  }
20
21
 
21
- color: black !important; // Black prints faster: h5bp.com/s
22
22
  box-shadow: none !important;
23
+
24
+ color: black !important; // Black prints faster: h5bp.com/s
23
25
  text-shadow: none !important;
24
26
  }
25
27
 
@@ -36,7 +38,9 @@ $print-transparent-backgrounds: true !default;
36
38
  // Display the URL of a link after the text
37
39
  a,
38
40
  a:visited { text-decoration: underline;}
39
- a[href]:after { content: ' (' attr(href) ')'; }
41
+ @if $print-hrefs {
42
+ a[href]:after { content: ' (' attr(href) ')'; }
43
+ }
40
44
 
41
45
  // Don't display the URL for images or JavaScript/internal links
42
46
  .ir a:after,
@@ -6,8 +6,6 @@
6
6
  /// @group typography
7
7
  ////
8
8
 
9
- // scss-lint:disable DeclarationOrder
10
-
11
9
  // Base typography styles (tags only)
12
10
  @import 'base';
13
11
 
@@ -6,8 +6,6 @@
6
6
  /// @group breakpoints
7
7
  ////
8
8
 
9
- // scss-lint:disable ZeroUnit
10
-
11
9
  /// A list of named breakpoints. You can use these with the `breakpoint()` mixin to quickly create media queries.
12
10
  /// @type Map
13
11
  $breakpoints: (
@@ -18,8 +16,14 @@ $breakpoints: (
18
16
  xxlarge: 1440px,
19
17
  ) !default;
20
18
 
19
+ /// The largest named breakpoint in which to include print as a media type
20
+ /// @type Keyword
21
+ $print-breakpoint: large !default;
22
+
21
23
  $-zf-zero-breakpoint: small !default;
22
24
 
25
+ $-zf-breakpoints-keys: map-to-list($breakpoints, 'keys');
26
+
23
27
  @if nth(map-values($breakpoints), 1) != 0 {
24
28
  @error 'Your smallest breakpoint (defined in $breakpoints) must be set to "0".';
25
29
  }
@@ -137,6 +141,8 @@ $breakpoint-classes: (small medium large) !default;
137
141
  /// @output If the breakpoint is "0px and larger", outputs the content as-is. Otherwise, outputs the content wrapped in a media query.
138
142
  @mixin breakpoint($value) {
139
143
  $str: breakpoint($value);
144
+ $bp: index($-zf-breakpoints-keys, $value);
145
+ $pbp: index($-zf-breakpoints-keys, $print-breakpoint);
140
146
 
141
147
  // If $str is still an empty string, no media query is needed
142
148
  @if $str == '' {
@@ -145,8 +151,16 @@ $breakpoint-classes: (small medium large) !default;
145
151
 
146
152
  // Otherwise, wrap the content in a media query
147
153
  @else {
148
- @media screen and #{$str} {
149
- @content;
154
+ // For named breakpoints less than or equal to $print-breakpoint, add print to the media types
155
+ @if $bp != null and $bp <= $pbp {
156
+ @media print, screen and #{$str} {
157
+ @content;
158
+ }
159
+ }
160
+ @else {
161
+ @media screen and #{$str} {
162
+ @content;
163
+ }
150
164
  }
151
165
  }
152
166
  }
@@ -197,14 +211,22 @@ $breakpoint-classes: (small medium large) !default;
197
211
 
198
212
  }
199
213
 
200
- /// Get a value for a breakpoint from a responsive config map. If the config map has the key `$value`, the exact breakpoint value is returned. If the config map does *not* have the breakpoint, the value matching the next lowest breakpoint in the config map is returned.
214
+ /// Get a value for a breakpoint from a responsive config map or single value.
215
+ /// - If the config is a single value, return it regardless of `$value`.
216
+ /// - If the config is a map and has the key `$value`, the exact breakpoint value is returned.
217
+ /// - If the config is a map and does *not* have the breakpoint, the value matching the next lowest breakpoint in the config map is returned.
201
218
  /// @access private
202
219
  ///
203
- /// @param {Map} $map - Input config map.
220
+ /// @param {Number|Map} $map - Responsive config map or single value.
204
221
  /// @param {Keyword} $value - Breakpoint name to use.
205
222
  ///
206
223
  /// @return {Mixed} The corresponding breakpoint value.
207
224
  @function -zf-get-bp-val($map, $value) {
225
+ // If the given map is a single value, return it
226
+ @if type-of($map) == 'number' {
227
+ @return $map;
228
+ }
229
+
208
230
  // Check if the breakpoint name exists globally
209
231
  @if not map-has-key($breakpoints, $value) {
210
232
  @return null;
@@ -234,19 +256,6 @@ $breakpoint-classes: (small medium large) !default;
234
256
  }
235
257
  }
236
258
 
237
- // Legacy breakpoint variables
238
- // These will be removed in 6.3
239
- $small-up: null;
240
- $small-only: null;
241
- $medium-up: null;
242
- $medium-only: null;
243
- $large-up: null;
244
- $large-only: null;
245
- $xlarge-up: null;
246
- $xlarge-only: null;
247
- $xxlarge-up: null;
248
- $xxlarge-only: null;
249
-
250
259
  @if map-has-key($breakpoints, small) {
251
260
  $small-up: screen;
252
261
  $small-only: unquote('screen and #{breakpoint(small only)}');
@@ -2,31 +2,83 @@
2
2
  // foundation.zurb.com
3
3
  // Licensed under MIT Open Source
4
4
 
5
+ @import 'math';
6
+
5
7
  ////
6
8
  /// @group functions
7
9
  ////
8
10
 
9
- /// Checks the lightness of `$color`, and if it passes the `$threshold` of lightness, it returns the `$yes` color. Otherwise, it returns the `$no` color. Use this function to dynamically output a foreground color based on a given background color.
11
+ /// Checks the luminance of `$color`.
10
12
  ///
11
- /// @param {Color} $color - Color to check the lightness of.
12
- /// @param {Color} $yes [$black] - Color to return if `$color` is light.
13
- /// @param {Color} $no [$white] - Color to return if `$color` is dark.
14
- /// @param {Percentage} $threshold [60%] - Threshold of lightness to check against.
13
+ /// @param {Color} $color - Color to check the luminance of.
15
14
  ///
16
- /// @returns {Color} The $yes color or $no color.
17
- @function foreground($color, $yes: $black, $no: $white, $threshold: 60%) {
18
- @if $color == transparent {
19
- $color: $body-background;
15
+ /// @returns {Number} The luminance of `$color`.
16
+ @function color-luminance($color) {
17
+ // Adapted from: https://github.com/LeaVerou/contrast-ratio/blob/gh-pages/color.js
18
+ // Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
19
+ $rgba: red($color), green($color), blue($color);
20
+ $rgba2: ();
21
+
22
+ @for $i from 1 through 3 {
23
+ $rgb: nth($rgba, $i);
24
+ $rgb: $rgb / 255;
25
+
26
+ $rgb: if($rgb < 0.03928, $rgb / 12.92, pow(($rgb + 0.055) / 1.055, 2.4));
27
+
28
+ $rgba2: append($rgba2, $rgb);
20
29
  }
21
- @if (lightness($color) > $threshold) {
22
- @return $yes;
30
+
31
+ @return 0.2126 * nth($rgba2, 1) + 0.7152 * nth($rgba2, 2) + 0.0722 * nth($rgba2, 3);
32
+ }
33
+
34
+ /// Checks the contrast ratio of two colors.
35
+ ///
36
+ /// @param {Color} $color1 - First color to compare.
37
+ /// @param {Color} $color2 - Second color to compare.
38
+ ///
39
+ /// @returns {Number} The contrast ratio of the compared colors.
40
+ @function color-contrast($color1, $color2) {
41
+ // Adapted from: https://github.com/LeaVerou/contrast-ratio/blob/gh-pages/color.js
42
+ // Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
43
+ $luminance1: color-luminance($color1) + 0.05;
44
+ $luminance2: color-luminance($color2) + 0.05;
45
+ $ratio: $luminance1 / $luminance2;
46
+
47
+ @if $luminance2 > $luminance1 {
48
+ $ratio: 1 / $ratio;
23
49
  }
24
- @else {
25
- @return $no;
50
+
51
+ $ratio: round($ratio * 10) / 10;
52
+
53
+ @return $ratio;
54
+ }
55
+
56
+ /// Checks the luminance of `$base`, and returns the color from `$colors` (list of colors) that has the most contrast.
57
+ ///
58
+ /// @param {Color} $color1 - First color to compare.
59
+ /// @param {Color} $color2 - Second color to compare.
60
+ ///
61
+ /// @returns {Number} The contrast ratio of the compared colors.
62
+ @function color-pick-contrast($base, $colors: ($white, $black), $tolerance: 0) {
63
+ $contrast: color-contrast($base, nth($colors, 1));
64
+ $best: nth($colors, 1);
65
+
66
+ @for $i from 2 through length($colors) {
67
+ $current-contrast: color-contrast($base, nth($colors, $i));
68
+ @if ($current-contrast - $contrast > $tolerance) {
69
+ $contrast: color-contrast($base, nth($colors, $i));
70
+ $best: nth($colors, $i);
71
+ }
26
72
  }
73
+
74
+ @if ($contrast < 3) {
75
+ @warn "Contrast ratio of #{$best} on #{$base} is pretty bad, just #{$contrast}";
76
+ }
77
+
78
+ @return $best;
27
79
  }
28
80
 
29
- /// Scales a color to be lighter if it's light, or darker if it's dark. Use this function to tint a color appropriate to its lightness.
81
+ /// Scales a color to be darker if it's light, or lighter if it's dark. Use this function to tint a color appropriate to its lightness.
30
82
  ///
31
83
  /// @param {Color} $color - Color to scale.
32
84
  /// @param {Percentage} $scale [5%] - Amount to scale up or down.
@@ -48,12 +100,13 @@
48
100
  @function get-color($key) {
49
101
  @if map-has-key($foundation-palette, $key) {
50
102
  @return map-get($foundation-palette, $key);
51
- } @else {
103
+ }
104
+ @else {
52
105
  @error 'given $key is not available in $foundation-palette';
53
106
  }
54
107
  }
55
108
 
56
- /// Transfers the colors in the `$foundation-palette` variable into the legacy color variables, such as `$primary-color` and `$secondary-color`. Call this mixin below the Global section of your settings file to properly migrate your codebase.
109
+ /// Transfers the colors in the `$foundation-palette`map into variables, such as `$primary-color` and `$secondary-color`. Call this mixin below the Global section of your settings file to properly migrate your codebase.
57
110
  @mixin add-foundation-colors() {
58
111
  @if map-has-key($foundation-palette, primary) {
59
112
  $primary-color: map-get($foundation-palette, primary) !global;