From f0f84513f8efe533b6ee670a6f1a0c074387b2ec Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 13 Aug 2025 12:01:46 +0200 Subject: Make use of SASS modules --- src/_props.scss | 214 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 107 insertions(+), 107 deletions(-) (limited to 'src/_props.scss') diff --git a/src/_props.scss b/src/_props.scss index 300fc28..17e9de7 100644 --- a/src/_props.scss +++ b/src/_props.scss @@ -3,137 +3,137 @@ @use 'sass:meta'; @function is-prop-ref($value) { - @if meta.type-of($value) != 'list' { - @return false; - } - @if list.length($value) != 4 { - @return false; - } - @if list.nth($value, 1) != 'prop-ref' { - @return false; - } - @return true; + @if meta.type-of($value) != 'list' { + @return false; + } + @if list.length($value) != 4 { + @return false; + } + @if list.nth($value, 1) != 'prop-ref' { + @return false; + } + @return true; } @function def($name, $value: (), $metadata: ()) { - @return ('prop-ref' $name $value $metadata); + @return ('prop-ref' $name $value $metadata); } @function merge($ref, $value) { - @if not is-prop-ref($ref) { - @return $ref; - } + @if not is-prop-ref($ref) { + @return $ref; + } - $v: list.nth($ref, 3); - $ref: list.set-nth($ref, 3, map.deep-merge($v, $value)); - @return $ref; + $v: list.nth($ref, 3); + $ref: list.set-nth($ref, 3, map.deep-merge($v, $value)); + @return $ref; } @function get-deep($name, $value, $key: null, $keys...) { - @if is-prop-ref($value) { - @return get($value, $key, $keys); - } - @if meta.type-of($value) == 'map' and $key != null { - @if meta.type-of($key) != 'string' { - @error 'Expected string, got #{$key}'; - } - @return get-deep(#{$name}#{$key}, map.get($value, $key), $keys...); - } - @return $name $value; + @if is-prop-ref($value) { + @return get($value, $key, $keys); + } + @if meta.type-of($value) == 'map' and $key != null { + @if meta.type-of($key) != 'string' { + @error 'Expected string, got #{$key}'; + } + @return get-deep(#{$name}#{$key}, map.get($value, $key), $keys...); + } + @return $name $value; } @function map-to-vars($name, $map) { - @if meta.type-of($map) != 'map' { - @if meta.type-of($name) != 'string' { - @error 'Expected variable name, got #{$name} instead'; - } - @return var($name); - } + @if meta.type-of($map) != 'map' { + @if meta.type-of($name) != 'string' { + @error 'Expected variable name, got #{$name} instead'; + } + @return var($name); + } - $out: (); + $out: (); - @each $key, $value in $map { - $out: map.set($out, $key, map-to-vars(#{$name}#{$key}, $value)); - } + @each $key, $value in $map { + $out: map.set($out, $key, map-to-vars(#{$name}#{$key}, $value)); + } - @return $out; + @return $out; } @function get($ref, $key: null, $keys...) { - @if not is-prop-ref($ref) { - @return $ref; - } - - $name: list.nth($ref, 2); - $value: get(list.nth($ref, 3)); - - @if meta.type-of($value) == 'map' { - $res: get-deep($name, $value, $key, $keys...); - $name: list.nth($res, 1); - $value: list.nth($res, 2); - } @else if meta.type-of($value) == 'list' { - $i: 1; - @each $item in $value { - $value: list.set-nth($value, $i, get($item)); - $i: $i + 1; - } - } - - @return map-to-vars($name, $value); + @if not is-prop-ref($ref) { + @return $ref; + } + + $name: list.nth($ref, 2); + $value: get(list.nth($ref, 3)); + + @if meta.type-of($value) == 'map' { + $res: get-deep($name, $value, $key, $keys...); + $name: list.nth($res, 1); + $value: list.nth($res, 2); + } @else if meta.type-of($value) == 'list' { + $i: 1; + @each $item in $value { + $value: list.set-nth($value, $i, get($item)); + $i: $i + 1; + } + } + + @return map-to-vars($name, $value); } @mixin materialize-helper($name, $value) { - @if meta.type-of($value) == 'map' { - @each $key, $value in $value { - @include materialize-helper(#{$name}#{$key}, $value); - } - } @else { - #{$name}: #{$value}; - } + @if meta.type-of($value) == 'map' { + @each $key, $value in $value { + @include materialize-helper(#{$name}#{$key}, $value); + } + } @else { + #{$name}: #{$value}; + } } @mixin materialize($ref, $match-meta: ()) { - @if is-prop-ref($ref) { - $name: list.nth($ref, 2); - $value: get(list.nth($ref, 3)); - $meta: get(list.nth($ref, 4)); - - $match: true; - @if meta.type-of($match-meta) == 'list' { - @each $item in $match-meta { - $match: $match and list.index($meta, $item) != null; - } - } @else if $match-meta == null and list.length($meta) == 0 { - $match: true; - } @else { - $match: list.index($meta, $match-meta) != null; - } - - @if $match { - @include materialize-helper($name, $value); - } - } @else if meta.type-of($ref) == 'list' { - @each $r in $ref { - @if is-prop-ref($r) { - $name: list.nth($r, 2); - $value: get(list.nth($r, 3)); - $meta: get(list.nth($r, 4)); - - $match: true; - @if meta.type-of($match-meta) == 'list' { - @each $item in $match-meta { - $match: $match and list.index($meta, $item) != null; - } - } @else if $match-meta == null and list.length($meta) == 0 { - $match: true; - } @else { - $match: list.index($meta, $match-meta) != null; - } + @if is-prop-ref($ref) { + $name: list.nth($ref, 2); + $value: get(list.nth($ref, 3)); + $meta: get(list.nth($ref, 4)); + + $match: true; + @if meta.type-of($match-meta) == 'list' { + @each $item in $match-meta { + $match: $match and list.index($meta, $item) != null; + } + } @else if $match-meta == null and list.length($meta) == 0 { + $match: true; + } @else { + $match: list.index($meta, $match-meta) != null; + } + + @if $match { + @include materialize-helper($name, $value); + } + } @else if meta.type-of($ref) == 'list' { + @each $r in $ref { + @if is-prop-ref($r) { + $name: list.nth($r, 2); + $value: get(list.nth($r, 3)); + $meta: get(list.nth($r, 4)); + + $match: true; + @if meta.type-of($match-meta) == 'list' { + @each $item in $match-meta { + $match: $match and list.index($meta, $item) != null; + } + } @else if $match-meta == null and list.length($meta) == 0 { + $match: true; + } @else { + $match: list.index($meta, $match-meta) != null; + } - @if $match { - @include materialize-helper($name, $value); - } - } - } - } + @if $match { + @include materialize-helper($name, $value); + } + } + } + } } -- cgit v1.2.3-70-g09d2