forked from sass/sass-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document first-class mixins (sass#852)
Closes sass#786
- Loading branch information
Israel-4Ever
authored
Oct 6, 2023
1 parent
bd69b69
commit 8cb868d
Showing
9 changed files
with
222 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: sass-spec | ||
description: Check out Dart Sass, build it, and link it into package.json. | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out Dart Sass | ||
id: clone | ||
uses: sass/clone-linked-repo@v1 | ||
with: | ||
repo: sass/dart-sass | ||
default-ref: null | ||
|
||
- uses: dart-lang/setup-dart@v1 | ||
if: steps.clone.outputs.cloned == 'true' | ||
|
||
- uses: bufbuild/[email protected] | ||
with: {github_token: '${{ inputs.github-token }}'} | ||
if: steps.clone.outputs.cloned == 'true' | ||
|
||
- run: dart pub get | ||
working-directory: dart-sass | ||
shell: bash | ||
if: steps.clone.outputs.cloned == 'true' | ||
|
||
- name: Check out the language repo | ||
uses: sass/clone-linked-repo@v1 | ||
with: {repo: sass/sass, path: dart-sass/build/language} | ||
if: steps.clone.outputs.cloned == 'true' | ||
|
||
- name: Build Dart Sass | ||
run: dart run grinder protobuf pkg-npm-dev | ||
working-directory: dart-sass | ||
shell: bash | ||
if: steps.clone.outputs.cloned == 'true' | ||
|
||
- name: Install Dart Sass | ||
run: npm install dart-sass/build/npm | ||
if: steps.clone.outputs.cloned == 'true' | ||
env: {UPDATE_SASS_PROTOCOL: false} | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,27 +46,28 @@ jobs: | |
if: github.event_name == 'workflow_run' | ||
steps: | ||
- name: Download built site | ||
id: download_site | ||
uses: dawidd6/[email protected] | ||
with: | ||
name: site | ||
run_id: ${{ github.event.workflow_run.id }} | ||
if_no_artifact_found: ignore | ||
- name: Clone shadow repo | ||
uses: actions/checkout@v4 | ||
if: steps.download_comment.outputs.found_artifact == 'true' | ||
if: steps.download_site.outputs.found_artifact == 'true' | ||
with: | ||
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }} | ||
token: ${{ secrets.SASS_SITE_TOKEN }} | ||
ref: ${{ github.ref_name }} | ||
path: shadow-repo | ||
- name: Update shadow repo files | ||
if: steps.download_comment.outputs.found_artifact == 'true' | ||
if: steps.download_site.outputs.found_artifact == 'true' | ||
run: | | ||
rm -rf shadow_repo/* | ||
tar xf site.tar | ||
cp -rT _site shadow_repo | ||
- uses: EndBug/add-and-commit@v9 | ||
if: steps.download_comment.outputs.found_artifact == 'true' | ||
if: steps.download_site.outputs.found_artifact == 'true' | ||
with: | ||
cwd: shadow-repo | ||
author_name: Sass Bot | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
source/_includes/code_snippets/example-first-class-mixin.liquid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% codeExample 'first-class-mixin' %} | ||
@use "sass:meta"; | ||
@use "sass:string"; | ||
|
||
/// Passes each element of $list to a separate invocation of $mixin. | ||
@mixin apply-to-all($mixin, $list) { | ||
@each $element in $list { | ||
@include meta.apply($mixin, $element); | ||
} | ||
} | ||
|
||
@mixin font-class($size) { | ||
.font-#{$size} { | ||
font-size: $size; | ||
} | ||
} | ||
|
||
$sizes: [8px, 12px, 2rem]; | ||
|
||
@include apply-to-all(meta.get-mixin("font-class"), $sizes); | ||
=== | ||
@use "sass:meta" | ||
@use "sass:string" | ||
|
||
/// Passes each element of $list to a separate invocation of $mixin. | ||
@mixin apply-to-all($mixin, $list) | ||
@each $element in $list | ||
@include meta.apply($mixin, $element) | ||
|
||
|
||
|
||
@mixin font-class($size) | ||
.font-#{$size} | ||
font-size: $size | ||
|
||
|
||
|
||
$sizes: 8px, 12px 2rem | ||
|
||
@include apply-to-all(meta.get-mixin("font-class"), $sizes) | ||
{% endcodeExample %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Functions | ||
title: Function Values | ||
--- | ||
|
||
{% render 'doc_snippets/call-impl-status' %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Mixin Values | ||
--- | ||
|
||
{% compatibility 'dart: "1.69.0"', 'libsass: false', 'ruby: false' %}{% endcompatibility %} | ||
|
||
[Mixins] can also be values! You can't directly write a mixin as a value, but | ||
you can pass a mixin's name to the [`meta.get-mixin()` function] to get it as a | ||
value. Once you have a mixin value, you can pass it to the [`meta.apply()` | ||
mixin] to call it. This is for libraries to be extensible in complex and | ||
powerful ways. | ||
|
||
[Mixins]: /documentation/at-rules/mixin | ||
[`meta.get-mixin()` function]: /documentation/modules/meta#get-mixin | ||
[`meta.apply()` mixin]: /documentation/modules/meta#apply | ||
|
||
{% render 'code_snippets/example-first-class-mixin' %} |