summaryrefslogtreecommitdiffstats
path: root/src/objects/_palette.scss
blob: 88448e07fb1a7928fc05bf1976a122aef838aa74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@use "sass:list";
@use "sass:map";
@use "sass:string";
@use "pkg:iro-sass/bem";
@use "../config";
@use "pkg:iro-sass/props";
@use "../core.vars" as core;

@mixin styles {
	@include bem.object("palette") {
		display: flex;
		block-size: 3em;

		@include bem.elem("item") {
			flex: 1 1 auto;

			$palette: map.get(config.$themes, config.$theme-default, light, --palettes, --base);
			$levels: map.get(
				config.$themes,
				config.$theme-default,
				light,
				--levels,
				list.nth($palette, 2)
			);

			@for $i from 1 through list.length($levels) {
				$key: list.nth(map.keys($levels), $i);

				&:nth-child(#{$i}) {
					background-color: props.get(core.$theme, --base, $key);
				}
			}
		}

		@each $palette-name,
			$palette in map.get(config.$themes, config.$theme-default, light, --palettes)
		{
			$levels: map.get(
				config.$themes,
				config.$theme-default,
				light,
				--levels,
				list.nth($palette, 2)
			);

			@include bem.modifier(string.slice($palette-name, 3)) {
				@include bem.elem("item") {
					@for $i from 1 through list.length($levels) {
						$key: list.nth(map.keys($levels), $i);

						&:nth-child(#{$i}) {
							background-color: props.get(core.$theme, $palette-name, $key);
						}
					}
				}
			}
		}

		@include bem.modifier("static") {
			@each $palette-name, $palette in map.get(config.$static-colors, --palettes) {
				$levels: map.get(config.$static-colors, --levels);

				@include bem.modifier(string.slice($palette-name, 3)) {
					@include bem.elem("item") {
						@for $i from 1 through list.length($levels) {
							$key: list.nth(map.keys($levels), $i);

							&:nth-child(#{$i}) {
								background-color: props.get(
									core.$theme,
									#{$palette-name}-static,
									$key
								);
							}
						}
					}
				}
			}
		}
	}
}