Skip to content

Commit 41a3cb5

Browse files
committed
[css-mixins-1][editorial] Fix some more examples to use the new mixin syntax.
1 parent 5ef053c commit 41a3cb5

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

��css-mixins-1/Overview.bs‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,16 @@ making them reusable and customizable with arguments.
885885

886886
<pre highlight=css>
887887
@mixin --gradient-text(
888-
--from type(<<color>>): mediumvioletred,
889-
--to type(<<color>>): teal,
888+
--from <<color>>: mediumvioletred,
889+
--to <<color>>: teal,
890890
--angle: to bottom right,
891891
) {
892+
--gradient: linear-gradient(var(--angle), var(--from), var(--to));
892893
@result {
893-
color: env(--from, env(--to));
894+
color: var(--from, var(--to));
894895

895896
@supports (background-clip: text) or (-webkit-background-clip: text) {
896-
@env --gradient: linear-gradient(env(--angle), env(--from), env(--to));
897-
background: env(--gradient, env(--from));
897+
background: var(--gradient, var(--from));
898898
color: transparent;
899899
-webkit-background-clip: text;
900900
background-clip: text;
@@ -907,36 +907,31 @@ making them reusable and customizable with arguments.
907907
}
908908
</pre>
909909

910-
Note that this example also uses a [=scoped environment variable=]
911-
(along with the arguments, which implicitly define [=scoped environment variables=])
912-
which is scoped to <em>the rule itself</em>
913-
(rather than being applied to the element, like a [=custom property=] would be)
914-
to hold a temporary value to aid in readability of the [=mixin=],
915-
without polluting the element's styles with unwanted [=custom properties=].
910+
Note that this example also uses a [=local variable=] ''--gradient'',
911+
which is accessible inside the mixin
912+
to aid in readability,
913+
but won't pollute the element's actual styles.
916914

917-
This is exactly equivalent to writing a [=nested style rule=] literally into the `h1` styles:
915+
This is roughly equivalent to writing a [=nested style rule=] literally into the `h1` styles:
918916

919917
<pre highlight=css>
920918
h1 {
921-
@nest {
922-
@env --from: pink;
923-
@env --to: powderblue;
924-
@env --angle: to bottom right;
925-
color: env(--from, env(--to));
926-
927-
@supports (background-clip: text) or (-webkit-background-clip: text) {
928-
@env --gradient: linear-gradient(env(--angle), env(--from), env(--to));
929-
background: env(--gradient, env(--from));
930-
color: transparent;
931-
-webkit-background-clip: text;
932-
background-clip: text;
933-
}
919+
--from: pink;
920+
--to: powderblue;
921+
--angle: to bottom right;
922+
color: var(--from, var(--to));
923+
924+
@supports (background-clip: text) or (-webkit-background-clip: text) {
925+
--gradient: linear-gradient(var(--angle), var(--from), var(--to));
926+
background: var(--gradient, var(--from));
927+
color: transparent;
928+
-webkit-background-clip: text;
929+
background-clip: text;
934930
}
935931
}
936932
</pre>
937933

938-
(Where <css>@nest</css> is a fictitious rule
939-
representing a [=nested declarations rule=].)
934+
(except that none of those custom properties actually show up in the element's styles)
940935
</div>
941936

942937
Issue: The entire ''@mixin'' feature is experimental and under active development,
@@ -1457,8 +1452,10 @@ that block is passed as the mixin's [=contents block=].
14571452

14581453
<pre highlight=css>
14591454
@mixin --just-contents() {
1460-
@contents { color: red; }
1461-
/* `color: red` is the fallback content */
1455+
@result {
1456+
@contents { color: red; }
1457+
/* `color: red` is the fallback content */
1458+
}
14621459
}
14631460

14641461
.foo {

0 commit comments

Comments
 (0)