|
8 | 8 | // |
9 | 9 | // The following custom properties can be used to customize the list component: |
10 | 10 | // | Property | Description | Default Value | |
11 | | -// | --- | --- | --- | |
| 11 | +// | ---------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
12 | 12 | // | `--graupl-list-padding-x` | Horizontal padding of the list. | `var(--graupl-spacer-0)` | |
13 | 13 | // | `--graupl-list-padding-y` | Vertical padding of the list. | `var(--graupl-spacer-0)` | |
14 | 14 | // | `--graupl-list-padding` | Shorthand padding of the list. | `var(--graupl-list-padding-y) var(--graupl-list-padding-x)` | |
|
35 | 35 | // | `--graupl-list-item-border-color` | Border colour of list items. | `var(--graupl-list-item-color)` | |
36 | 36 | // |
37 | 37 | // The following sass variables can be used to customize the generation of the list component: |
38 | | -// | Variable | Description | Default Value | |
39 | | -// | --- | --- | --- | |
40 | | -// | `$selector-base` | Selector base for the component. | `"."` | |
41 | | -// | `$modifier-selector-base` | Selector base for component modifiers. | `"."` | |
42 | | -// | `$list-selector-base` | Selector base for the list container. | `$selector-base` | |
43 | | -// | `$list-selector` | Selector for the list container. | `"list"` | |
44 | | -// | `$list-item-selector-base` | Selector base for list items. | `$selector-base` | |
45 | | -// | `$list-item-selector` | Selector for list items. | `"list-item"` | |
46 | | -// | `$list-item-transform` | Base transform for list items. | `none` | |
47 | | -// | `$list-item-hover-transform` | Hover transform for list items. | `none` | |
| 38 | +// | Variable | Description | Default Value | |
| 39 | +// | ---------------------------- | ----------------------------------------- | ---------------- | |
| 40 | +// | `$selector-base` | Selector base for the component. | `"."` | |
| 41 | +// | `$modifier-selector-base` | Selector base for component modifiers. | `"."` | |
| 42 | +// | `$generate-base-theme-map` | Flag to generate the base theme map. | `true` | |
| 43 | +// | `$themeable` | Flag to generate theme modifiers. | `false` | |
| 44 | +// | `$list-selector-base` | Selector base for the list container. | `$selector-base` | |
| 45 | +// | `$list-selector` | Selector for the list container. | `"list"` | |
| 46 | +// | `$list-theme-selector-base` | Selector base for theme modifiers. | `"."` | |
| 47 | +// | `$list-theme-selector-prefix`| Selector prefix for theme modifiers. | `""` | |
| 48 | +// | `$list-item-selector-base` | Selector base for list items. | `$selector-base` | |
| 49 | +// | `$list-item-selector` | Selector for list items. | `"list-item"` | |
| 50 | +// | `$list-item-transform` | Base transform for list items. | `none` | |
| 51 | +// | `$list-item-hover-transform` | Hover transform for list items. | `none` | |
| 52 | +// | `$list-theme-mappings` | Map of properties/shades for list themes. | `()` | |
| 53 | +// | `$list-theme-map` | Expanded map of properties/colors/shades. | `()` | |
| 54 | +// |
| 55 | +// ## Using `$list-theme-mappings` |
| 56 | +// |
| 57 | +// `$list-theme-mappings` is a 1-level map of properties and shade values. |
| 58 | +// |
| 59 | +// e.g. |
| 60 | +// ```scss |
| 61 | +// $list-theme-mappings: ( |
| 62 | +// color: 900, |
| 63 | +// border-color: 700, |
| 64 | +// ) |
| 65 | +// ``` |
| 66 | +// |
| 67 | +// This directly[1] maps to all list variants, telling them what shade to use for the base colour slots. |
| 68 | +// All list variants will use the following based on the example above: |
| 69 | +// - Primary lists will have their `--graupl-list-color` property set to `--graupl-theme-active--primary--900` and `--graupl-list-border-color` to `--graupl-theme-active--primary--700`, |
| 70 | +// - Secondary lists will use the same shades for the secondary palette, and |
| 71 | +// - Tertiary lists will use the same shades for the tertiary palette. |
| 72 | +// |
| 73 | +// You can use this to customize _all_ list variants in the same way. |
| 74 | +// |
| 75 | +// For example, if you use the following map: |
| 76 | +// ```scss |
| 77 | +// $list-theme-mappings: ( |
| 78 | +// color: 500, |
| 79 | +// item-color: 500, |
| 80 | +// ) |
| 81 | +// ``` |
| 82 | +// |
| 83 | +// All list variants will use the following: |
| 84 | +// - Primary lists will have their `--graupl-list-color` and `--graupl-list-item-color` properties set to `--graupl-theme-active--primary--500`, |
| 85 | +// - Secondary lists will have theirs set to `--graupl-theme-active--secondary--500`, and |
| 86 | +// - Tertiary lists will have theirs set to `--graupl-theme-active--tertiary--500`. |
| 87 | +// |
| 88 | +// [1] `$list-theme-mappings` gets parsed into a larger, more explicit map: `$list-theme-map`. |
| 89 | +// |
| 90 | +// Using `$list-theme-map` |
| 91 | +// |
| 92 | +// `$list-theme-map` is a multi-level map of properties, colors, and shade values. |
| 93 | +// |
| 94 | +// e.g. |
| 95 | +// ```scss |
| 96 | +// $list-theme-map: ( |
| 97 | +// primary: ( |
| 98 | +// item-border-color: ( |
| 99 | +// color: secondary, |
| 100 | +// shade: 700 |
| 101 | +// ), |
| 102 | +// ), |
| 103 | +// secondary: ( |
| 104 | +// item-border-color: ( |
| 105 | +// color: secondary, |
| 106 | +// shade: 500 |
| 107 | +// ), |
| 108 | +// ), |
| 109 | +// tertiary: ( |
| 110 | +// item-border-color: ( |
| 111 | +// color: tertiary, |
| 112 | +// shade: 300 |
| 113 | +// ), |
| 114 | +// ), |
| 115 | +// ) |
| 116 | +// ``` |
| 117 | +// |
| 118 | +// This directly maps to all list variants, telling them what shade to use for said property. |
| 119 | +// You can use this to customize list variants individually. |
48 | 120 | // |
49 | 121 | // @example |
50 | 122 | // <ul class="list"> |
|
63 | 135 | @use "../../defaults" as root-defaults; |
64 | 136 | @use "../../mixins/animation"; |
65 | 137 | @use "../../mixins/layer" as *; |
| 138 | +@use "../../mixins/theme" as theme; |
66 | 139 | @use "defaults"; |
67 | 140 | @use "sass:map"; |
68 | 141 | @use "variables" as *; |
|
106 | 179 | border-color: $list-border-color; |
107 | 180 | background: $list-background; |
108 | 181 | color: $list-color; |
| 182 | + |
| 183 | + @if root-defaults.$themeable-components and defaults.$themeable { |
| 184 | + @include theme.generate-modifiers( |
| 185 | + defaults.$list-theme-map, |
| 186 | + defaults.$list-theme-selector-base, |
| 187 | + defaults.$list-theme-selector-prefix, |
| 188 | + "list-" |
| 189 | + ); |
| 190 | + @include theme.generate-modifiers( |
| 191 | + defaults.$list-theme-map, |
| 192 | + defaults.$list-theme-selector-base, |
| 193 | + defaults.$list-theme-selector-prefix, |
| 194 | + "list-", |
| 195 | + "" |
| 196 | + ); |
| 197 | + } |
109 | 198 | } |
110 | 199 |
|
111 | 200 | // .list-item |
|
0 commit comments