gerillass 2.3.1 → 3.0.0

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.
@@ -1,36 +1,46 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  @use "sass:list";
4
- @use "sass:map";
5
- @use "sass:math";
6
4
  @use "sass:meta";
7
- @use "../maps/map-for-directions" as *;
8
- @use "../internal/color-stops-problem" as *;
5
+ @use "sass:string";
6
+ @use "../internal/gradient" as *;
9
7
 
10
- @mixin text-gradient($direction, $colors) {
11
- // A stop the browser does not keep drops the whole gradient, and with it the
12
- // text, which this mixin makes transparent; see
13
- // scss/internal/_color-stops-problem.scss.
14
- $problem: colorStopsProblem($colors);
15
- @if $problem {
16
- @error "`#{meta.inspect($colors)}` is not a valid $colors for `text-gradient`: #{$problem}. A browser drops the whole gradient, and the transparent text with it.";
17
- }
18
- $list: ();
19
- @for $i from 1 through list.length($colors) {
20
- $list: list.append($list, list.nth($colors, $i), comma);
21
- }
22
- @if map.has-key($map-for-directions, $direction) {
23
- background: linear-gradient(
24
- map.get($map-for-directions, $direction),
25
- $list
26
- );
27
- } @else if not map.has-key($map-for-directions, $direction) {
28
- @if meta.type-of($direction) != "number" or not list.index("deg", math.unit($direction)) {
29
- @error "`#{$direction}` is not a valid $direction for `text-gradient`. Pass an angle such as `45deg`, or one of: #{map.keys($map-for-directions)}.";
30
- } @else {
31
- background: linear-gradient($direction, $list);
8
+ // Fills the letters with a gradient: the gradient mixin's arguments, and
9
+ // background-clip: text. The gradient is built and checked in
10
+ // scss/internal/_gradient.scss.
11
+ //
12
+ // The colours come first since 3.0.0, as in gradient, so a direction, a type
13
+ // and a colour space can all be left out. A call in the old order,
14
+ // `text-gradient("top", (red, blue))`, would otherwise fail on `"top"` not
15
+ // being a colour, so it is caught and answered with the new form.
16
+ //
17
+ // It still writes the background shorthand rather than background-image, so a
18
+ // call in the new order compiles to exactly what the same call compiled to in
19
+ // the old order.
20
+ @mixin text-gradient(
21
+ $colors,
22
+ $type: linear,
23
+ $direction: null,
24
+ $shape: null,
25
+ $position: null,
26
+ $from: null,
27
+ $in: null,
28
+ $repeating: false
29
+ ) {
30
+ @if gradientDirection($colors) != null and not list.index("linear" "radial" "conic", string.to-lower-case("#{$type}")) {
31
+ $written: meta.inspect($type);
32
+ @if list.separator($type) == "comma" {
33
+ $written: "(#{$written})";
32
34
  }
35
+ @error "`text-gradient` takes the colours first since 3.0.0. Write `text-gradient(#{$written}, $direction: #{meta.inspect($colors)})`.";
36
+ }
37
+ $value: gradientOf($colors, $type, $direction, $shape, $position, $from, $in, $repeating, $member: "text-gradient");
38
+ // Written without the space first, as the gradient mixin does, for a browser
39
+ // that does not know `in`.
40
+ @if $in != null {
41
+ background: gradientOf($colors, $type, $direction, $shape, $position, $from, null, $repeating, $member: "text-gradient", $warn: false);
33
42
  }
43
+ background: $value;
34
44
  -webkit-background-clip: text;
35
45
  -webkit-text-fill-color: transparent;
36
46
  background-clip: text;
@@ -0,0 +1,24 @@
1
+ @charset "UTF-8";
2
+
3
+ @use "../internal/gradient" as *;
4
+
5
+ // The gradient mixin's gradient as a value, for where a mixin cannot write the
6
+ // whole declaration: layered with an image in one background-image, or as a
7
+ // mask-image or border-image. It takes the same arguments and refuses the same
8
+ // input; see scss/internal/_gradient.scss.
9
+ //
10
+ // A function returns one value, so unlike the mixin it cannot write a fallback
11
+ // before a gradient with $in. Write one yourself if an old browser matters:
12
+ // the same call with $in left out, in a declaration before it.
13
+ @function gradientValue(
14
+ $colors,
15
+ $type: linear,
16
+ $direction: null,
17
+ $shape: null,
18
+ $position: null,
19
+ $from: null,
20
+ $in: null,
21
+ $repeating: false
22
+ ) {
23
+ @return gradientOf($colors, $type, $direction, $shape, $position, $from, $in, $repeating, $member: "gradientValue");
24
+ }
@@ -8,6 +8,7 @@
8
8
  @forward "fluid";
9
9
  @forward "font-sizer";
10
10
  @forward "font-source";
11
+ @forward "gradient-value";
11
12
  @forward "is-color";
12
13
  @forward "is-gutter";
13
14
  @forward "is-number";
@@ -1,33 +0,0 @@
1
- @charset "UTF-8";
2
-
3
- @use "sass:list";
4
- @use "sass:map";
5
- @use "sass:math";
6
- @use "sass:meta";
7
- @use "../maps/map-for-directions" as *;
8
- @use "../internal/color-stops-problem" as *;
9
-
10
- @mixin linear-gradient($direction, $colors) {
11
- // A stop the browser does not keep drops the whole gradient; see
12
- // scss/internal/_color-stops-problem.scss for what was measured.
13
- $problem: colorStopsProblem($colors);
14
- @if $problem {
15
- @error "`#{meta.inspect($colors)}` is not a valid $colors for `linear-gradient`: #{$problem}. A browser drops the whole gradient.";
16
- }
17
- $list: ();
18
- @for $i from 1 through list.length($colors) {
19
- $list: list.append($list, list.nth($colors, $i), comma);
20
- }
21
- @if map.has-key($map-for-directions, $direction) {
22
- background: linear-gradient(
23
- map.get($map-for-directions, $direction),
24
- $list
25
- );
26
- } @else if not map.has-key($map-for-directions, $direction) {
27
- @if meta.type-of($direction) != "number" or not list.index("deg", math.unit($direction)) {
28
- @error "`#{$direction}` is not a valid $direction for `linear-gradient`. Pass an angle such as `45deg`, or one of: #{map.keys($map-for-directions)}.";
29
- } @else {
30
- background: linear-gradient($direction, $list);
31
- }
32
- }
33
- }
@@ -1,184 +0,0 @@
1
- @charset "UTF-8";
2
-
3
- @use "sass:list";
4
- @use "sass:map";
5
- @use "sass:meta";
6
- @use "sass:string";
7
- @use "../maps/map-for-positions" as *;
8
- @use "../internal/is-condition-value" as *;
9
- @use "../internal/words" as *;
10
- @use "../internal/color-stops-problem" as *;
11
-
12
- // The mixin writes `radial-gradient($shape $position, ...)`, so $shape carries
13
- // the shape and may carry a size, and a $position that is not a key from
14
- // $map-for-positions carries a size, `at` and a position, or both. Each is
15
- // checked against what Chrome 152 kept in `background-image`, in any case:
16
- //
17
- // - kept: circle, ellipse, an extent keyword such as closest-side, a length
18
- // (`circle 10px`, `10px`), two lengths or percentages (`ellipse 10% 20%`),
19
- // `at` followed by one or two keywords from left, center, right, top and
20
- // bottom or up to four keywords and lengths (`at left 10px top 20px`), and
21
- // var() or calc() anywhere;
22
- // - dropped: a word outside those (`huge`, `auto`, `inherit`), a percentage or a
23
- // negative length as a circle's size (`circle 10%`, `circle -10px`), the
24
- // shape twice (`circle circle`), four keywords after `at`, and the logical
25
- // keywords `at x-start` and `at block-start`.
26
- //
27
- // It checks each part on its own, so a shape in one argument and a size in the
28
- // other that do not fit together, such as `ellipse` with a single length, are
29
- // not caught.
30
- $-extents: "closest-side" "closest-corner" "farthest-side" "farthest-corner";
31
- $-places: "left" "center" "right" "top" "bottom";
32
-
33
- // "extent", "length" or "percentage" for a word that can size the gradient,
34
- // or null.
35
- @function -size-kind($word) {
36
- $lower: string.to-lower-case("#{$word}");
37
- @if list.index($-extents, $lower) {
38
- @return "extent";
39
- }
40
- @if string.index($lower, "-") == 1 {
41
- @return null;
42
- }
43
- @if isConditionValue($word, "length") {
44
- @return "length";
45
- }
46
- @if isConditionValue($word, "length-percentage") {
47
- @return "percentage";
48
- }
49
- @return null;
50
- }
51
-
52
- // Checks the size words before `at`. $shape is the shape named, or null.
53
- @function -size-problem($words, $shape) {
54
- $extents: 0;
55
- $lengths: 0;
56
- $percentages: 0;
57
- @each $word in $words {
58
- $kind: -size-kind($word);
59
- @if $kind == null {
60
- @return "`#{$word}` is not a shape, an extent keyword such as `closest-side`, or a length";
61
- } @else if $kind == "extent" {
62
- $extents: $extents + 1;
63
- } @else if $kind == "length" {
64
- $lengths: $lengths + 1;
65
- } @else {
66
- $percentages: $percentages + 1;
67
- }
68
- }
69
- $sizes: $lengths + $percentages;
70
- @if $extents > 1 or ($extents == 1 and $sizes > 0) {
71
- @return "it gives the size twice";
72
- }
73
- @if $sizes > 2 {
74
- @return "a size is one length or two";
75
- }
76
- @if $sizes == 1 and ($percentages == 1 or $shape == "ellipse") {
77
- @return "one size is a circle's radius, which is a length and not a percentage";
78
- }
79
- @if $sizes == 2 and $shape == "circle" {
80
- @return "a circle takes one length, not two";
81
- }
82
- @return null;
83
- }
84
-
85
- @function -shape-problem($shape) {
86
- @if string.index($shape, "(") {
87
- @return null;
88
- }
89
- $named: null;
90
- $sizes: ();
91
- @each $word in wordsOf($shape) {
92
- $lower: string.to-lower-case($word);
93
- @if list.index("circle" "ellipse", $lower) {
94
- @if $named {
95
- @return "it names the shape twice";
96
- }
97
- $named: $lower;
98
- } @else {
99
- $sizes: list.append($sizes, $word);
100
- }
101
- }
102
- @return -size-problem($sizes, $named);
103
- }
104
-
105
- @function -position-problem($position) {
106
- @if map.has-key($map-for-positions, $position) or string.index($position, "(") {
107
- @return null;
108
- }
109
- $sizes: ();
110
- $places: ();
111
- $after-at: false;
112
- @each $word in wordsOf($position) {
113
- $lower: string.to-lower-case($word);
114
- @if $lower == "at" {
115
- @if $after-at {
116
- @return "it has `at` twice";
117
- }
118
- $after-at: true;
119
- } @else if $after-at {
120
- $places: list.append($places, $word);
121
- } @else if list.index("circle" "ellipse", $lower) {
122
- @return "the shape goes in $shape, not $position";
123
- } @else {
124
- $sizes: list.append($sizes, $word);
125
- }
126
- }
127
- $problem: -size-problem($sizes, null);
128
- @if $problem {
129
- @return "#{$problem}. Pass a position name such as `center` or `top-left`, an extent keyword such as `closest-side`, or `at` followed by a position, such as `at 30% 40%`";
130
- }
131
- @if $after-at and list.length($places) == 0 {
132
- @return "`at` needs a position after it, such as `at center`";
133
- }
134
- @if list.length($places) > 4 {
135
- @return "a position takes at most four values";
136
- }
137
- $keywords: 0;
138
- @each $word in $places {
139
- @if list.index($-places, string.to-lower-case($word)) {
140
- $keywords: $keywords + 1;
141
- } @else if not isConditionValue($word, "length-percentage") {
142
- @return "`#{$word}` is not a position; after `at` pass left, center, right, top, bottom or a length";
143
- }
144
- }
145
- @if $keywords > 2 and $keywords == list.length($places) {
146
- @return "a position of keywords alone takes at most two, such as `at top left`";
147
- }
148
- @return null;
149
- }
150
-
151
- @mixin radial-gradient($shape, $position, $colors) {
152
- @if meta.type-of($shape) != "string" {
153
- @error "`#{$shape}` is not a valid $shape for `radial-gradient`. Pass `circle` or `ellipse`.";
154
- }
155
- @if meta.type-of($position) != "string" {
156
- @error "`#{$position}` is not a valid $position for `radial-gradient`. Pass a position name such as `center` or `top-left`, or a raw CSS position as a string.";
157
- }
158
- $list: ();
159
- $shape: string.unquote($shape);
160
- $position: string.unquote($position);
161
- $problem: -shape-problem($shape);
162
- @if $problem {
163
- @error "`#{$shape}` is not a valid $shape for `radial-gradient`: #{$problem}. A browser drops the whole gradient.";
164
- }
165
- $problem: -position-problem($position);
166
- @if $problem {
167
- @error "`#{$position}` is not a valid $position for `radial-gradient`: #{$problem}. A browser drops the whole gradient.";
168
- }
169
- $problem: colorStopsProblem($colors);
170
- @if $problem {
171
- @error "`#{meta.inspect($colors)}` is not a valid $colors for `radial-gradient`: #{$problem}. A browser drops the whole gradient.";
172
- }
173
- @for $i from 1 through list.length($colors) {
174
- $list: list.append($list, list.nth($colors, $i), comma);
175
- }
176
- @if map.has-key($map-for-positions, $position) {
177
- background: radial-gradient(
178
- $shape map.get($map-for-positions, $position),
179
- $list
180
- );
181
- } @else if not map.has-key($map-for-positions, $position) {
182
- background: radial-gradient($shape $position, $list);
183
- }
184
- }