summaryrefslogtreecommitdiffstats
path: root/src/scopes/_headings.scss
blob: a6a7bbbc099bd96e5eea5e6b4391cedaa4dd15fb (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@use "sass:map";
@use "sass:string";
@use "pkg:iro-sass/bem";
@use "pkg:iro-sass/props";
@use "../objects/heading.vars" as heading;

@mixin styles {
	/* stylelint-disable-next-line scss/dollar-variable-pattern */
	$-size-map: (
		xs: h6,
		sm: h5,
		md: h4,
		lg: h3,
		xl: h2,
		xxl: h1,
	);

	@include bem.scope("headings") {
		h1,
		h2,
		h3,
		h4,
		h5,
		h6 {
			display: block;
			margin-block-start: props.get(heading.$margin-bs);
			font-family: props.get(heading.$font-family);
			font-weight: props.get(heading.$font-weight);
			font-feature-settings: props.get(heading.$feature-settings);
			line-height: props.get(heading.$line-height);
			text-transform: props.get(heading.$text-transform);
			letter-spacing: normal;
			transform: translateX(props.get(heading.$offset));
		}

		@include bem.elem("highlight") {
			background-image: linear-gradient(
				to top,
				transparent 0.15em,
				props.get(heading.$bg-color) 0.15em,
				props.get(heading.$bg-color) 0.6em,
				transparent 0.6em
			);
		}

		@each $mod, $font-family, $line-height, $font-size, $font-weight, $letter-spacing,
			$feature-settings, $text-transform, $text-color in heading.$sizes
		{
			#{map.get($-size-map, $mod)} {
				font-family: props.get($font-family);
				font-size: props.get($font-size);
				font-weight: props.get($font-weight);
				font-feature-settings: props.get($feature-settings);
				line-height: props.get($line-height);
				color: props.get($text-color);
				text-transform: props.get($text-transform);
				letter-spacing: props.get($letter-spacing);
			}
		}

		@include bem.modifier("display") {
			@each $mod, $font-family, $line-height, $font-size, $font-weight, $letter-spacing,
				$feature-settings, $text-transform, $text-color in heading.$display--sizes
			{
				#{map.get($-size-map, $mod)} {
					font-family: props.get($font-family);
					font-size: props.get($font-size);
					font-weight: props.get($font-weight);
					font-feature-settings: props.get($feature-settings);
					line-height: props.get($line-height);
					color: props.get($text-color);
					text-transform: props.get($text-transform);
					letter-spacing: props.get($letter-spacing);
				}
			}
		}

		@each $theme in map.keys(props.get(heading.$static-themes)) {
			@include bem.modifier(string.slice($theme, 3)) {
				color: props.get(heading.$static-themes, $theme, --text-color);

				@each $mod, $value in heading.$sizes {
					#{map.get($-size-map, $mod)} {
						color: props.get(heading.$static-themes, $theme, --#{$mod}, --text-color);
					}
				}

				@include bem.modifier("display") {
					@each $mod, $value in heading.$sizes {
						#{map.get($-size-map, $mod)} {
							color: props.get(
								heading.$static-themes,
								$theme,
								--display,
								--#{$mod},
								--text-color
							);
						}
					}
				}
			}
		}
	}
}