-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce color collections for generative styling of components
- Loading branch information
1 parent
02a83f7
commit ac823eb
Showing
7 changed files
with
99 additions
and
19 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
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,24 @@ | ||
# Collections | ||
|
||
Collections are lists of available values that can be used to customize the | ||
appearance of components, such as colors, sizes, and placement. Collections are | ||
used to ensure consistency across the design system. | ||
|
||
## General Guidelines | ||
|
||
- If an option from a collection is used in a component, all other options from | ||
the same collection must be available for use in that component too. | ||
- Components can support one or more collections from a collection category. | ||
Refer to the documentation for each component to see which collections are | ||
available. | ||
|
||
## Colors | ||
|
||
The following color names are designed for use in components that support the | ||
`color` prop: | ||
|
||
| Collection | Available values | | ||
|------------|--------------------------------------------------------| | ||
| Action | `primary`, `secondary`, `selected` | | ||
| Feedback | `success`, `warning`, `danger`, `info`, `help`, `note` | | ||
| Neutral | `light`, `dark` | |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$action-colors: primary, secondary, selected; | ||
$feedback-colors: success, warning, danger, info, help, note; | ||
$neutral-colors: light, dark; | ||
|
||
$colors: ( | ||
action: $action-colors, | ||
feedback: $feedback-colors, | ||
neutral: $neutral-colors, | ||
); |
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,49 @@ | ||
@use "sass:list"; | ||
@use "sass:map"; | ||
@use "../settings/collections"; | ||
@use "string" as rui-string; | ||
|
||
@function _get-category-by-value($value, $collections) { | ||
@each $category, $values in $collections { | ||
@if list.index($values, $value) { | ||
@return $category; | ||
} | ||
} | ||
|
||
@error | ||
"Supplied value \"" | ||
+ $value | ||
+ "\" not found in any category (" | ||
+ map.keys(collections.$colors) | ||
+ ")"; | ||
} | ||
|
||
@function _get-text-color-modifier($modifier) { | ||
@if $modifier == "dark" { | ||
@return "light"; | ||
} @else if $modifier == "light" { | ||
@return "dark"; | ||
} | ||
|
||
@return $modifier; | ||
} | ||
|
||
@mixin generate-colors($prefix, $component-name, $modifier, $properties, $inherit-link-color: false) { | ||
.isRootColor#{rui-string.capitalize($modifier)} { | ||
@each $property in $properties { | ||
--#{$prefix}local-#{$property}: | ||
var( | ||
#{"--" + $prefix + $component-name + "--" + $modifier + "__" + $property} | ||
); | ||
} | ||
|
||
@if $inherit-link-color { | ||
$color-category: _get-category-by-value($value: $modifier, $collections: collections.$colors); | ||
$text-modifier: _get-text-color-modifier($modifier); | ||
|
||
--#{$prefix}local-link-color: var(--rui-color-#{$color-category}-#{$text-modifier}); | ||
--#{$prefix}local-link-color-hover: var(--rui-color-#{$color-category}-#{$text-modifier}-hover); | ||
--#{$prefix}local-link-color-active: var(--rui-color-#{$color-category}-#{$text-modifier}-active); | ||
} | ||
} | ||
} |
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