gerillass 2.1.0 → 2.1.1

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,17 +1,63 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  @use "sass:list";
4
- @use "sass:math";
5
4
  @use "sass:meta";
6
5
  @use "sass:string";
7
6
 
7
+ // An image path goes into url(). A var(), url(), image-set() or gradient is
8
+ // already an image, and wrapping it produced url(var(--x)), which loads nothing.
9
+ @function -image($value) {
10
+ @if -is-css-function($value, "var" "url" "image-set" "linear-gradient" "radial-gradient" "conic-gradient" "repeating-linear-gradient" "repeating-radial-gradient" "repeating-conic-gradient") {
11
+ @return $value;
12
+ }
13
+ @return url(string.unquote($value));
14
+ }
15
+
16
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
17
+ // stays text, so `"var(--x)"` is not a call.
18
+ @function -is-css-function($value, $names) {
19
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
20
+ @return false;
21
+ }
22
+ $open: string.index($value, "(");
23
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
24
+ }
25
+
26
+ // A size Sass can use inside calc(): a number, a calculation such as calc(),
27
+ // min() or clamp(), or var() and env(), which only the browser can resolve.
28
+ // Anything else would pass silently through calc(): `calc(nonsense * 5)`
29
+ // compiles.
30
+ @function -is-size($value) {
31
+ @if meta.type-of($value) == "number" or meta.type-of($value) == "calculation" {
32
+ @return true;
33
+ }
34
+ @if meta.type-of($value) == "string" and string.slice(meta.inspect($value), 1, 1) != "\"" {
35
+ $open: string.index($value, "(");
36
+ @return $open != null and list.index("var" "env", string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
37
+ }
38
+ @return false;
39
+ }
40
+
8
41
  @mixin background-dots(
9
42
  $color: null,
10
43
  $size: 1em,
11
- $gutter: $size * 5,
44
+ $gutter: null,
12
45
  $diagonal: true,
13
46
  $image: null
14
47
  ) {
48
+ // The gutter defaults to five times the size. Deriving it here rather than in
49
+ // the signature lets $size be checked first, and doing the arithmetic in
50
+ // calc() lets var() and clamp() through: Sass simplifies calc() on plain
51
+ // numbers back to a number, so a call with lengths emits the same CSS.
52
+ @if not -is-size($size) {
53
+ @error "`#{meta.inspect($size)}` is not a valid $size for `background-dots`. Pass a length, or var(), env() or a calculation such as `clamp()`.";
54
+ }
55
+ @if $gutter == null {
56
+ $gutter: calc($size * 5);
57
+ }
58
+ @if not -is-size($gutter) {
59
+ @error "`#{meta.inspect($gutter)}` is not a valid $gutter for `background-dots`. Pass a length, or var(), env() or a calculation such as `calc()`.";
60
+ }
15
61
  @if $image != null and meta.type-of($image) != "string" {
16
62
  @error "`#{$image}` is not a valid $image for `background-dots`. Pass an image path as a string.";
17
63
  }
@@ -23,21 +69,21 @@
23
69
  @if $diagonal == true {
24
70
  background-image: radial-gradient($color $size, transparent 0),
25
71
  radial-gradient($color $size, transparent 0);
26
- background-position: math.div($gutter, 2) math.div($gutter, 2),
27
- ($gutter * 2) ($gutter * 2);
72
+ background-position: calc($gutter / 2) calc($gutter / 2),
73
+ calc($gutter * 2) calc($gutter * 2);
28
74
  } @else if $diagonal == false {
29
75
  background-image: radial-gradient($color $size, transparent 0);
30
- background-position: math.div($gutter, 2) math.div($gutter, 2);
76
+ background-position: calc($gutter / 2) calc($gutter / 2);
31
77
  }
32
78
  } @else if $color {
33
79
  @if $diagonal == true {
34
80
  background-image: radial-gradient(list.nth($color, 1) $size, transparent 0),
35
81
  radial-gradient(list.nth($color, list.length($color)) $size, transparent 0);
36
- background-position: math.div($gutter, 2) math.div($gutter, 2),
37
- ($gutter * 2) ($gutter * 2);
82
+ background-position: calc($gutter / 2) calc($gutter / 2),
83
+ calc($gutter * 2) calc($gutter * 2);
38
84
  } @else if $diagonal == false {
39
85
  background-image: radial-gradient(list.nth($color, 1) $size, transparent 0);
40
- background-position: math.div($gutter, 2) math.div($gutter, 2);
86
+ background-position: calc($gutter / 2) calc($gutter / 2);
41
87
  @if list.length($color) > 1 {
42
88
  @error "Please do not pass more than one argument when you disable 'diagonal' property! Simply remove the argument(s) after '#{list.nth($color, 1)}' to resolve the problem.";
43
89
  }
@@ -55,7 +101,7 @@
55
101
  height: 100%;
56
102
  top: 0;
57
103
  left: 0;
58
- background-image: url(string.unquote($image));
104
+ background-image: -image($image);
59
105
  background-repeat: no-repeat;
60
106
  background-position: center;
61
107
  background-size: cover;
@@ -4,19 +4,45 @@
4
4
  @use "sass:map";
5
5
  @use "sass:math";
6
6
  @use "sass:meta";
7
+ @use "sass:string";
7
8
  @use "../library/linear-gradient" as *;
8
9
  @use "../maps/map-for-directions" as *;
9
10
 
11
+ // An image path goes into url(). A var(), url(), image-set() or gradient is
12
+ // already an image, and wrapping it produced url(var(--x)), which loads nothing.
13
+ @function -image($value) {
14
+ @if -is-css-function($value, "var" "url" "image-set" "linear-gradient" "radial-gradient" "conic-gradient" "repeating-linear-gradient" "repeating-radial-gradient" "repeating-conic-gradient") {
15
+ @return $value;
16
+ }
17
+ @return url($value);
18
+ }
19
+
20
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
21
+ // stays text, so `"var(--x)"` is not a call.
22
+ @function -is-css-function($value, $names) {
23
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
24
+ @return false;
25
+ }
26
+ $open: string.index($value, "(");
27
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
28
+ }
29
+
10
30
  @mixin background-image(
11
31
  $image-url: null,
12
32
  $filter-color: null,
13
33
  $filter-direction: null
14
34
  ) {
35
+ // The direction used to be read only when there were two or more colours,
36
+ // so with one colour any value was dropped without a word, a typo included.
37
+ // Check it first, against what the gradient branches accept.
38
+ @if $filter-direction and not map.has-key($map-for-directions, $filter-direction) and not (meta.type-of($filter-direction) == "number" and math.unit($filter-direction) == "deg") {
39
+ @error "`#{$filter-direction}` is not a valid $filter-direction. Pass an angle such as `45deg`, or one of: #{map.keys($map-for-directions)}.";
40
+ }
15
41
  @if $image-url {
16
42
  @if $filter-color {
17
43
  @if list.length($filter-color) == 1 {
18
44
  background-image: linear-gradient(to top, $filter-color, $filter-color),
19
- url($image-url);
45
+ -image($image-url);
20
46
  } @else if list.length($filter-color) > 1 {
21
47
  $color-list: ();
22
48
  @for $i from 1 through list.length($filter-color) {
@@ -28,22 +54,22 @@
28
54
  map.get($map-for-directions, $filter-direction),
29
55
  $color-list
30
56
  ),
31
- url($image-url);
57
+ -image($image-url);
32
58
  } @else {
33
59
  @if meta.type-of($filter-direction) == "number" and list.index("deg", math.unit($filter-direction)) {
34
60
  background-image: linear-gradient($filter-direction, $color-list),
35
- url($image-url);
61
+ -image($image-url);
36
62
  } @else {
37
63
  @error "`#{$filter-direction}` is not a valid $filter-direction. Pass an angle such as `45deg`, or one of: #{map.keys($map-for-directions)}.";
38
64
  }
39
65
  }
40
66
  } @else {
41
67
  background-image: linear-gradient(to top, $color-list),
42
- url($image-url);
68
+ -image($image-url);
43
69
  }
44
70
  }
45
71
  } @else {
46
- background-image: url($image-url);
72
+ background-image: -image($image-url);
47
73
  }
48
74
  } @else {
49
75
  position: relative;
@@ -5,12 +5,51 @@
5
5
  @use "sass:meta";
6
6
  @use "sass:string";
7
7
 
8
+ // An image path goes into url(). A var(), url(), image-set() or gradient is
9
+ // already an image, and wrapping it produced url(var(--x)), which loads nothing.
10
+ @function -image($value) {
11
+ @if -is-css-function($value, "var" "url" "image-set" "linear-gradient" "radial-gradient" "conic-gradient" "repeating-linear-gradient" "repeating-radial-gradient" "repeating-conic-gradient") {
12
+ @return $value;
13
+ }
14
+ @return url(string.unquote($value));
15
+ }
16
+
17
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
18
+ // stays text, so `"var(--x)"` is not a call.
19
+ @function -is-css-function($value, $names) {
20
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
21
+ @return false;
22
+ }
23
+ $open: string.index($value, "(");
24
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
25
+ }
26
+
27
+ // A size Sass can use inside calc(): a number, a calculation such as calc(),
28
+ // min() or clamp(), or var() and env(), which only the browser can resolve.
29
+ // Anything else would pass silently through calc(): `calc(nonsense * 5)`
30
+ // compiles.
31
+ @function -is-size($value) {
32
+ @if meta.type-of($value) == "number" or meta.type-of($value) == "calculation" {
33
+ @return true;
34
+ }
35
+ @if meta.type-of($value) == "string" and string.slice(meta.inspect($value), 1, 1) != "\"" {
36
+ $open: string.index($value, "(");
37
+ @return $open != null and list.index("var" "env", string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
38
+ }
39
+ @return false;
40
+ }
41
+
8
42
  @mixin background-stripes(
9
43
  $color: null,
10
44
  $thickness: 1em,
11
45
  $rotation: -45deg,
12
46
  $image: null
13
47
  ) {
48
+ // The arithmetic below runs in calc() so var() and clamp() work; on plain
49
+ // lengths Sass simplifies it back to the same number.
50
+ @if not -is-size($thickness) {
51
+ @error "`#{meta.inspect($thickness)}` is not a valid $thickness for `background-stripes`. Pass a length, or var(), env() or a calculation such as `clamp()`.";
52
+ }
14
53
  @if meta.type-of($rotation) != "number" {
15
54
  @error "`#{$rotation}` is not a valid $rotation for `background-stripes`. Pass an angle such as `-45deg`, or a unitless number which is treated as degrees.";
16
55
  }
@@ -18,7 +57,7 @@
18
57
  @error "`#{$image}` is not a valid $image for `background-stripes`. Pass an image path as a string.";
19
58
  }
20
59
  $validate-unit: if(not list.index("deg", math.unit($rotation)), $rotation + deg, $rotation);
21
- $get-image: if($image, string.unquote(", ") + url(string.unquote($image)), string.unquote(""));
60
+ $get-image: if($image, string.unquote(", ") + -image($image), string.unquote(""));
22
61
  @if not $color {
23
62
  $color: rgba(0, 0, 0, 0.1);
24
63
  background-image: repeating-linear-gradient(
@@ -26,7 +65,7 @@
26
65
  $color 0,
27
66
  $color $thickness,
28
67
  transparent $thickness,
29
- transparent $thickness * 2
68
+ transparent calc($thickness * 2)
30
69
  ) + $get-image;
31
70
  @if $image {
32
71
  background-position: center;
@@ -39,7 +78,7 @@
39
78
  $color 0,
40
79
  $color $thickness,
41
80
  transparent $thickness,
42
- transparent $thickness * 2
81
+ transparent calc($thickness * 2)
43
82
  ) + $get-image;
44
83
  @if $image {
45
84
  background-position: center;
@@ -50,7 +89,7 @@
50
89
  $list: ();
51
90
  @for $i from 1 through list.length($color) {
52
91
  $index-color: list.nth($color, $i);
53
- $style-rule: $index-color ($thickness * $i) - $thickness, $index-color $thickness * $i;
92
+ $style-rule: $index-color calc($thickness * $i - $thickness), $index-color calc($thickness * $i);
54
93
  $list: list.append($list, $style-rule, comma);
55
94
  }
56
95
  background-image: repeating-linear-gradient($validate-unit, $list) + $get-image;
@@ -1,14 +1,29 @@
1
1
  @charset "UTF-8";
2
2
 
3
+ @use "sass:list";
3
4
  @use "sass:meta";
4
5
  @use "sass:string";
5
6
 
7
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
8
+ // stays text, so `"var(--x)"` is not a call.
9
+ @function -is-css-function($value, $names) {
10
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
11
+ @return false;
12
+ }
13
+ $open: string.index($value, "(");
14
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
15
+ }
16
+
6
17
  @mixin before($content: null) {
7
18
  &::before {
8
19
  @if $content == null {
9
20
  @content;
10
21
  } @else if meta.type-of($content) != "string" {
11
22
  @error "`#{$content}` is not a valid $content for `before`. Pass a string to use as the content value, a data- attribute name such as `\"data-label\"` to render it with attr(), or no argument at all and write the content yourself.";
23
+ } @else if -is-css-function($content, "var" "attr" "counter" "counters") {
24
+ // Quoting would turn the call into text: content: "var(--label)".
25
+ content: $content;
26
+ @content;
12
27
  } @else {
13
28
  $data: string.slice($content, 1, 5);
14
29
  @if $data == "data-" {
@@ -1,14 +1,37 @@
1
1
  @charset "UTF-8";
2
2
 
3
+ @use "sass:list";
4
+ @use "sass:meta";
5
+ @use "sass:string";
6
+
3
7
  @use "../library/stretched-link" as *;
4
8
 
9
+ // An image path goes into url(). A var(), url(), image-set() or gradient is
10
+ // already an image, and wrapping it produced url(var(--x)), which loads nothing.
11
+ @function -image($value) {
12
+ @if -is-css-function($value, "var" "url" "image-set" "linear-gradient" "radial-gradient" "conic-gradient" "repeating-linear-gradient" "repeating-radial-gradient" "repeating-conic-gradient") {
13
+ @return $value;
14
+ }
15
+ @return url($value);
16
+ }
17
+
18
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
19
+ // stays text, so `"var(--x)"` is not a call.
20
+ @function -is-css-function($value, $names) {
21
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
22
+ @return false;
23
+ }
24
+ $open: string.index($value, "(");
25
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
26
+ }
27
+
5
28
  @mixin brand-logo($width, $height, $image-url: null) {
6
29
  display: inline-block;
7
30
  position: relative;
8
31
  width: $width;
9
32
  height: $height;
10
33
  @if $image-url {
11
- background-image: url($image-url);
34
+ background-image: -image($image-url);
12
35
  }
13
36
  background-position: center;
14
37
  background-repeat: no-repeat;
@@ -2,10 +2,35 @@
2
2
 
3
3
  @use "sass:list";
4
4
  @use "sass:map";
5
+ @use "sass:meta";
6
+ @use "sass:string";
5
7
  @use "../maps/map-for-breakpoints" as *;
6
8
  @use "../utilities/validate-breakpoint" as *;
7
9
 
10
+ // Returns the first value in $value that holds var(), looking inside lists and
11
+ // calculations, or null. Custom properties are not evaluated in a @media or
12
+ // @container condition, so a rule built from one never applies, and nothing
13
+ // warns. Measured in Chrome 152: `(min-width: var(--wide))` did not match with
14
+ // `--wide: 200px`, while `(min-width: 200px)` did.
15
+ @function -custom-property-in($value) {
16
+ @each $item in $value {
17
+ @if meta.type-of($item) == "list" or meta.type-of($item) == "arglist" {
18
+ $found: -custom-property-in($item);
19
+ @if $found {
20
+ @return $found;
21
+ }
22
+ } @else if string.index(meta.inspect($item), "var(") {
23
+ @return $item;
24
+ }
25
+ }
26
+ @return null;
27
+ }
28
+
8
29
  @mixin breakpoint($params...) {
30
+ $custom-property: -custom-property-in($params);
31
+ @if $custom-property {
32
+ @error "`#{$custom-property}` cannot be used in a breakpoint: custom properties are not evaluated in a @media condition, so the rule would never apply. Pass a length or a key from $map-for-breakpoints.";
33
+ }
9
34
  @if list.length($params) == 1 {
10
35
  $value: list.nth($params, 1);
11
36
  @if map.has-key($map-for-breakpoints, $value) {
@@ -65,5 +90,9 @@
65
90
  }
66
91
  }
67
92
  }
93
+ } @else {
94
+ // Anything else used to match no branch and emit nothing, so a three
95
+ // argument range such as `between, medium, large` failed without a sound.
96
+ @error "`breakpoint` takes one or two arguments; you passed #{list.length($params)}. For a range, pass `between` with a space-separated pair, `between, medium large`, or two sizes, `medium, large`.";
68
97
  }
69
98
  }
@@ -7,6 +7,25 @@
7
7
  @use "../maps/map-for-breakpoints" as *;
8
8
  @use "../utilities/validate-breakpoint" as *;
9
9
 
10
+ // Returns the first value in $value that holds var(), looking inside lists and
11
+ // calculations, or null. Custom properties are not evaluated in a @media or
12
+ // @container condition, so a rule built from one never applies, and nothing
13
+ // warns. Measured in Chrome 152: `(min-width: var(--wide))` did not match with
14
+ // `--wide: 200px`, while `(min-width: 200px)` did.
15
+ @function -custom-property-in($value) {
16
+ @each $item in $value {
17
+ @if meta.type-of($item) == "list" or meta.type-of($item) == "arglist" {
18
+ $found: -custom-property-in($item);
19
+ @if $found {
20
+ @return $found;
21
+ }
22
+ } @else if string.index(meta.inspect($item), "var(") {
23
+ @return $item;
24
+ }
25
+ }
26
+ @return null;
27
+ }
28
+
10
29
  // A @container rule, taking the same argument shapes as `breakpoint` so the two
11
30
  // read alike. Sizes may be a key from $map-for-breakpoints or a raw length; a
12
31
  // container is usually narrower than the viewport, so a length is the common
@@ -24,6 +43,10 @@
24
43
  @error "`#{$name}` is not a valid $name for `container-query`. Pass a container name as a string, such as `\"card\"`.";
25
44
  }
26
45
 
46
+ $custom-property: -custom-property-in($params);
47
+ @if $custom-property {
48
+ @error "`#{$custom-property}` cannot be used in a container query: custom properties are not evaluated in a @container condition, so the rule would never apply. Pass a length or a key from $map-for-breakpoints.";
49
+ }
27
50
  $condition: null;
28
51
 
29
52
  @if $count == 1 {
@@ -1,8 +1,20 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  @use "sass:list";
4
+ @use "sass:meta";
5
+ @use "sass:string";
4
6
  @use "../lists/list-of-counter-styles" as *;
5
7
 
8
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
9
+ // stays text, so `"var(--x)"` is not a call.
10
+ @function -is-css-function($value, $names) {
11
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
12
+ @return false;
13
+ }
14
+ $open: string.index($value, "(");
15
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
16
+ }
17
+
6
18
  @mixin counter($params...) {
7
19
  $counter: null;
8
20
  $counter-before: null;
@@ -33,15 +45,25 @@
33
45
  }
34
46
  }
35
47
 
48
+ // A prefix or suffix is quoted into text, except a call CSS resolves, which
49
+ // quoting would turn into the literal characters.
50
+ $quote-before: '"';
51
+ $quote-after: '"';
52
+ @if -is-css-function($counter-before, "var" "attr" "counter" "counters") {
53
+ $quote-before: "";
54
+ }
55
+ @if -is-css-function($counter-after, "var" "attr" "counter" "counters") {
56
+ $quote-after: "";
57
+ }
36
58
  &.counter-start {
37
59
  counter-reset: glsCounter;
38
60
  }
39
61
  &.counter-start .counter-item::before,
40
62
  &.counter-continue .counter-item::before {
41
- content: #{if($counter-before, '"' + $counter-before + '"' + " ", null)}counter(
63
+ content: #{if($counter-before, $quote-before + $counter-before + $quote-before + " ", null)}counter(
42
64
  glsCounter#{if($counter, ", " + $counter, null)}
43
65
  )
44
- #{if($counter-after, " " + '"' + $counter-after + '"', null)};
66
+ #{if($counter-after, " " + $quote-after + $counter-after + $quote-after, null)};
45
67
  counter-increment: glsCounter;
46
68
  @content;
47
69
  }
@@ -1,8 +1,10 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  @use "sass:list";
4
+ @use "sass:map";
4
5
  @use "sass:meta";
5
6
  @use "sass:string";
7
+ @use "../maps/map-for-font-formats" as *;
6
8
  @use "../utilities/font-source" as *;
7
9
 
8
10
  @mixin font-face(
@@ -18,6 +20,10 @@
18
20
  @error "`#{$font-family}` is not a valid $font-family for `font-face`. Pass the family name as a string, such as `\"Inter\"`.";
19
21
  } @else if meta.type-of($file-path) != "string" {
20
22
  @error "`#{$file-path}` is not a valid $file-path for `font-face`. Pass the path to the font files without an extension, as a string.";
23
+ } @else if string.slice(meta.inspect($file-path), 1, 1) != "\"" and string.index($file-path, "var(") {
24
+ // The path is written into url("..."), where var() is only text: the
25
+ // browser would request a file literally named var(--x).woff2.
26
+ @error "`#{$file-path}` is not a valid $file-path for `font-face`. A custom property cannot supply a font path, because the path is written into url() as text. Pass the path as a string.";
21
27
  } @else {
22
28
 
23
29
  $list: ();
@@ -42,6 +48,14 @@
42
48
  }
43
49
  }
44
50
 
51
+ // fontSource returns nothing for a format it does not know, so a typo
52
+ // dropped that source and a list of nothing but typos dropped `src`.
53
+ @each $format in $file-formats {
54
+ @if not map.has-key($map-for-font-formats, $format) {
55
+ @error "`#{meta.inspect($format)}` is not a valid file format for `font-face`. Pass one or more of: #{map.keys($map-for-font-formats)}.";
56
+ }
57
+ }
58
+
45
59
  @font-face {
46
60
  font-family: $font-family;
47
61
  @if list.index($file-formats, eot) {
@@ -1,7 +1,19 @@
1
1
  @charset "UTF-8";
2
2
 
3
+ @use "sass:list";
3
4
  @use "sass:math";
4
5
  @use "sass:meta";
6
+ @use "sass:string";
7
+
8
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
9
+ // stays text, so `"var(--x)"` is not a call.
10
+ @function -is-css-function($value, $names) {
11
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
12
+ @return false;
13
+ }
14
+ $open: string.index($value, "(");
15
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
16
+ }
5
17
 
6
18
  // Truncates text after a number of lines. `ellipsis` does one line; this does
7
19
  // several, and needs five declarations rather than one because -webkit-line-clamp
@@ -20,7 +32,8 @@
20
32
  // So the standard property is emitted for the future and the prefixed trio is
21
33
  // what actually does the work today.
22
34
  @mixin line-clamp($lines: 3) {
23
- @if $lines != none {
35
+ // var() is resolved by the browser, so only a literal count is checked.
36
+ @if $lines != none and not -is-css-function($lines, "var" "env") {
24
37
  @if meta.type-of($lines) != "number" or not math.is-unitless($lines) {
25
38
  @error "`#{$lines}` is not a valid $lines for `line-clamp`. Pass a whole number of lines, or `none` to undo a clamp.";
26
39
  }
@@ -4,6 +4,13 @@
4
4
  @use "sass:meta";
5
5
  @use "../utilities/is-time" as *;
6
6
 
7
+ // `init` defines the %loadify placeholder, and every call extends it. Under the
8
+ // module system a selector can only extend a placeholder from a module it
9
+ // loads, so the file with the call must be the file that calls `init`, or must
10
+ // `@use` it. Anything else fails with "The target selector was not found".
11
+ // An entry file calling `init` does not help a partial it loads, since the
12
+ // partial does not load the entry file. Stylesheets using @import share one
13
+ // scope and are unaffected.
7
14
  @mixin loadify($params...) {
8
15
  @if not & {
9
16
  @if list.length($params) == 0 or (list.length($params) == 1 and list.nth($params, 1) == "init") {
@@ -4,10 +4,12 @@
4
4
  @if & {
5
5
  @error "Please call the mixin at the root of your style sheet.";
6
6
  } @else {
7
- /* http://meyerweb.com/eric/tools/css/reset/
8
- v2.0 | 20110126
9
- License: none (public domain)
10
- */
7
+ // http://meyerweb.com/eric/tools/css/reset/
8
+ // v2.0 | 20110126
9
+ // License: none (public domain)
10
+ //
11
+ // Comments in this file are `//`: a /* */ comment inside a mixin is emitted
12
+ // into the stylesheet of everyone who includes it.
11
13
  html, body, div, span, applet, object, iframe,
12
14
  h1, h2, h3, h4, h5, h6, p, blockquote, pre,
13
15
  a, abbr, acronym, address, big, cite, code,
@@ -28,7 +30,7 @@
28
30
  font: inherit;
29
31
  vertical-align: baseline;
30
32
  }
31
- /* HTML5 display-role reset for older browsers */
33
+ // HTML5 display-role reset for older browsers
32
34
  article, aside, details, figcaption, figure,
33
35
  footer, header, hgroup, menu, main, nav, section {
34
36
  display: block;
@@ -1,6 +1,33 @@
1
1
  @charset "UTF-8";
2
2
 
3
+ @use "sass:list";
4
+ @use "sass:meta";
5
+ @use "sass:string";
6
+
7
+ // Returns the first value in $value that holds var(), looking inside lists and
8
+ // calculations, or null. Custom properties are not evaluated in a @media or
9
+ // @container condition, so a rule built from one never applies, and nothing
10
+ // warns. Measured in Chrome 152: `(min-width: var(--wide))` did not match with
11
+ // `--wide: 200px`, while `(min-width: 200px)` did.
12
+ @function -custom-property-in($value) {
13
+ @each $item in $value {
14
+ @if meta.type-of($item) == "list" or meta.type-of($item) == "arglist" {
15
+ $found: -custom-property-in($item);
16
+ @if $found {
17
+ @return $found;
18
+ }
19
+ } @else if string.index(meta.inspect($item), "var(") {
20
+ @return $item;
21
+ }
22
+ }
23
+ @return null;
24
+ }
25
+
3
26
  @mixin screen-agent($resolution) {
27
+ $custom-property: -custom-property-in($resolution);
28
+ @if $custom-property {
29
+ @error "`#{$custom-property}` cannot be used as a resolution: custom properties are not evaluated in a @media condition, so the rule would never apply. Pass `1x`, `2x`, `3x` or a resolution such as `2dppx`.";
30
+ }
4
31
  @if $resolution == "1x" {
5
32
  @media (min-resolution: 96dpi) {
6
33
  @content;
@@ -1,8 +1,31 @@
1
1
  @charset "UTF-8";
2
2
 
3
+ @use "sass:list";
4
+ @use "sass:meta";
5
+ @use "sass:string";
6
+
7
+ // An image path goes into url(). A var(), url(), image-set() or gradient is
8
+ // already an image, and wrapping it produced url(var(--x)), which loads nothing.
9
+ @function -image($value) {
10
+ @if -is-css-function($value, "var" "url" "image-set" "linear-gradient" "radial-gradient" "conic-gradient" "repeating-linear-gradient" "repeating-radial-gradient" "repeating-conic-gradient") {
11
+ @return $value;
12
+ }
13
+ @return url($value);
14
+ }
15
+
16
+ // True for an unquoted call to one of $names, such as var(--x). A quoted string
17
+ // stays text, so `"var(--x)"` is not a call.
18
+ @function -is-css-function($value, $names) {
19
+ @if meta.type-of($value) != "string" or string.slice(meta.inspect($value), 1, 1) == "\"" {
20
+ @return false;
21
+ }
22
+ $open: string.index($value, "(");
23
+ @return $open != null and list.index($names, string.to-lower-case(string.slice($value, 1, $open - 1))) != null;
24
+ }
25
+
3
26
  @mixin text-image($image: null) {
4
27
  @if $image {
5
- background-image: url($image);
28
+ background-image: -image($image);
6
29
  }
7
30
  background-size: cover;
8
31
  background-position: center;