@appartmint/css-mint 0.0.17 → 0.0.18

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appartmint/css-mint",
3
3
  "author": "App Art Mint LLC",
4
- "version": "0.0.17",
4
+ "version": "0.0.18",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Styles by App Art Mint",
@@ -1,3 +1,4 @@
1
1
  @use './form';
2
+ @use './section';
2
3
  @use './ui';
3
4
  @use './widget';
@@ -0,0 +1,21 @@
1
+ /// grid.scss - Grid styles
2
+ /// @author App Art Mint LLC
3
+ ///
4
+ /// @group Section
5
+ @charset 'utf-8';
6
+
7
+ /// Imports
8
+ @use '../../util' as *;
9
+
10
+ :root {
11
+ @include css-var-ref(grid-gap, gap);
12
+ @include css-var-ref(grid-fit-w, xs);
13
+ }
14
+
15
+ #{class(grid)} {
16
+ &-fit {
17
+ display: grid;
18
+ grid-template-columns: repeat(minmax(min(css-var(grid-fit-w), 100%), 1fr));
19
+ gap: css-var(grid-gap);
20
+ }
21
+ }
@@ -0,0 +1 @@
1
+ @use './grid';
@@ -8,7 +8,7 @@
8
8
  @use '../../util' as *;
9
9
 
10
10
  :root {
11
- @include css-var-ref(modal-w, max-sm);
11
+ @include css-var-ref(modal-w, sm);
12
12
  }
13
13
 
14
14
  #{class(modal)} {
@@ -20,6 +20,6 @@
20
20
 
21
21
  /// Widths
22
22
  @each $size, $value in $break {
23
- @include css-var(max-#{$size}, #{$value}px);
23
+ @include css-var(#{$size}, #{$value}px);
24
24
  }
25
25
  }
package/src/util.scss CHANGED
@@ -10,31 +10,17 @@
10
10
  @use 'sass:math';
11
11
  @use 'sass:meta';
12
12
  @use 'sass:string';
13
+ @use 'sass:selector';
13
14
 
14
15
  /// Library name
15
16
  /// @group Variables
16
17
  /// @type String
17
18
  $lib: mint !default;
18
19
 
19
- /// Dash - variable name separator
20
- /// @group Variables
21
- /// @type String
22
- $dash: #{'-'};
23
-
24
20
  /// Prefix added to selectors
25
21
  /// @group Variables
26
22
  /// @type String
27
- $pre: #{$lib}#{$dash};
28
-
29
- /// Dot - added to classes
30
- /// @group Variables
31
- /// @type String
32
- $dot: #{'.'};
33
-
34
- /// Hash - added to ids
35
- /// @group Variables
36
- /// @type String
37
- $hash: #{'#'};
23
+ $pre: #{$lib}-;
38
24
 
39
25
  /// CSS-selector for disabled elements
40
26
  /// @group Variables
@@ -133,27 +119,9 @@ $break: (
133
119
  xl: 1440
134
120
  ) !default;
135
121
 
136
- /// True if Bootstrap5 is used in the project
137
- /// @group Variables
138
- /// @type Boolean
139
- $bootstrap5: false !default;
140
-
141
- @if ($bootstrap5) {
142
- $break: (
143
- sm: 576,
144
- md: 768,
145
- lg: 992,
146
- xl: 1200,
147
- xxl: 1400
148
- ) !default;
149
- }
150
-
151
122
  /// Prefixes the provided string with the library name if it isn't already
152
123
  /// @group Functions
153
124
  ///
154
- /// @example scss - prefix function
155
- /// prefix(header) // -> sun-header
156
- ///
157
125
  /// @param {String} $base - the string to be prefixed
158
126
  /// @return {String} - a prefixed string
159
127
  @function prefix ($base) {
@@ -173,9 +141,6 @@ $bootstrap5: false !default;
173
141
  /// Prefixes the provided string with two dashes and the library name if it isn't already
174
142
  /// @group Functions
175
143
  ///
176
- /// @example scss - css-prefix function
177
- /// css-prefix(background) // -> --sun-background
178
- ///
179
144
  /// @param {String} $base - the string to be prefixed
180
145
  /// @return {String} - a prefixed string
181
146
  @function css-prefix ($base) {
@@ -183,19 +148,16 @@ $bootstrap5: false !default;
183
148
  @error 'The css-prefix function requires a string value.';
184
149
  }
185
150
 
186
- @while (string.index($base, $dash) == 1) {
151
+ @while (string.index($base, '-') == 1) {
187
152
  $base: string.slice($base, 2);
188
153
  }
189
154
 
190
- @return #{$dash}#{$dash}#{prefix($base)};
155
+ @return '--#{prefix($base)}';
191
156
  }
192
157
 
193
158
  /// Creates a CSS-var call for the prefixed `$base`
194
159
  /// @group Functions
195
160
  ///
196
- /// @example scss - css-var function
197
- /// css-var(background) // -> var(--sun-background)
198
- ///
199
161
  /// @param {String} $base - the CSS-var to create a call for
200
162
  /// @return {String} - a CSS-var call
201
163
  @function css-var ($base) {
@@ -213,9 +175,6 @@ $bootstrap5: false !default;
213
175
  /// Creates a class selector with the library prefix
214
176
  /// @group Functions
215
177
  ///
216
- /// @example scss - class function
217
- /// class(open) // -> .sun-open
218
- ///
219
178
  /// @param {String} $base - the name of the class
220
179
  /// @return {String} - a class selector
221
180
  @function class($base) {
@@ -223,15 +182,12 @@ $bootstrap5: false !default;
223
182
  @error 'The class function requires a string value.';
224
183
  }
225
184
 
226
- @return #{$dot}#{prefix($base)};
185
+ @return '.#{prefix($base)}';
227
186
  }
228
187
 
229
188
  /// Creates an id selector with the library prefix
230
189
  /// @group Functions
231
190
  ///
232
- /// @example scss - id function
233
- /// id(header) // -> #sun-header
234
- ///
235
191
  /// @param {String} $base - the name of the id
236
192
  /// @param {String} $op - the comparison operator
237
193
  /// @return {String} - an id selector
@@ -249,7 +205,7 @@ $bootstrap5: false !default;
249
205
  }
250
206
 
251
207
  @if ($op == '=') {
252
- @return #{$hash}#{prefix($base)};
208
+ @return '##{prefix($base)}';
253
209
  }
254
210
 
255
211
  @return '[id#{$op}#{prefix($base)}]';
@@ -258,9 +214,6 @@ $bootstrap5: false !default;
258
214
  /// Creates an aria-controls selector with the library prefix
259
215
  /// @group Functions
260
216
  ///
261
- /// @example scss - controls function
262
- /// controls(header) // -> [aria-controls=sun-header]
263
- ///
264
217
  /// @param {String} $id - the id of the controlled element
265
218
  /// @param {String} $op - the comparison operator
266
219
  /// @return {String} - an aria-controls selector
@@ -283,9 +236,6 @@ $bootstrap5: false !default;
283
236
  /// Creates an aria-expanded selector
284
237
  /// @group Functions
285
238
  ///
286
- /// @example scss - expanded function
287
- /// expanded(true) // -> [aria-expanded=true]
288
- ///
289
239
  /// @param {Bool} $bool - the value of the selector
290
240
  /// @return {String} - an aria-expanded selector
291
241
  @function expanded ($bool) {
@@ -307,9 +257,6 @@ $bootstrap5: false !default;
307
257
  /// Creates an aria-hidden selector
308
258
  /// @group Functions
309
259
  ///
310
- /// @example scss - hidden function
311
- /// hidden(true) // -> [aria-hidden=true]
312
- ///
313
260
  /// @param {Bool} $bool - the value of the selector
314
261
  /// @return {String} - an aria-hidden selector
315
262
  @function hidden ($bool) {
@@ -331,9 +278,6 @@ $bootstrap5: false !default;
331
278
  /// Converts a number to ms
332
279
  /// @group Functions
333
280
  ///
334
- /// @example scss - ms function
335
- /// ms(100) // -> 100ms
336
- ///
337
281
  /// @param {Number} $val - the number of ms to return
338
282
  /// @return {Number} the number as ms
339
283
  @function ms ($val) {
@@ -347,9 +291,6 @@ $bootstrap5: false !default;
347
291
  /// Converts a number to px
348
292
  /// @group Functions
349
293
  ///
350
- /// @example scss - px function
351
- /// px(100) // -> 100px
352
- ///
353
294
  /// @param {Number} $val - the number of px to return
354
295
  /// @return {Number} - the number as px
355
296
  @function px ($val) {
@@ -363,9 +304,6 @@ $bootstrap5: false !default;
363
304
  /// Removes the unit from the given value
364
305
  /// @group Functions
365
306
  ///
366
- /// @example scss - strip-unit function
367
- /// strip-unit(100px) // -> 100
368
- ///
369
307
  /// @param {Number} $val - the value to strip
370
308
  /// @return {Number} - the number without units
371
309
  @function strip-unit($val) {
@@ -379,9 +317,6 @@ $bootstrap5: false !default;
379
317
  /// Returns the percentage of the given values
380
318
  /// @group Functions
381
319
  ///
382
- /// @example scss - percent function
383
- /// percent(100, 200) // -> 50%
384
- ///
385
320
  /// @param {Number} $dividend - the value that will be devided
386
321
  /// @param {Number} $divisor - the value that will devided by
387
322
  /// @return {Number} - the percentage of the given values
@@ -406,9 +341,6 @@ $bootstrap5: false !default;
406
341
  /// Returns the requested delay value as ms
407
342
  /// @group Functions
408
343
  ///
409
- /// @example scss - delay function
410
- /// delay(default) // -> 300ms
411
- ///
412
344
  /// @param {Number} $key - the key of the delay to use
413
345
  /// @return {Number} - the delay value as ms
414
346
  @function delay($key) {
@@ -422,9 +354,6 @@ $bootstrap5: false !default;
422
354
  /// Returns the requested breakpoint value as px
423
355
  /// @group Functions
424
356
  ///
425
- /// @example scss - break function
426
- /// break(md) // -> 1024px
427
- ///
428
357
  /// @param {Number} $key - the key of the breakpoint to use
429
358
  /// @return {Number} - the breakpoint value as px
430
359
  @function break($key) {
@@ -438,9 +367,6 @@ $bootstrap5: false !default;
438
367
  /// Creates a prefixed CSS var definition
439
368
  /// @group Mixins
440
369
  ///
441
- /// @example scss - css-var mixin
442
- /// @include css-var(bg, black) // -> --sun-bg: black;
443
- ///
444
370
  /// @param {String} $key - the key of the CSS var
445
371
  /// @param {Any} $val - the value of the CSS var
446
372
  /// @output a prefixed CSS var definition
@@ -459,9 +385,6 @@ $bootstrap5: false !default;
459
385
  /// Creates a prefixed CSS var reference
460
386
  /// @group Mixins
461
387
  ///
462
- /// @example scss - css-var-ref mixin
463
- /// @include css-var-ref(fill, bg) // -> --sun-fill: var(--sun-bg);
464
- ///
465
388
  /// @param {String} $key1 - the key of the new CSS var to define
466
389
  /// @param {String} $key2 - the key of the referenced CSS var
467
390
  /// @output a prefixed CSS var reference
@@ -476,11 +399,6 @@ $bootstrap5: false !default;
476
399
  /// Wraps the provided content in a media query
477
400
  /// @group Mixins
478
401
  ///
479
- /// @example scss - break mixin
480
- /// @include break(md) { // -> @media (min-width: 1024px) {
481
- /// display: none; // display: none;
482
- /// } // }
483
- ///
484
402
  /// @param {String} $min - the key of the breakpoint to use with min-width
485
403
  /// @param {String} $max - the key of the breakpoint to use with max-width
486
404
  /// @output the provided content wrapped in a media query
@@ -524,37 +442,6 @@ $bootstrap5: false !default;
524
442
  /// Creates utility selectors for a given property at each breakpoint
525
443
  /// @group Mixins
526
444
  ///
527
- /// @example scss- break-util mixin
528
- /// @include break-util(display, flex); // -> & {
529
- /// // display: flex;
530
- /// //
531
- /// // &-xs {
532
- /// // display: none;
533
- /// // @include break(xs) {
534
- /// // display: flex;
535
- /// // }
536
- /// // }
537
- /// // &-to-xs {
538
- /// // display: flex;
539
- /// // @include break(xs) {
540
- /// // display: none;
541
- /// // }
542
- /// // }
543
- /// // ...
544
- /// // &-xl {
545
- /// // display: none;
546
- /// // @include break(xl) {
547
- /// // display: flex;
548
- /// // }
549
- /// // }
550
- /// // &-to-xl {
551
- /// // display: flex;
552
- /// // @include break(xl) {
553
- /// // display: none;
554
- /// // }
555
- /// // }
556
- /// // }
557
- ///
558
445
  /// @param {String} $prop - the property to toggle
559
446
  /// @param {Any} $val - the active value of the property
560
447
  /// @param {Any} $none - the inactive value of the property
@@ -564,25 +451,22 @@ $bootstrap5: false !default;
564
451
  @error 'The break-util mixin requires a string for the $prop argument.';
565
452
  }
566
453
 
567
- & {
568
- #{$prop}: #{$val};
454
+ #{$prop}: #{$val};
569
455
 
570
- @each $key,
571
- $width in $break {
572
- &-#{$key} {
573
- #{$prop}: #{$none};
456
+ @each $key, $width in $break {
457
+ &-#{$key} {
458
+ #{$prop}: #{$none};
574
459
 
575
- @include break($key) {
576
- #{$prop}: #{$val};
577
- }
460
+ @include break($key) {
461
+ #{$prop}: #{$val};
578
462
  }
463
+ }
579
464
 
580
- &-to-#{$key} {
581
- #{$prop}: #{$val};
465
+ &-to-#{$key} {
466
+ #{$prop}: #{$val};
582
467
 
583
- @include break($key) {
584
- #{$prop}: #{$none};
585
- }
468
+ @include break($key) {
469
+ #{$prop}: #{$none};
586
470
  }
587
471
  }
588
472
  }
@@ -805,53 +689,52 @@ $bootstrap5: false !default;
805
689
  }
806
690
  }
807
691
 
808
- /// TODO: Document this
692
+ /// Wrap the content in given states
693
+ /// @group Mixins
694
+ ///
695
+ /// @param {String[]} $states - a list of states
809
696
  @mixin states ($states...) {
697
+ @if (list.length($states) == 0) {
698
+ @error 'The states mixin requires at least one state parameter.';
699
+ }
810
700
  @each $state in $states {
811
701
  @if (meta.type-of($state) != 'string') {
812
- @error 'The states mixin requires a string for each state argument.';
702
+ @error 'The states mixin requires a string for each state parameter.';
813
703
  }
814
704
  }
815
705
 
706
+ $selectors: ();
707
+
816
708
  @if (list.index($states, 'hover') != null) {
817
- &:hover {
818
- @content;
819
- }
709
+ $selectors: list.append($selectors, selector.append(&, ':hover'));
820
710
  }
821
711
 
822
712
  @if (list.index($states, 'focus') != null) {
823
- &:focus-visible {
824
- @content;
825
- }
713
+ $selectors: list.append($selectors, selector.append(&, ':focus-visible'));
826
714
  }
827
715
 
828
716
  @if (list.index($states, 'active') != null) {
829
-
830
- &:active {
831
- @content;
832
- }
717
+ $selectors: list.append($selectors, selector.append(&, ':active'));
833
718
  }
834
719
 
835
720
  @if (list.index($states, 'mint-active') != null) {
836
- &#{class(active)} {
837
- @content;
838
- }
721
+ $selectors: list.append($selectors, selector.append(&, class(active)));
839
722
  }
840
723
 
841
724
  @if (list.index($states, 'visited') != null) {
842
- &:visited {
843
- @content;
844
- }
725
+ $selectors: list.append($selectors, selector.append(&, ':visited'));
845
726
  }
846
727
 
847
728
  @if (list.index($states, 'disabled') != null) {
848
- &:disabled {
849
- @content;
850
- }
729
+ $selectors: list.append($selectors, selector.append(&, ':disabled'));
851
730
  }
852
731
 
853
732
  @if (list.index($states, 'expanded') != null) {
854
- &#{expanded(true)} {
733
+ $selectors: list.append($selectors, selector.append(&, expanded(true)));
734
+ }
735
+
736
+ @at-root {
737
+ #{$selectors} {
855
738
  @content;
856
739
  }
857
740
  }