|
33 | 33 | @return map-get($CONSTANTS, $name); |
34 | 34 | } |
35 | 35 |
|
36 | | -@function feature($key) { |
37 | | - @if map-has-key($features,$key) { |
38 | | - @return map-get($features,$key); |
| 36 | +@function component($c) { |
| 37 | + $cKey: quote($c); |
| 38 | + @if map-has-key($components, $cKey) { |
| 39 | + $component: map-get($components, $cKey); |
| 40 | + @if type-of($component) == "map" { |
| 41 | + @if map-has-key($component, "_enabled") { |
| 42 | + @return map-get($component, "_enabled"); |
| 43 | + } @else { |
| 44 | + @error "The component `#{$c}` does not indicate whether or not it is enabled."; |
| 45 | + } |
| 46 | + } @else { |
| 47 | + @return $component; |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + @error "The component `#{$c}` does not exist in the `$components` map."; |
| 52 | +} |
| 53 | + |
| 54 | +@function component-feature($c,$f) { |
| 55 | + $cKey: quote($c); |
| 56 | + @if not(map-has-key($components,$cKey)) { |
| 57 | + @error "The component `#{$c} does not seem to exist within the `$components` map." |
| 58 | + } @else { |
| 59 | + $component: map-get($components, $cKey); |
| 60 | + @if type-of($component) != "map" { |
| 61 | + @error "The component `#{$c}` does not have individual features."; |
| 62 | + } @else { |
| 63 | + $fKey: quote($f); |
| 64 | + @if not(map-has-key($component),$fKey) { |
| 65 | + @error "The component `#{$c}` does not have a feature named `#{$f}`."; |
| 66 | + } @else { |
| 67 | + @return map-get($component, $fKey); |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +@function theme($prop) { |
| 74 | + $pKey: quote($prop); |
| 75 | + @if (map-has-key($theme, $pKey)) { |
| 76 | + @return map-get($theme, $pKey); |
39 | 77 | } |
40 | 78 |
|
41 | | - @error "The feature `#{$key}` does not exist in the $features map."; |
| 79 | + @error "The property `#{$prop}` is not a key in the `$theme` map."; |
42 | 80 | } |
43 | 81 |
|
44 | 82 | // region /////////////////////////////////////////////////////////////// Other Functions |
|
61 | 99 |
|
62 | 100 | // endregion //////////////////////////////////////////////////////////// End Other Functions |
63 | 101 |
|
64 | | - |
65 | | - |
66 | 102 | // endregion //////////////////////////////////////////////////////////// End Getter Functions |
67 | 103 |
|
68 | 104 | // region /////////////////////////////////////////////////////////////// Setter Functions |
69 | 105 |
|
70 | | -@mixin set-feature($key,$value) { |
71 | | - @if not(variable-exists(features)) { |
72 | | - @error "You may not use the `set-feature` mixin prior without the $features map. Please include `root-variables` prior to this usage." |
| 106 | +@mixin set-component($c,$v) { |
| 107 | + @if not(variable-exists(components)) { |
| 108 | + @error "You may not use the `set-component` mixin prior without the $components map. Please include `root-variables` prior to this usage." |
73 | 109 | } @else { |
74 | | - $features: set-map-key($features,$key,$value); |
| 110 | + @if type-of($v) != "bool" { |
| 111 | + @error "You may only set a component to TRUE or FALSE, indicating whether it is enabled"; |
| 112 | + } @else { |
| 113 | + $cKey: quote($c); |
| 114 | + @if not(map-has-key($components,$cKey)) { |
| 115 | + $components: set-map-key($components, $cKey, $v); |
| 116 | + } @else { |
| 117 | + $component: map-get($components, $cKey); |
| 118 | + @if type-of($component) == "map" { |
| 119 | + $component: set-map-key($component, "_enabled", $v); |
| 120 | + $components: set-map-key($components, $cKey, $component); |
| 121 | + } @else { |
| 122 | + $components: set-map-key($components, $cKey, $v); |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +@mixin set-component-feature($c, $f, $v) { |
| 130 | + @if not(variable_exists(components)) { |
| 131 | + @error "You may not use the `set-component-feature` mixin prior without the $components map. Please include `root-variables` prior to this usage." |
| 132 | + } @else { |
| 133 | + @if type-of($v) != "bool" { |
| 134 | + @error "You may only set a component feature to TRUE or FALSE, indicating whether it is enabled"; |
| 135 | + } @else { |
| 136 | + $cKey: quote($c); |
| 137 | + @if not(map-has-key($components, $cKey)) { |
| 138 | + @error "The component `#{$c} does not seem to exist in the `$components` map!"; |
| 139 | + } @else { |
| 140 | + $component: map-get($components, $cKey); |
| 141 | + $fKey: quote($f); |
| 142 | + $new : null; |
| 143 | + @if type_of($component) != "map" { |
| 144 | + $new: ("_enabled": $component, $fKey: $v); |
| 145 | + } @else { |
| 146 | + $new: set-map-key($component,$fKey,$v); |
| 147 | + } |
| 148 | + |
| 149 | + $components: set-map-key($components, $cKey, $new); |
| 150 | + } |
| 151 | + } |
75 | 152 | } |
76 | 153 | } |
77 | 154 |
|
|
0 commit comments