@import 'variables';
@function __var__($var) {
@return var(--#{$var});
}
@function __get__($map, $keys…) {
@each $key in $keys { $map: map-get($map, $key); } @return $map;
}
@function __fetch__($map, $name) {
@if map-has-key($map, $name) { @return map-get($map, $name); } @else { @error "ERROR: '#{$name}' is not defined"; }
}
@function get-from-theme($theme-name, $keys…) {
@return __get__($themes, $theme-name, $keys...);
}
@function themed-value-exists($category, $key, $raise: true) {
@each $theme-name in map-keys($themes) { @if null == get-from-theme($theme-name, $category, $key) { @if $raise { @error "ERROR: '#{$key}' is missing in #{$category} of the #{$theme-name} theme"; } @else { @return false; } } } @return true;
}
@function themed-value($category, $key) {
@if themed-value-exists($category, $key) { @return __var__('theme-#{$category}-#{$key}'); }
}
@function font-family($key) {
@return themed-value('font-families', $key);
}
@function color($key, $opacity: null) {
@if themed-value-exists('colors', $key, $raise: false) { @if $opacity { @return rgba(themed-value('colors', $key), $opacity); } @else { @return themed-value('colors', $key); } } @if $opacity { @return rgba(__fetch__($colors-flat, $key), $opacity); } @else { @return __fetch__($colors-flat, $key); }
}
@function letter-spacing($key) {
@return __fetch__($letter-spacing, $key);
}
@function line-height($key) {
@return __fetch__($line-heights, $key);
}
@function font-size($key) {
@return __fetch__($font-sizes, $key);
}
@function space($index) {
@return nth($scale, $index + 1);
}
@function z-index($key) {
@return __fetch__($z-indexes, $key);
}
@mixin breakpoint($key) {
@media (min-width: __fetch__($breakpoints, $key)) { @content; }
}