bourbon 5.0.0.beta.6 → 5.0.0.beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +11 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
  4. data/CHANGELOG.md +32 -1
  5. data/README.md +111 -44
  6. data/RELEASING.md +3 -2
  7. data/bourbon.gemspec +3 -5
  8. data/bower.json +2 -2
  9. data/core/_bourbon.scss +8 -6
  10. data/core/bourbon/library/_border-color.scss +8 -7
  11. data/core/bourbon/library/_border-radius.scss +12 -12
  12. data/core/bourbon/library/_border-style.scss +8 -7
  13. data/core/bourbon/library/_border-width.scss +8 -7
  14. data/core/bourbon/library/_buttons.scss +4 -4
  15. data/core/bourbon/library/_clearfix.scss +2 -2
  16. data/core/bourbon/library/_contrast-switch.scss +36 -14
  17. data/core/bourbon/library/_ellipsis.scss +1 -1
  18. data/core/bourbon/library/_font-face.scss +5 -4
  19. data/core/bourbon/library/_font-stacks.scss +170 -8
  20. data/core/bourbon/library/_hide-text.scss +2 -2
  21. data/core/bourbon/library/_hide-visually.scss +4 -2
  22. data/core/bourbon/library/_margin.scss +17 -14
  23. data/core/bourbon/library/_modular-scale.scss +28 -20
  24. data/core/bourbon/library/_overflow-wrap.scss +24 -0
  25. data/core/bourbon/library/_padding.scss +12 -10
  26. data/core/bourbon/library/_position.scss +30 -20
  27. data/core/bourbon/library/_prefixer.scss +1 -1
  28. data/core/bourbon/library/_shade.scss +1 -1
  29. data/core/bourbon/library/_size.scss +7 -5
  30. data/core/bourbon/library/_strip-unit.scss +1 -1
  31. data/core/bourbon/library/_text-inputs.scss +5 -5
  32. data/core/bourbon/library/_timing-functions.scss +1 -1
  33. data/core/bourbon/library/_tint.scss +1 -1
  34. data/core/bourbon/library/_triangle.scss +1 -1
  35. data/core/bourbon/library/_value-prefixer.scss +1 -1
  36. data/core/bourbon/settings/_settings.scss +28 -4
  37. data/core/bourbon/utilities/{_collapse-directionals.scss → _compact-shorthand.scss} +6 -18
  38. data/core/bourbon/utilities/_contrast-ratio.scss +31 -0
  39. data/core/bourbon/utilities/_directional-property.scss +71 -0
  40. data/core/bourbon/utilities/_font-source-declaration.scss +1 -1
  41. data/core/bourbon/utilities/_gamma.scss +21 -0
  42. data/core/bourbon/utilities/_lightness.scss +24 -0
  43. data/core/bourbon/utilities/{_unpack.scss → _unpack-shorthand.scss} +4 -4
  44. data/core/bourbon/validators/_contains-falsy.scss +1 -1
  45. data/lib/bourbon/version.rb +1 -1
  46. data/package.json +2 -2
  47. data/spec/bourbon/library/font_stacks_spec.rb +6 -4
  48. data/spec/bourbon/library/hide_visually_spec.rb +2 -0
  49. data/spec/bourbon/library/overflow_wrap_spec.rb +27 -0
  50. data/spec/bourbon/utilities/compact_shorthand_spec.rb +30 -0
  51. data/spec/bourbon/utilities/{directional_values_spec.rb → directional_property_spec.rb} +9 -2
  52. data/spec/fixtures/library/overflow-wrap.scss +9 -0
  53. data/spec/fixtures/library/position.scss +0 -4
  54. data/spec/fixtures/utilities/compact-shorthand.scss +21 -0
  55. data/spec/fixtures/utilities/{directional-values.scss → directional-property.scss} +4 -0
  56. data/spec/fixtures/utilities/unpack.scss +4 -4
  57. metadata +26 -28
  58. data/core/bourbon/library/_word-wrap.scss +0 -29
  59. data/core/bourbon/utilities/_directional-values.scss +0 -58
  60. data/core/bourbon/validators/_is-light.scss +0 -23
  61. data/spec/bourbon/library/word_wrap_spec.rb +0 -29
  62. data/spec/bourbon/utilities/collapse_directionals.rb +0 -25
  63. data/spec/bourbon/validators/is_light_spec.rb +0 -37
  64. data/spec/fixtures/library/word-wrap.scss +0 -9
  65. data/spec/fixtures/utilities/collapse-directionals.scss +0 -17
  66. data/spec/fixtures/validators/is-light.scss +0 -29
@@ -23,7 +23,7 @@
23
23
  /// }
24
24
  /// }
25
25
  ///
26
- /// @example css
26
+ /// // CSS Output
27
27
  /// .element::before {
28
28
  /// border-style: solid;
29
29
  /// height: 0;
@@ -16,7 +16,7 @@
16
16
  /// @include value-prefixer(cursor, grab, ("webkit", "moz"));
17
17
  /// }
18
18
  ///
19
- /// @example css
19
+ /// // CSS Output
20
20
  /// .element {
21
21
  /// cursor: -webkit-grab;
22
22
  /// cursor: -moz-grab;
@@ -1,6 +1,7 @@
1
1
  @charset "UTF-8";
2
2
 
3
- /// Default Bourbon configuration settings.
3
+ /// Default global Bourbon settings. Values in this map are overwritten by any
4
+ /// values set in the `$bourbon` map.
4
5
  ///
5
6
  /// @type map
6
7
  ///
@@ -20,8 +21,9 @@
20
21
  /// Global base ratio for the `modular-scale` function.
21
22
  ///
22
23
  /// @property {boolean} rails-asset-pipeline [false]
23
- /// Enable or disable the `$asset-pipeline` variable for all functions that
24
- /// accept it.
24
+ /// Set this to `true` when using the Rails Asset Pipeline and Bourbon will
25
+ /// write asset paths using
26
+ /// [sass-rails’ asset helpers](https://github.com/rails/sass-rails#asset-helpers).
25
27
  ///
26
28
  /// @access private
27
29
 
@@ -34,10 +36,32 @@ $_bourbon-defaults: (
34
36
  "rails-asset-pipeline": false,
35
37
  );
36
38
 
37
- /// User overrides of Bourbon configuration settings.
39
+ /// Global Bourbon settings.
40
+ ///
41
+ /// @name Settings
38
42
  ///
39
43
  /// @type map
40
44
  ///
45
+ /// @property {color} contrast-switch-dark-color [#000]
46
+ /// Global dark color for the `contrast-switch` function.
47
+ ///
48
+ /// @property {color} contrast-switch-light-color [#fff]
49
+ /// Global light color for the `contrast-switch` function.
50
+ ///
51
+ /// @property {list} global-font-file-formats [("ttf", "woff2", "woff")]
52
+ /// Global font file formats for the `font-face` mixin.
53
+ ///
54
+ /// @property {number (with unit)} modular-scale-base [1em]
55
+ /// Global base value for the `modular-scale` function.
56
+ ///
57
+ /// @property {number (unitless)} modular-scale-ratio [$major-third (1.25)]
58
+ /// Global base ratio for the `modular-scale` function.
59
+ ///
60
+ /// @property {boolean} rails-asset-pipeline [false]
61
+ /// Set this to `true` when using the Rails Asset Pipeline and Bourbon will
62
+ /// write asset paths using
63
+ /// [sass-rails’ asset helpers](https://github.com/rails/sass-rails#asset-helpers).
64
+ ///
41
65
  /// @example scss
42
66
  /// $bourbon: (
43
67
  /// "contrast-switch-dark-color": #000,
@@ -2,34 +2,22 @@
2
2
 
3
3
  // scss-lint:disable ElsePlacement
4
4
 
5
- /// Directional-property mixins are shorthands for writing properties like
6
- /// the following.
7
- ///
8
- /// @ignore You can also use `false` instead of `null`.
5
+ /// Transforms shorthand to its shortest possible form.
9
6
  ///
10
7
  /// @argument {list} $values
11
8
  /// List of directional values.
12
9
  ///
13
- /// @example scss - Usage
14
- /// .element {
15
- /// @include border-style(dotted null);
16
- /// @include margin(null 0 10px);
17
- /// }
10
+ /// @example scss
11
+ /// $values: _compact-shorthand(10px 20px 10px 20px);
18
12
  ///
19
- /// @example css - CSS Output
20
- /// .element {
21
- /// border-bottom-style: dotted;
22
- /// border-top-style: dotted;
23
- /// margin-bottom: 10px;
24
- /// margin-left: 0;
25
- /// margin-right: 0;
26
- /// }
13
+ /// // Output
14
+ /// $values: 10px 20px;
27
15
  ///
28
16
  /// @return {list}
29
17
  ///
30
18
  /// @access private
31
19
 
32
- @function _collapse-directionals($values) {
20
+ @function _compact-shorthand($values) {
33
21
  $output: null;
34
22
 
35
23
  $a: nth($values, 1);
@@ -0,0 +1,31 @@
1
+ @charset "UTF-8";
2
+
3
+ /// Programatically determines the contrast ratio between two colors.
4
+ ///
5
+ /// Note that the alpha channel is ignored.
6
+ ///
7
+ /// @link https://goo.gl/54htLV
8
+ ///
9
+ /// @argument {color (hex)} $color-1
10
+ ///
11
+ /// @argument {color (hex)} $color-2
12
+ ///
13
+ /// @return {number (1-21)}
14
+ ///
15
+ /// @example scss
16
+ /// _contrast-ratio(black, white)
17
+ ///
18
+ /// @require {function} _lightness
19
+ ///
20
+ /// @access private
21
+
22
+ @function _contrast-ratio($color-1, $color-2) {
23
+ $-local-lightness-1: _lightness($color-1) + 0.05;
24
+ $-local-lightness-2: _lightness($color-2) + 0.05;
25
+
26
+ @if $-local-lightness-1 > $-local-lightness-2 {
27
+ @return $-local-lightness-1 / $-local-lightness-2;
28
+ } @else {
29
+ @return $-local-lightness-2 / $-local-lightness-1;
30
+ }
31
+ }
@@ -0,0 +1,71 @@
1
+ @charset "UTF-8";
2
+
3
+ // scss-lint:disable SpaceAroundOperator
4
+
5
+ /// Builds directional properties by parsing CSS shorthand values. For example,
6
+ /// a value of `10px null` will output top and bottom directional properties,
7
+ /// but the `null` skips left and right from being output.
8
+ ///
9
+ /// @argument {string} $property
10
+ /// Base property.
11
+ ///
12
+ /// @argument {string} $suffix
13
+ /// Suffix to append. Use `null` to omit.
14
+ ///
15
+ /// @argument {list} $values
16
+ /// List of values to set for the property.
17
+ ///
18
+ /// @example scss
19
+ /// .element {
20
+ /// @include _directional-property(border, width, null 5px);
21
+ /// }
22
+ ///
23
+ /// // CSS Output
24
+ /// .element {
25
+ /// border-right-width: 5px;
26
+ /// border-left-width: 5px;
27
+ /// }
28
+ ///
29
+ /// @require {function} _compact-shorthand
30
+ ///
31
+ /// @require {function} _contains-falsy
32
+ ///
33
+ /// @access private
34
+
35
+ @mixin _directional-property(
36
+ $property,
37
+ $suffix,
38
+ $values
39
+ ) {
40
+
41
+ $top: $property + "-top" + if($suffix, "-#{$suffix}", "");
42
+ $bottom: $property + "-bottom" + if($suffix, "-#{$suffix}", "");
43
+ $left: $property + "-left" + if($suffix, "-#{$suffix}", "");
44
+ $right: $property + "-right" + if($suffix, "-#{$suffix}", "");
45
+ $all: $property + if($suffix, "-#{$suffix}", "");
46
+
47
+ $values: _compact-shorthand($values);
48
+
49
+ @if _contains-falsy($values) {
50
+ @if nth($values, 1) { #{$top}: nth($values, 1); }
51
+
52
+ @if length($values) == 1 {
53
+ @if nth($values, 1) { #{$right}: nth($values, 1); }
54
+ } @else {
55
+ @if nth($values, 2) { #{$right}: nth($values, 2); }
56
+ }
57
+
58
+ @if length($values) == 2 {
59
+ @if nth($values, 1) { #{$bottom}: nth($values, 1); }
60
+ @if nth($values, 2) { #{$left}: nth($values, 2); }
61
+ } @else if length($values) == 3 {
62
+ @if nth($values, 3) { #{$bottom}: nth($values, 3); }
63
+ @if nth($values, 2) { #{$left}: nth($values, 2); }
64
+ } @else if length($values) == 4 {
65
+ @if nth($values, 3) { #{$bottom}: nth($values, 3); }
66
+ @if nth($values, 4) { #{$left}: nth($values, 4); }
67
+ }
68
+ } @else {
69
+ #{$all}: $values;
70
+ }
71
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  /// Builds the `src` list for an `@font-face` declaration.
4
4
  ///
5
- /// @link http://goo.gl/Ru1bKP
5
+ /// @link https://goo.gl/Ru1bKP
6
6
  ///
7
7
  /// @argument {string} $font-family
8
8
  ///
@@ -0,0 +1,21 @@
1
+ @charset "UTF-8";
2
+
3
+ /// Performs gamma correction on a single color channel.
4
+ ///
5
+ /// Note that Sass does not have a `pow()` function, so the calculation
6
+ /// is approximate.
7
+ ///
8
+ /// @argument {number (0-1)} $channel
9
+ ///
10
+ /// @return {number (0-1)}
11
+ ///
12
+ /// @access private
13
+
14
+ @function _gamma($channel) {
15
+ @if $channel < 0.03928 {
16
+ @return $channel / 12.92;
17
+ } @else {
18
+ $c: ($channel + 0.055) / 1.055;
19
+ @return (133 * $c * $c * $c + 155 * $c * $c) / 288;
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ @charset "UTF-8";
2
+
3
+ /// Programatically determines the lightness of a color.
4
+ ///
5
+ /// @argument {color (hex)} $hex-color
6
+ ///
7
+ /// @return {number (0-1)}
8
+ ///
9
+ /// @example scss
10
+ /// _lightness($color)
11
+ ///
12
+ /// @access private
13
+
14
+ @function _lightness($hex-color) {
15
+ $-local-red-raw: red(rgba($hex-color, 1));
16
+ $-local-green-raw: green(rgba($hex-color, 1));
17
+ $-local-blue-raw: blue(rgba($hex-color, 1));
18
+
19
+ $-local-red: _gamma($-local-red-raw / 255);
20
+ $-local-green: _gamma($-local-green-raw / 255);
21
+ $-local-blue: _gamma($-local-blue-raw / 255);
22
+
23
+ @return $-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722;
24
+ }
@@ -1,22 +1,22 @@
1
1
  @charset "UTF-8";
2
2
 
3
- /// Converts shorthand to the 4-value syntax.
3
+ /// Transforms shorthand that can range from 1-to-4 values to be 4 values.
4
4
  ///
5
5
  /// @argument {list} $shorthand
6
6
  ///
7
7
  /// @example scss
8
8
  /// .element {
9
- /// margin: _unpack(1em 2em);
9
+ /// margin: _unpack-shorthand(1em 2em);
10
10
  /// }
11
11
  ///
12
- /// @example css
12
+ /// // CSS Output
13
13
  /// .element {
14
14
  /// margin: 1em 2em 1em 2em;
15
15
  /// }
16
16
  ///
17
17
  /// @access private
18
18
 
19
- @function _unpack($shorthand) {
19
+ @function _unpack-shorthand($shorthand) {
20
20
  @if length($shorthand) == 1 {
21
21
  @return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1);
22
22
  } @else if length($shorthand) == 2 {
@@ -1,6 +1,6 @@
1
1
  @charset "UTF-8";
2
2
 
3
- /// Checks if a list does not contains a value.
3
+ /// Checks if a list does not contain any values.
4
4
  ///
5
5
  /// @argument {list} $list
6
6
  /// The list to check against.
@@ -1,3 +1,3 @@
1
1
  module Bourbon
2
- VERSION = "5.0.0.beta.6"
2
+ VERSION = "5.0.0.beta.7"
3
3
  end
@@ -6,7 +6,7 @@
6
6
  "bugs": {
7
7
  "url": "https://github.com/thoughtbot/bourbon/issues"
8
8
  },
9
- "description": "A simple and lightweight mixin library for Sass.",
9
+ "description": "A lightweight Sass tool set.",
10
10
  "eyeglass": {
11
11
  "needs": "*",
12
12
  "exports": "eyeglass-exports.js"
@@ -29,5 +29,5 @@
29
29
  "scripts": {
30
30
  "test": "bundle exec rake"
31
31
  },
32
- "version": "5.0.0-beta.6"
32
+ "version": "5.0.0-beta.7"
33
33
  }
@@ -19,11 +19,13 @@ describe "font-stacks" do
19
19
  consolas = '"Consolas", "monaco", monospace'
20
20
  courier_new = '"Courier New", "Courier", "Lucida Sans Typewriter", ' +
21
21
  '"Lucida Typewriter", monospace'
22
- monaco = '"monaco", "Consolas", "Lucida Console", monospace'
22
+ monaco = '"Monaco", "Consolas", "Lucida Console", monospace'
23
23
 
24
- system = '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", ' +
25
- '"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", ' +
26
- '"Helvetica Neue", sans-serif'
24
+ system = '-apple-system, BlinkMacSystemFont, "Avenir Next", "Avenir", ' +
25
+ '"Segoe UI", "Lucida Grande", "Helvetica Neue", "Helvetica", ' +
26
+ '"Fira Sans", "Roboto", "Noto", "Droid Sans", "Cantarell", ' +
27
+ '"Oxygen", "Ubuntu", "Franklin Gothic Medium", ' +
28
+ '"Century Gothic", "Liberation Sans", sans-serif'
27
29
 
28
30
  expect(".helvetica").to have_value(helvetica)
29
31
  expect(".lucida-grande").to have_value(lucida_grande)
@@ -14,6 +14,7 @@ describe "hide-visually" do
14
14
  "overflow: hidden; " +
15
15
  "padding: 0; " +
16
16
  "position: absolute; " +
17
+ "white-space: nowrap; " +
17
18
  "width: 1px;"
18
19
 
19
20
  expect(".hide-visually").to have_ruleset(ruleset)
@@ -27,6 +28,7 @@ describe "hide-visually" do
27
28
  "height: auto; " +
28
29
  "overflow: visible; " +
29
30
  "position: static; " +
31
+ "white-space: inherit; " +
30
32
  "width: auto;"
31
33
 
32
34
  expect(".hide-visually--unhide").to have_ruleset(ruleset)
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe "overflow-wrap" do
4
+ before(:all) do
5
+ ParserSupport.parse_file("library/overflow-wrap")
6
+ end
7
+
8
+ context "called on element" do
9
+ it "adds overflow-wrap and word-wrap" do
10
+ input = ".overflow-wrap"
11
+ ruleset = "word-wrap: break-word; " +
12
+ "overflow-wrap: break-word;"
13
+
14
+ expect(input).to have_ruleset(ruleset)
15
+ end
16
+ end
17
+
18
+ context "called on element with normal" do
19
+ it "sets values as normal" do
20
+ input = ".overflow-wrap-normal"
21
+ ruleset = "word-wrap: normal; " +
22
+ "overflow-wrap: normal;"
23
+
24
+ expect(input).to have_ruleset(ruleset)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe "compact-shorthand" do
4
+ before(:all) do
5
+ ParserSupport.parse_file("utilities/compact-shorthand")
6
+ end
7
+
8
+ context "compact-shorthand" do
9
+ it "returns four values unaltered" do
10
+ expect(".four-values-a").to have_rule("padding: 10px 20px 30px 40px")
11
+ end
12
+
13
+ it "returns four values when the left and right values are not equal" do
14
+ expect(".four-values-b").to have_rule("padding: 5px 10px 5px 20px")
15
+ end
16
+
17
+ it "compacts four values to two values when the top/bottom and " +
18
+ "left/right values are equal" do
19
+ expect(".two-values").to have_rule("padding: 50px 100px")
20
+ end
21
+
22
+ it "compacts four values to one value when they all match" do
23
+ expect(".one-value").to have_rule("padding: 10px")
24
+ end
25
+
26
+ it "skips null values" do
27
+ expect(".null-value").to have_rule("padding: 10px 20px")
28
+ end
29
+ end
30
+ end
@@ -1,8 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "directional-values" do
3
+ describe "directional-property" do
4
4
  before(:all) do
5
- ParserSupport.parse_file("utilities/directional-values")
5
+ ParserSupport.parse_file("utilities/directional-property")
6
6
  end
7
7
 
8
8
  context "directional-property" do
@@ -17,5 +17,12 @@ describe "directional-values" do
17
17
  it "returns property and value with vertical and horizontal values" do
18
18
  expect(".border-color").to have_rule("border-color: #fff #000")
19
19
  end
20
+
21
+ it "returns properties for top and bottom margin" do
22
+ ruleset = "margin-top: 20px; " +
23
+ "margin-bottom: 10px;"
24
+
25
+ expect(".margin-null").to have_ruleset(ruleset)
26
+ end
20
27
  end
21
28
  end