Debian Codegraph @

debian/missing-sources/bourbon/app/assets/stylesheets/helpers/_directional-values.scss

raw
1 @charset "UTF-8";
2
3 /// Directional-property mixins are shorthands for writing properties like the following
4 ///
5 /// @ignore You can also use `false` instead of `null`.
6 ///
7 /// @param {List} $vals
8 /// List of directional values
9 ///
10 /// @example scss - Usage
11 /// .element {
12 /// @include border-style(dotted null);
13 /// @include margin(null 0 10px);
14 /// }
15 ///
16 /// @example css - CSS Output
17 /// .element {
18 /// border-bottom-style: dotted;
19 /// border-top-style: dotted;
20 /// margin-bottom: 10px;
21 /// margin-left: 0;
22 /// margin-right: 0;
23 /// }
24 ///
25 /// @require {function} contains-falsy
26 ///
27 /// @return {List}
28
29 @function collapse-directionals($vals) {
30 @if $output-bourbon-deprecation-warnings == true {
31 @warn "[Bourbon] [Deprecation] `collapse-directionals` is deprecated and " +
32 "will be removed in 5.0.0.";
33 }
34
35 $output: null;
36
37 $a: nth($vals, 1);
38 $b: if(length($vals) < 2, $a, nth($vals, 2));
39 $c: if(length($vals) < 3, $a, nth($vals, 3));
40 $d: if(length($vals) < 2, $a, nth($vals, if(length($vals) < 4, 2, 4)));
41
42 @if $a == 0 { $a: 0; }
43 @if $b == 0 { $b: 0; }
44 @if $c == 0 { $c: 0; }
45 @if $d == 0 { $d: 0; }
46
47 @if $a == $b and $a == $c and $a == $d { $output: $a; }
48 @else if $a == $c and $b == $d { $output: $a $b; }
49 @else if $b == $d { $output: $a $b $c; }
50 @else { $output: $a $b $c $d; }
51
52 @return $output;
53 }
54
55 /// Output directional properties, for instance `margin`.
56 ///
57 /// @access private
58 ///
59 /// @param {String} $pre
60 /// Prefix to use
61 /// @param {String} $suf
62 /// Suffix to use
63 /// @param {List} $vals
64 /// List of values
65 ///
66 /// @require {function} collapse-directionals
67 /// @require {function} contains-falsy
68
69 @mixin directional-property($pre, $suf, $vals) {
70 @include _bourbon-deprecate("directional-property");
71
72 $user-deprecation-warnings-setting: $output-bourbon-deprecation-warnings;
73 $output-bourbon-deprecation-warnings: false !global;
74
75 // Property Names
76 $top: $pre + "-top" + if($suf, "-#{$suf}", "");
77 $bottom: $pre + "-bottom" + if($suf, "-#{$suf}", "");
78 $left: $pre + "-left" + if($suf, "-#{$suf}", "");
79 $right: $pre + "-right" + if($suf, "-#{$suf}", "");
80 $all: $pre + if($suf, "-#{$suf}", "");
81
82 $vals: collapse-directionals($vals);
83
84 @if contains-falsy($vals) {
85 @if nth($vals, 1) { #{$top}: nth($vals, 1); }
86
87 @if length($vals) == 1 {
88 @if nth($vals, 1) { #{$right}: nth($vals, 1); }
89 } @else {
90 @if nth($vals, 2) { #{$right}: nth($vals, 2); }
91 }
92
93 @if length($vals) == 2 {
94 @if nth($vals, 1) { #{$bottom}: nth($vals, 1); }
95 @if nth($vals, 2) { #{$left}: nth($vals, 2); }
96 } @else if length($vals) == 3 {
97 @if nth($vals, 3) { #{$bottom}: nth($vals, 3); }
98 @if nth($vals, 2) { #{$left}: nth($vals, 2); }
99 } @else if length($vals) == 4 {
100 @if nth($vals, 3) { #{$bottom}: nth($vals, 3); }
101 @if nth($vals, 4) { #{$left}: nth($vals, 4); }
102 }
103 } @else {
104 #{$all}: $vals;
105 }
106
107 $output-bourbon-deprecation-warnings: $user-deprecation-warnings-setting !global;
108 }