-
-
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.
feat(variant.update): add sub module
update
to modify variant item …
…and property.
- Loading branch information
1 parent
2b05573
commit 6a7c2fe
Showing
4 changed files
with
101 additions
and
0 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@forward 'update' as update-*; | ||
@forward 'variant.create.function'; | ||
@forward 'variant.modify.function'; |
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,2 @@ | ||
@forward 'update.item.function'; | ||
@forward 'update.property.function'; |
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,48 @@ | ||
// Sass. | ||
@use 'sass:list'; | ||
@use 'sass:meta'; | ||
|
||
// Modules. | ||
@use '../../class'; | ||
@use '../../map'; | ||
@use '../../values'; | ||
|
||
// Status: DONE | ||
// The `update.item()` function. | ||
// @param `$item` | ||
// @param `$class` | ||
// @param `$property` | ||
// @param `$key` | ||
// @returns | ||
@function item($item, $class: null, $property: null, $key: base) { | ||
$result: (); | ||
@if type-of($item) == map { | ||
@each $-class, $prop in $item { | ||
$result: ( | ||
if( | ||
meta.type-of($class) == map, | ||
class.affix-add($-class, $class), | ||
$-class | ||
): map.get($property, $key, $property) or $prop | ||
); | ||
} | ||
} @else { | ||
$class: if( | ||
meta.type-of($class) == map, | ||
class.affix-add($item, $class), | ||
$class or $item | ||
); | ||
@if $property { | ||
$result: ( | ||
$class: map.get($property, $key, $property) | ||
); | ||
} @else { | ||
@return $class; | ||
} | ||
} | ||
@return $result; | ||
} | ||
|
||
// Examples. | ||
// @debug modify((primary: primary light), (prefix: p, suffix: s)); | ||
// @debug modify((primary: primary light), (prefix: spectre, suffix: end)); |
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,50 @@ | ||
// Sass. | ||
@use 'sass:list'; | ||
|
||
// Modules. | ||
@use '../../map'; | ||
@use '../../values'; | ||
|
||
// Status: TODO: | ||
// The `update.property()` function. | ||
// @param `$property` | ||
// @param `$modifier` | ||
// @param `$attribute` | ||
// @returns | ||
@function property($property, $modifier, $attribute: null) { | ||
$property: if( | ||
map.has-keys($modifier, (property, middle)), | ||
map.get($modifier, (property, middle)), | ||
$property | ||
); | ||
@if list.separator($property) == comma { | ||
$i: 1; | ||
@each $base in $property { | ||
$property: list.set-nth( | ||
$property, | ||
$i, | ||
values.join( | ||
(separator: space), | ||
map.get-any($modifier, (property, base), (property, name), null), | ||
$base, | ||
$attribute, | ||
map.get-any($modifier, (property, attribute), (property, end), null), | ||
) | ||
); | ||
$i: $i + 1; | ||
} | ||
} @else { | ||
$property: values.join( | ||
(separator: space), | ||
map.get-any($modifier, (property, base), (property, name), null), | ||
$property, | ||
$attribute, | ||
map.get-any($modifier, (property, attribute), (property, end), null), | ||
); | ||
} | ||
@return $property; | ||
} | ||
|
||
// Examples. | ||
|
||
|