diff options
Diffstat (limited to 'src/_utils.scss')
-rw-r--r-- | src/_utils.scss | 251 |
1 files changed, 251 insertions, 0 deletions
diff --git a/src/_utils.scss b/src/_utils.scss new file mode 100644 index 0000000..fdec622 --- /dev/null +++ b/src/_utils.scss | |||
@@ -0,0 +1,251 @@ | |||
1 | @use 'sass:map'; | ||
2 | @use 'iro-sass/src/iro-sass' as iro; | ||
3 | @use 'include-media/dist/include-media' as media; | ||
4 | @use 'props'; | ||
5 | |||
6 | @use 'core.vars' as vars; | ||
7 | @forward 'core.vars'; | ||
8 | |||
9 | /* stylelint-disable-next-line scss/dollar-variable-pattern */ | ||
10 | $-dirs: ( | ||
11 | '': '', | ||
12 | 'bs': '-block-start', | ||
13 | 'be': '-block-end', | ||
14 | 'b': '-block', | ||
15 | 'is': '-inline-start', | ||
16 | 'ie': '-inline-end', | ||
17 | 'i': '-inline', | ||
18 | ) !default; | ||
19 | |||
20 | /* stylelint-disable-next-line scss/dollar-variable-pattern */ | ||
21 | $-sizes: ( | ||
22 | 0: vars.$size--0, | ||
23 | 10: vars.$size--10, | ||
24 | 50: vars.$size--50, | ||
25 | 75: vars.$size--75, | ||
26 | 100: vars.$size--100, | ||
27 | 125: vars.$size--125, | ||
28 | 200: vars.$size--200, | ||
29 | 400: vars.$size--400, | ||
30 | 700: vars.$size--700, | ||
31 | 800: vars.$size--800, | ||
32 | ) !default; | ||
33 | |||
34 | @mixin styles { | ||
35 | @include iro.bem-utility('d-block') { | ||
36 | display: block; | ||
37 | } | ||
38 | |||
39 | @include iro.bem-utility('d-inline-block') { | ||
40 | display: inline-block; | ||
41 | } | ||
42 | |||
43 | @include iro.bem-utility('d-contents') { | ||
44 | display: contents; | ||
45 | } | ||
46 | |||
47 | @include iro.bem-utility('td-none') { | ||
48 | text-decoration: none; | ||
49 | } | ||
50 | |||
51 | @include iro.bem-utility('d-none') { | ||
52 | display: none; | ||
53 | |||
54 | @each $breakpoint in map.keys(media.$breakpoints) { | ||
55 | @include media.media('<=#{$breakpoint}') { | ||
56 | @include iro.bem-suffix('#{$breakpoint}-lo') { | ||
57 | display: none; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | @include media.media('>#{$breakpoint}') { | ||
62 | @include iro.bem-suffix('#{$breakpoint}-hi') { | ||
63 | display: none; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | @include iro.bem-at-theme('js') { | ||
69 | @include iro.bem-suffix('js') { | ||
70 | display: none; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | @include iro.bem-at-theme('no-js') { | ||
75 | @include iro.bem-suffix('no-js') { | ||
76 | display: none; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | @include iro.bem-suffix('empty') { | ||
81 | &:empty { | ||
82 | display: none; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | @include iro.bem-utility('ta-start') { | ||
88 | text-align: start; | ||
89 | } | ||
90 | |||
91 | @include iro.bem-utility('ta-end') { | ||
92 | text-align: end; | ||
93 | } | ||
94 | |||
95 | @include iro.bem-utility('ta-center') { | ||
96 | text-align: center; | ||
97 | } | ||
98 | |||
99 | @include iro.bem-utility('fw-normal') { | ||
100 | font-weight: normal; | ||
101 | } | ||
102 | |||
103 | @include iro.bem-utility('ai-center') { | ||
104 | align-items: center; | ||
105 | } | ||
106 | |||
107 | @include iro.bem-utility('ai-start') { | ||
108 | align-items: flex-start; | ||
109 | } | ||
110 | |||
111 | @include iro.bem-utility('ai-end') { | ||
112 | align-items: flex-end; | ||
113 | } | ||
114 | |||
115 | @include iro.bem-utility('jc-center') { | ||
116 | justify-content: center; | ||
117 | } | ||
118 | |||
119 | @include iro.bem-utility('jc-start') { | ||
120 | justify-content: flex-start; | ||
121 | } | ||
122 | |||
123 | @include iro.bem-utility('jc-end') { | ||
124 | justify-content: flex-end; | ||
125 | } | ||
126 | |||
127 | @include iro.bem-utility('c-heading') { | ||
128 | color: props.get(vars.$theme, --heading); | ||
129 | } | ||
130 | |||
131 | @include iro.bem-utility('c-text') { | ||
132 | color: props.get(vars.$theme, --text); | ||
133 | } | ||
134 | |||
135 | @include iro.bem-utility('c-mute') { | ||
136 | color: props.get(vars.$theme, --text-mute); | ||
137 | } | ||
138 | |||
139 | @include iro.bem-utility('c-mute-more') { | ||
140 | color: props.get(vars.$theme, --text-mute-more); | ||
141 | } | ||
142 | |||
143 | @each $dir, $prop in (is: inline-size, bs: block-size) { | ||
144 | @include iro.bem-utility('#{$dir}-100') { | ||
145 | #{$prop}: 100%; | ||
146 | } | ||
147 | |||
148 | @include iro.bem-utility('#{$dir}-75') { | ||
149 | #{$prop}: 75%; | ||
150 | } | ||
151 | |||
152 | @include iro.bem-utility('#{$dir}-50') { | ||
153 | #{$prop}: 50%; | ||
154 | } | ||
155 | |||
156 | @include iro.bem-utility('#{$dir}-25') { | ||
157 | #{$prop}: 25%; | ||
158 | } | ||
159 | |||
160 | @include iro.bem-utility('#{$dir}-1px') { | ||
161 | #{$prop}: 1px; | ||
162 | } | ||
163 | |||
164 | @include iro.bem-utility('#{$dir}-0') { | ||
165 | #{$prop}: 0; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | @include iro.bem-utility('elp') { | ||
170 | overflow: hidden; | ||
171 | text-overflow: ellipsis; | ||
172 | white-space: nowrap; | ||
173 | } | ||
174 | |||
175 | @include iro.bem-utility('p-static') { | ||
176 | position: static; | ||
177 | } | ||
178 | |||
179 | @include iro.bem-utility('p-relative') { | ||
180 | position: relative; | ||
181 | } | ||
182 | |||
183 | @include iro.bem-utility('p-fixed') { | ||
184 | position: fixed; | ||
185 | } | ||
186 | |||
187 | @include iro.bem-utility('p-sticky-bs') { | ||
188 | position: sticky; | ||
189 | inset-block-start: 0; | ||
190 | } | ||
191 | |||
192 | @each $dir, $suffix in $-dirs { | ||
193 | @include iro.bem-utility('m#{$dir}-auto') { | ||
194 | margin#{$suffix}: auto; | ||
195 | } | ||
196 | |||
197 | @include iro.bem-utility('p#{$dir}-auto') { | ||
198 | padding#{$suffix}: auto; | ||
199 | } | ||
200 | |||
201 | @each $mod, $size in $-sizes { | ||
202 | @include iro.bem-utility('m#{$dir}-#{$mod}') { | ||
203 | margin#{$suffix}: props.get($size); | ||
204 | } | ||
205 | |||
206 | @include iro.bem-utility('p#{$dir}-#{$mod}') { | ||
207 | padding#{$suffix}: props.get($size); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | @include iro.bem-utility('b#{$dir}-0') { | ||
212 | border#{$suffix}: 0; | ||
213 | |||
214 | @include iro.bem-suffix('light') { | ||
215 | @media (prefers-color-scheme: light) { | ||
216 | border#{$suffix}: 0; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | @include iro.bem-suffix('dark') { | ||
221 | @media (prefers-color-scheme: dark) { | ||
222 | border#{$suffix}: 0; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | @include iro.bem-utility('b#{$dir}-1') { | ||
228 | border#{$suffix}: props.get(vars.$border-width--thin) solid props.get(vars.$theme, --border); | ||
229 | |||
230 | @include iro.bem-suffix('light') { | ||
231 | @media (prefers-color-scheme: light) { | ||
232 | border#{$suffix}: props.get(vars.$border-width--thin) solid props.get(vars.$theme, --border); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | @include iro.bem-suffix('dark') { | ||
237 | @media (prefers-color-scheme: dark) { | ||
238 | border#{$suffix}: props.get(vars.$border-width--thin) solid props.get(vars.$theme, --border); | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | |||
244 | @include iro.bem-utility('mbs-neutralize') { | ||
245 | &::before { | ||
246 | display: block; | ||
247 | margin-block: -100em 100em; | ||
248 | content: ''; | ||
249 | } | ||
250 | } | ||
251 | } | ||