@appartmint/css-mint 0.0.37 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,313 @@
1
+ /// selector.scss - Selector utilities
2
+ /// @author App Art Mint LLC
3
+ ///
4
+ /// @group UI
5
+ @charset 'utf-8';
6
+
7
+ /// Imports
8
+ @use 'sass:string';
9
+ @use 'sass:meta';
10
+
11
+ /// Library name
12
+ /// @group Variables
13
+ /// @type String
14
+ $lib: mint !default;
15
+
16
+ /// Prefix added to selectors
17
+ /// @group Variables
18
+ /// @type String
19
+ $pre: #{$lib}-;
20
+
21
+ /// CSS-selector for disabled elements
22
+ /// @group Variables
23
+ /// @type String
24
+ $disabled: #{'[disabled]'};
25
+
26
+ /// CSS-selector for elements with an aria-controls attribute
27
+ /// @group Variables
28
+ /// @type String
29
+ $has-controls: #{'[aria-controls]'};
30
+
31
+ /// CSS-selector for elements with an aria-expanded attribute
32
+ /// @group Variables
33
+ /// @type String
34
+ $has-expanded: #{'[aria-expanded]'};
35
+
36
+ /// CSS-selector for elements with an aria-hidden attribute
37
+ /// @group Variables
38
+ /// @type String
39
+ $has-hidden: #{'[aria-hidden]'};
40
+
41
+ /// CSS-selector for elements with an href attribute
42
+ /// @group Variables
43
+ /// @type String
44
+ $has-link: #{'[href]'};
45
+
46
+ /// CSS-selector for elements with a routerLink attribute
47
+ /// @group Variables
48
+ /// @type String
49
+ $has-router-link: #{'[routerLink]'};
50
+
51
+ /// CSS-selector for elements with an id attribute
52
+ /// @group Variables
53
+ /// @type String
54
+ $has-id: #{'[id]'};
55
+
56
+ /// CSS-selector for elements that aren't tabbable (i.e. tabindex is negative)
57
+ /// @group Variables
58
+ /// @type String
59
+ $not-tabbable: #{'[tabindex^="-"]'};
60
+
61
+ /// CSS-selector for elements that are tabbable (i.e. tabindex isn't negative)
62
+ /// @group Variables
63
+ /// @type String
64
+ $tabbable: #{'[tabindex]'}#{neg($not-tabbable)};
65
+
66
+ /// CSS-selector for submenu buttons
67
+ /// @group Variables
68
+ /// @type String
69
+ $sub-menu-buttons: #{'button'}#{$has-controls};
70
+
71
+ /// CSS-selector for submenus
72
+ /// @group Variables
73
+ /// @type String
74
+ $sub-menu: #{$sub-menu-buttons}#{' + ul'}#{$has-id};
75
+
76
+ /// Prefixes the provided string with the library name if it isn't already
77
+ /// @group Functions
78
+ ///
79
+ /// @param {String} $base - the string to be prefixed
80
+ /// @return {String} - a prefixed string
81
+ @function prefix ($base) {
82
+ @if (meta.type-of($base) != 'string') {
83
+ @error 'The prefix function requires a string value.';
84
+ }
85
+
86
+ $base: string.to-lower-case($base);
87
+
88
+ @if (string.index($base, $pre) != 1) {
89
+ $base: #{$pre}#{$base};
90
+ }
91
+
92
+ @return $base;
93
+ }
94
+
95
+ /// Prefixes the provided string with two dashes and the library name if it isn't already
96
+ /// @group Functions
97
+ ///
98
+ /// @param {String} $base - the string to be prefixed
99
+ /// @return {String} - a prefixed string
100
+ @function css-prefix ($base) {
101
+ @if (meta.type-of($base) != 'string') {
102
+ @error 'The css-prefix function requires a string value.';
103
+ }
104
+
105
+ @while (string.index($base, '-') == 1) {
106
+ $base: string.slice($base, 2);
107
+ }
108
+
109
+ @return '--#{prefix($base)}';
110
+ }
111
+
112
+ /// Creates a CSS-var call for the prefixed `$base`
113
+ /// @group Functions
114
+ ///
115
+ /// @param {String} $base - the CSS-var to create a call for
116
+ /// @return {String} - a CSS-var call
117
+ @function css-var ($base) {
118
+ @if (meta.type-of($base) != 'string') {
119
+ @error 'The css-var function requires a string value.';
120
+ }
121
+
122
+ @if (string.index($base, '--') != 1) {
123
+ $base: css-prefix($base);
124
+ }
125
+
126
+ @return var(#{$base});
127
+ }
128
+
129
+ /// Creates a class selector with the library prefix
130
+ /// @group Functions
131
+ ///
132
+ /// @param {String} $base - the name of the class
133
+ /// @return {String} - a class selector
134
+ @function class($base) {
135
+ @if (meta.type-of($base) != 'string') {
136
+ @error 'The class function requires a string value.';
137
+ }
138
+
139
+ @return '.#{prefix($base)}';
140
+ }
141
+
142
+ /// Creates an id selector with the library prefix
143
+ /// @group Functions
144
+ ///
145
+ /// @param {String} $base - the name of the id
146
+ /// @param {String} $op - the comparison operator
147
+ /// @return {String} - an id selector
148
+ @function id ($base, $op: '=') {
149
+ @if (meta.type-of($base) != 'string') {
150
+ @error 'The id function requires a string value.';
151
+ }
152
+
153
+ @if (meta.type-of($op) != 'string') {
154
+ @error 'The controls function requires a string value for param 2.';
155
+ }
156
+
157
+ @if not($op == '=' or $op == '~=' or $op == '|=' or $op == '^=' or $op == '$=' or $op == '*=') {
158
+ @error 'The controls function requires a valid attribute comparison operator for param 2.';
159
+ }
160
+
161
+ @if ($op == '=') {
162
+ @return '##{prefix($base)}';
163
+ }
164
+
165
+ @return '[id#{$op}#{prefix($base)}]';
166
+ }
167
+
168
+ /// Creates an aria-controls selector with the library prefix
169
+ /// @group Functions
170
+ ///
171
+ /// @param {String} $id - the id of the controlled element
172
+ /// @param {String} $op - the comparison operator
173
+ /// @return {String} - an aria-controls selector
174
+ @function controls ($id, $op: '=') {
175
+ @if (meta.type-of($id) != 'string') {
176
+ @error 'The controls function requires a string value for param 1.';
177
+ }
178
+
179
+ @if (meta.type-of($op) != 'string') {
180
+ @error 'The controls function requires a string value for param 2.';
181
+ }
182
+
183
+ @if not($op == '=' or $op == '~=' or $op == '|=' or $op == '^=' or $op == '$=' or $op == '*=') {
184
+ @error 'The controls function requires a valid attribute comparison operator for param 2.';
185
+ }
186
+
187
+ @return '[aria-controls#{$op}#{prefix($id)}]';
188
+ }
189
+
190
+ /// Creates an aria-expanded selector
191
+ /// @group Functions
192
+ ///
193
+ /// @param {Bool} $bool - the value of the selector
194
+ /// @return {String} - an aria-expanded selector
195
+ @function expanded ($bool) {
196
+ @if (meta.type-of($bool) == 'string') {
197
+ $bool: string.to-lower-case($bool);
198
+
199
+ @if not($bool == 'true' or $bool == 'false') {
200
+ @error 'The expanded function requires a boolean value.';
201
+ }
202
+ }
203
+
204
+ @else if (meta.type-of($bool) != 'bool') {
205
+ @error 'The expanded function requires a boolean value.';
206
+ }
207
+
208
+ @return '[aria-expanded=#{$bool}]';
209
+ }
210
+
211
+ /// Creates an aria-hidden selector
212
+ /// @group Functions
213
+ ///
214
+ /// @param {Bool} $bool - the value of the selector
215
+ /// @return {String} - an aria-hidden selector
216
+ @function hidden ($bool) {
217
+ @if (meta.type-of($bool) == 'string') {
218
+ $bool: string.to-lower-case($bool);
219
+
220
+ @if not($bool == 'true' or $bool == 'false') {
221
+ @error 'The hidden function requires a boolean value. Received: #{$bool}';
222
+ }
223
+ }
224
+
225
+ @else if (meta.type-of($bool) !='bool') {
226
+ @error 'The hidden function requires a boolean value. Received: #{$bool}';
227
+ }
228
+
229
+ @return '[aria-hidden=#{$bool}]';
230
+ }
231
+
232
+ /// Creates a prefixed CSS var definition
233
+ /// @group Mixins
234
+ ///
235
+ /// @param {String} $key - the key of the CSS var
236
+ /// @param {Any} $val - the value of the CSS var
237
+ /// @output a prefixed CSS var definition
238
+ @mixin css-var ($key, $val) {
239
+ @if (meta.type-of($key) != 'string') {
240
+ @error 'The css-var mixin requires a string for the $key argument.';
241
+ }
242
+
243
+ @if (string.index($key, '--') != 1) {
244
+ $key: css-prefix($key);
245
+ }
246
+
247
+ #{$key}: #{$val};
248
+ }
249
+
250
+ /// Creates a prefixed CSS var reference
251
+ /// @group Mixins
252
+ ///
253
+ /// @param {String} $key1 - the key of the new CSS var to define
254
+ /// @param {String} $key2 - the key of the referenced CSS var
255
+ /// @output a prefixed CSS var reference
256
+ @mixin css-var-ref ($key1, $key2) {
257
+ @if (meta.type-of($key1) != 'string' or meta.type-of($key2) != 'string') {
258
+ @error 'The css-var-ref mixin requires string values for both parameters.';
259
+ }
260
+
261
+ @include css-var($key1, css-var($key2));
262
+ }
263
+
264
+ /// Wrap the content in given states
265
+ /// @group Mixins
266
+ ///
267
+ /// @param {String[]} $states - a list of states
268
+ @mixin states ($states...) {
269
+ @if (list.length($states) == 0) {
270
+ @error 'The states mixin requires at least one state parameter.';
271
+ }
272
+ @each $state in $states {
273
+ @if (meta.type-of($state) != 'string') {
274
+ @error 'The states mixin requires a string for each state parameter.';
275
+ }
276
+ }
277
+
278
+ $selectors: ();
279
+
280
+ @if (list.index($states, 'hover') != null) {
281
+ $selectors: list.append($selectors, selector.append(&, ':hover'));
282
+ }
283
+
284
+ @if (list.index($states, 'focus') != null) {
285
+ $selectors: list.append($selectors, selector.append(&, ':focus-visible'));
286
+ }
287
+
288
+ @if (list.index($states, 'active') != null) {
289
+ $selectors: list.append($selectors, selector.append(&, ':active'));
290
+ }
291
+
292
+ @if (list.index($states, 'mint-active') != null) {
293
+ $selectors: list.append($selectors, selector.append(&, class(active)));
294
+ }
295
+
296
+ @if (list.index($states, 'visited') != null) {
297
+ $selectors: list.append($selectors, selector.append(&, ':visited'));
298
+ }
299
+
300
+ @if (list.index($states, 'disabled') != null) {
301
+ $selectors: list.append($selectors, selector.append(&, ':disabled'));
302
+ }
303
+
304
+ @if (list.index($states, 'expanded') != null) {
305
+ $selectors: list.append($selectors, selector.append(&, expanded(true)));
306
+ }
307
+
308
+ @at-root {
309
+ #{$selectors} {
310
+ @content;
311
+ }
312
+ }
313
+ }
@@ -0,0 +1,30 @@
1
+ /// text.scss - Text utilities
2
+ /// @author App Art Mint LLC
3
+ ///
4
+ /// @group UI
5
+ @charset 'utf-8';
6
+
7
+ /// Selector for all headers
8
+ /// @group Mixins
9
+ @mixin headers () {
10
+ @for $i from 1 through 6 {
11
+ h#{$i},
12
+ #{class(h#{$i})} {
13
+ @content;
14
+ }
15
+ }
16
+ }
17
+
18
+ /// Background clip text
19
+ /// @group Mixins
20
+ @mixin background-clip ($color) {
21
+ color: $color;
22
+
23
+ @supports (-webkit-background-clip: text) and (-webkit-text-fill-color: transparent) {
24
+ background: $color;
25
+ @content;
26
+ background-clip: text;
27
+ -webkit-background-clip: text;
28
+ -webkit-text-fill-color: transparent;
29
+ }
30
+ }
@@ -0,0 +1,48 @@
1
+ /// time.scss - Time utilities
2
+ /// @author App Art Mint LLC
3
+ ///
4
+ /// @group UI
5
+ @charset 'utf-8';
6
+
7
+ /// Imports
8
+ @use 'sass:map';
9
+
10
+ /// Value added to all time variables
11
+ /// @group Variables
12
+ /// @type Number
13
+ $time-base: 0 !default;
14
+
15
+ /// Value added to all time variables
16
+ /// @group Variables
17
+ /// @type Number
18
+ $time-step: 100 !default;
19
+
20
+ /// Time variables
21
+ /// @group Maps
22
+ /// @prop {Number} $time.instant [0] - Instant: the quickest time; close or equal to 0
23
+ /// @prop {Number} $time.faster [100] - Faster: times that happen faster
24
+ /// @prop {Number} $time.fast [200] - Fast: times that happen quickly
25
+ /// @prop {Number} $time.default [300] - Default: times that are average
26
+ /// @prop {Number} $time.slow [400] - Slow: times that happen slower
27
+ /// @prop {Number} $time.slower [500] - Slower: times that happen slowly
28
+ $time: (
29
+ instant: $time-base + $time-step * 0,
30
+ faster: $time-base + $time-step * 1,
31
+ fast: $time-base + $time-step * 2,
32
+ default: $time-base + $time-step * 3,
33
+ slow: $time-base + $time-step * 4,
34
+ slower: $time-base + $time-step * 5
35
+ ) !default;
36
+
37
+ /// Returns the requested time value as ms
38
+ /// @group Functions
39
+ ///
40
+ /// @param {Number} $key - the key of the time to use
41
+ /// @return {Number} - the time value as ms
42
+ @function time($key) {
43
+ @if not(map.has-key($time, $key)) {
44
+ @error 'The time function requires one of the following values: #{map.keys($time)}';
45
+ }
46
+
47
+ @return ms(map.get($time, $key));
48
+ }