@nuvoui/core 1.1.6 → 1.1.8

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.
@@ -3,15 +3,102 @@
3
3
  @use 'sass:meta';
4
4
  @use './variables' as *;
5
5
 
6
+
7
+ /**
8
+ * @component Spacing
9
+ * @description Controls element margins, padding, gaps, and spacing between children
10
+ *
11
+ * @example
12
+ * <!-- Padding -->
13
+ * <div class="p-4">All sides padding</div>
14
+ * <div class="px-4 py-2">Horizontal and vertical padding</div>
15
+ * <div class="pt-2 pb-4">Top and bottom padding</div>
16
+ *
17
+ * <!-- Margins -->
18
+ * <div class="m-4">All sides margin</div>
19
+ * <div class="mt-4">Top margin only</div>
20
+ * <div class="mx-auto">Horizontally centered</div>
21
+ *
22
+ * <!-- Gap (for flex/grid containers) -->
23
+ * <div class="flex gap-4">
24
+ * <div>Item 1</div>
25
+ * <div>Item 2</div>
26
+ * </div>
27
+ *
28
+ * <!-- Responsive spacing -->
29
+ * <div class="p-2 p-4@md p-6@lg">
30
+ * Padding increases at each breakpoint
31
+ * </div>
32
+ *
33
+ * <!-- Child spacing -->
34
+ * <div class="space-y-4">
35
+ * <div>First child</div>
36
+ * <div>Second child (margin-top: 1rem)</div>
37
+ * <div>Third child (margin-top: 1rem)</div>
38
+ * </div>
39
+ *
40
+ * @classes
41
+ * Padding:
42
+ * - p-{size}: Padding on all sides
43
+ * - px-{size}: Horizontal padding (left and right)
44
+ * - py-{size}: Vertical padding (top and bottom)
45
+ * - pt-{size}, pr-{size}, pb-{size}, pl-{size}: Individual side padding
46
+ *
47
+ * Margin:
48
+ * - m-{size}: Margin on all sides
49
+ * - mx-{size}: Horizontal margin (left and right)
50
+ * - my-{size}: Vertical margin (top and bottom)
51
+ * - mt-{size}, mr-{size}, mb-{size}, ml-{size}: Individual side margin
52
+ * - mx-auto, ml-auto, mr-auto: Auto margin for alignment
53
+ *
54
+ * Gap:
55
+ * - gap-{size}: Gap between flex/grid children (all directions)
56
+ * - gap-x-{size}: Horizontal gap between children (column-gap)
57
+ * - gap-y-{size}: Vertical gap between children (row-gap)
58
+ *
59
+ * Child Spacing:
60
+ * - space-x-{size}: Horizontal space between children
61
+ * - space-y-{size}: Vertical space between children
62
+ *
63
+ * @responsive
64
+ * All spacing classes support responsive variants using @breakpoint suffix:
65
+ * - p-4@md: 1rem padding on medium screens and up
66
+ * - mt-8@lg: 2rem top margin on large screens
67
+ * - gap-2@xl: 0.5rem gap on extra large screens
68
+ *
69
+ * @customization
70
+ * Spacing values are defined in the $spacings map in variables.scss
71
+ * Typically follows a scale where higher numbers mean more spacing
72
+ *
73
+ * @see flex, grid, display
74
+ */
75
+
76
+ //-----------------------------------------------
77
+ // HELPER FUNCTIONS
78
+ //-----------------------------------------------
79
+
80
+ /**
81
+ * @function format-unit-value
82
+ * @description Ensures values have appropriate units
83
+ * @param {Number|String} $value - The value to format
84
+ * @returns {Number|String} Value with appropriate units
85
+ * @internal
86
+ */
87
+
6
88
  @function format-unit-value($value) {
7
89
  // Zero check
8
90
  @if $value == 0 {
9
91
  @return 0;
10
92
  }
11
93
 
12
- // If pure number, add px
13
- @if meta.type-of($value) == 'number' {
14
- @return $value + px;
94
+ // If pure number (no units), add px
95
+ @if meta.type-of($value) == 'number' and math.unit($value) == "" {
96
+ @return $value * 1px; // Multiply by 1px instead of adding px
97
+ }
98
+
99
+ // If number with units (like rem), return as is
100
+ @if meta.type-of($value) == 'number' and math.unit($value) != "" {
101
+ @return $value; // Already has units, return as is
15
102
  }
16
103
 
17
104
  // Convert value to string for unit checking
@@ -20,78 +107,243 @@
20
107
  @return $value-str;
21
108
  }
22
109
 
23
- // Padding mixins
110
+
111
+ //-----------------------------------------------
112
+ // PADDING MIXINS
113
+ //-----------------------------------------------
114
+
115
+ /**
116
+ * @mixin p
117
+ * @description Sets padding on all sides
118
+ * @param {Number|String} $val - Padding value
119
+ */
24
120
  @mixin p($val) { padding: format-unit-value($val); }
25
- @mixin px($val) { $val: format-unit-value($val); padding-left: $val; padding-right: $val; }
26
- @mixin py($val) { $val: format-unit-value($val); padding-top: $val; padding-bottom: $val; }
121
+
122
+ /**
123
+ * @mixin px
124
+ * @description Sets horizontal padding (left and right)
125
+ * @param {Number|String} $val - Padding value
126
+ */
127
+ @mixin px($val) {
128
+ $val: format-unit-value($val);
129
+ padding-left: $val;
130
+ padding-right: $val;
131
+ }
132
+
133
+ /**
134
+ * @mixin py
135
+ * @description Sets vertical padding (top and bottom)
136
+ * @param {Number|String} $val - Padding value
137
+ */
138
+ @mixin py($val) {
139
+ $val: format-unit-value($val);
140
+ padding-top: $val;
141
+ padding-bottom: $val;
142
+ }
143
+
144
+ /**
145
+ * @mixin pt
146
+ * @description Sets padding-top
147
+ * @param {Number|String} $val - Padding value
148
+ */
27
149
  @mixin pt($val) { $val: format-unit-value($val); padding-top: $val; }
150
+
151
+ /**
152
+ * @mixin pr
153
+ * @description Sets padding-right
154
+ * @param {Number|String} $val - Padding value
155
+ */
28
156
  @mixin pr($val) { $val: format-unit-value($val); padding-right: $val; }
157
+
158
+ /**
159
+ * @mixin pb
160
+ * @description Sets padding-bottom
161
+ * @param {Number|String} $val - Padding value
162
+ */
29
163
  @mixin pb($val) { $val: format-unit-value($val); padding-bottom: $val; }
164
+
165
+ /**
166
+ * @mixin pl
167
+ * @description Sets padding-left
168
+ * @param {Number|String} $val - Padding value
169
+ */
30
170
  @mixin pl($val) { $val: format-unit-value($val); padding-left: $val; }
31
171
 
32
- // Margin mixins
172
+ //-----------------------------------------------
173
+ // MARGIN MIXINS
174
+ //-----------------------------------------------
175
+
176
+ /**
177
+ * @mixin m
178
+ * @description Sets margin on all sides
179
+ * @param {Number|String} $val - Margin value
180
+ */
33
181
  @mixin m($val) { $val: format-unit-value($val); margin: $val; }
34
- @mixin mx($val) { $val: format-unit-value($val); margin-left: $val; margin-right: $val; }
35
- @mixin my($val) { $val: format-unit-value($val); margin-top: $val; margin-bottom: $val; }
182
+
183
+ /**
184
+ * @mixin mx
185
+ * @description Sets horizontal margin (left and right)
186
+ * @param {Number|String} $val - Margin value
187
+ */
188
+ @mixin mx($val) {
189
+ $val: format-unit-value($val);
190
+ margin-left: $val;
191
+ margin-right: $val;
192
+ }
193
+
194
+ /**
195
+ * @mixin my
196
+ * @description Sets vertical margin (top and bottom)
197
+ * @param {Number|String} $val - Margin value
198
+ */
199
+ @mixin my($val) {
200
+ $val: format-unit-value($val);
201
+ margin-top: $val;
202
+ margin-bottom: $val;
203
+ }
204
+
205
+ /**
206
+ * @mixin mt
207
+ * @description Sets margin-top
208
+ * @param {Number|String} $val - Margin value
209
+ */
36
210
  @mixin mt($val) { $val: format-unit-value($val); margin-top: $val; }
211
+
212
+ /**
213
+ * @mixin mr
214
+ * @description Sets margin-right
215
+ * @param {Number|String} $val - Margin value
216
+ */
37
217
  @mixin mr($val) { $val: format-unit-value($val); margin-right: $val; }
218
+
219
+ /**
220
+ * @mixin mb
221
+ * @description Sets margin-bottom
222
+ * @param {Number|String} $val - Margin value
223
+ */
38
224
  @mixin mb($val) { $val: format-unit-value($val); margin-bottom: $val; }
225
+
226
+ /**
227
+ * @mixin ml
228
+ * @description Sets margin-left
229
+ * @param {Number|String} $val - Margin value
230
+ */
39
231
  @mixin ml($val) { $val: format-unit-value($val); margin-left: $val; }
40
232
 
41
- // Auto margin utilities
233
+ /**
234
+ * @mixin ml-auto
235
+ * @description Sets margin-left to auto
236
+ */
42
237
  @mixin ml-auto { margin-left: auto; }
238
+
239
+ /**
240
+ * @mixin mr-auto
241
+ * @description Sets margin-right to auto
242
+ */
43
243
  @mixin mr-auto { margin-right: auto; }
244
+
245
+ /**
246
+ * @mixin mx-auto
247
+ * @description Centers element horizontally using auto margins
248
+ */
44
249
  @mixin mx-auto { @include ml-auto; @include mr-auto; }
45
250
 
46
- // Spacing map
47
- @mixin space-y($i) { & > * + * { margin-top: if($i == 0, 0, $i + px); } }
48
- @mixin space-x($i) { & > * + * { margin-left: if($i == 0, 0, $i + px); } }
49
251
 
252
+ //-----------------------------------------------
253
+ // SPACING MIXINS
254
+ //-----------------------------------------------
255
+
256
+ /**
257
+ * @mixin space-y
258
+ * @description Adds vertical spacing between direct children
259
+ * @param {Number|String} $i - Space amount
260
+ */
261
+ @mixin space-y($i) { & > * + * { $i: format-unit-value($i); margin-top: $i; } }
50
262
 
51
- // Gap Mixins
52
- @mixin gap($value) { gap: if($value == 0, $value, $value + px); }
53
- @mixin gap-x($value) { column-gap: if($value == 0, $value, $value + px); }
54
- @mixin gap-y($value) { row-gap: if($value == 0, $value, $value + px); }
263
+ /**
264
+ * @mixin space-x
265
+ * @description Adds horizontal spacing between direct children
266
+ * @param {Number|String} $i - Space amount
267
+ */
268
+ @mixin space-x($i) { & > * + * { $i: format-unit-value($i); margin-left: $i; } }
269
+
270
+ //-----------------------------------------------
271
+ // GAP MIXINS
272
+ //-----------------------------------------------
273
+
274
+ /**
275
+ * @mixin gap
276
+ * @description Sets gap between grid/flex children
277
+ * @param {Number|String} $val - Gap value
278
+ */
279
+ @mixin gap($val) { $val: format-unit-value($val); gap: $val; }
280
+
281
+ /**
282
+ * @mixin gap-x
283
+ * @description Sets horizontal gap between grid/flex children
284
+ * @param {Number|String} $val - Gap value
285
+ */
286
+ @mixin gap-x($val) { $val: format-unit-value($val); column-gap: $val; }
287
+
288
+ /**
289
+ * @mixin gap-y
290
+ * @description Sets vertical gap between grid/flex children
291
+ * @param {Number|String} $val - Gap value
292
+ */
293
+ @mixin gap-y($val) { $val: format-unit-value($val); row-gap: $val; }
294
+
295
+ //-----------------------------------------------
296
+ // AUTO MARGIN UTILITY CLASSES
297
+ //-----------------------------------------------
55
298
 
56
299
  .mx-auto { @include mx-auto; }
57
300
  .ml-auto { @include ml-auto; }
58
301
  .mr-auto { @include mr-auto; }
59
302
 
60
- // Gap Classes
303
+ //-----------------------------------------------
304
+ // GAP AUTO CLASS
305
+ //-----------------------------------------------
306
+
61
307
  .gap-auto { gap: auto; }
62
308
 
63
- // Generate utilities from spacing map
64
- @each $i in $spacings {
309
+ //-----------------------------------------------
310
+ // SPACING CLASSES
311
+ //-----------------------------------------------
312
+
313
+ @each $key, $value in $spacings {
65
314
  // Padding classes
66
- .p-#{$i} { @include p($i); }
67
- .px-#{$i} { @include px($i); }
68
- .py-#{$i} { @include py($i); }
69
- .pt-#{$i} { @include pt($i); }
70
- .pr-#{$i} { @include pr($i); }
71
- .pb-#{$i} { @include pb($i); }
72
- .pl-#{$i} { @include pl($i); }
315
+ .p-#{$key} { @include p($value); }
316
+ .px-#{$key} { @include px($value); }
317
+ .py-#{$key} { @include py($value); }
318
+ .pt-#{$key} { @include pt($value); }
319
+ .pr-#{$key} { @include pr($value); }
320
+ .pb-#{$key} { @include pb($value); }
321
+ .pl-#{$key} { @include pl($value); }
73
322
 
74
323
  // Margin classes
75
- .m-#{$i} { @include m($i); }
76
- .mx-#{$i} { @include mx($i); }
77
- .my-#{$i} { @include my($i); }
78
- .mt-#{$i} { @include mt($i); }
79
- .mr-#{$i} { @include mr($i); }
80
- .mb-#{$i} { @include mb($i); }
81
- .ml-#{$i} { @include ml($i); }
324
+ .m-#{$key} { @include m($value); }
325
+ .mx-#{$key} { @include mx($value); }
326
+ .my-#{$key} { @include my($value); }
327
+ .mt-#{$key} { @include mt($value); }
328
+ .mr-#{$key} { @include mr($value); }
329
+ .mb-#{$key} { @include mb($value); }
330
+ .ml-#{$key} { @include ml($value); }
82
331
 
83
332
  // Gap classes
84
- .gap-#{$i} { @include gap($i); }
85
- .gap-x-#{$i} { @include gap-x($i); }
86
- .gap-y-#{$i} { @include gap-y($i); }
333
+ .gap-#{$key} { @include gap($value); }
334
+ .gap-x-#{$key} { @include gap-x($value); }
335
+ .gap-y-#{$key} { @include gap-y($value); }
87
336
 
88
337
  // Space classes
89
- .space-x-#{$i} { @include space-x($i); }
90
- .space-y-#{$i} { @include space-y($i); }
338
+ .space-x-#{$key} { @include space-x($value); }
339
+ .space-y-#{$key} { @include space-y($value); }
91
340
  }
92
341
 
93
342
 
94
- // Responsive Position Classes
343
+ //-----------------------------------------------
344
+ // RESPONSIVE SPACING CLASSES
345
+ //-----------------------------------------------
346
+
95
347
  @each $breakpoint, $width in $breakpoints {
96
348
  @media (min-width: #{$width}) {
97
349
  .mx-auto\@#{$breakpoint} { @include mx-auto; }
@@ -99,33 +351,32 @@
99
351
  .mr-auto\@#{$breakpoint} { @include mr-auto; }
100
352
 
101
353
  // Generate utilities from spacing map
102
- @each $i in $spacings {
354
+ @each $key, $value in $spacings {
103
355
  // Padding classes
104
- .p-#{$i}\@#{$breakpoint} { @include p($i); }
105
- .px-#{$i}\@#{$breakpoint} { @include px($i); }
106
- .py-#{$i}\@#{$breakpoint} { @include py($i); }
107
- .pt-#{$i}\@#{$breakpoint} { @include pt($i); }
108
- .pr-#{$i}\@#{$breakpoint} { @include pr($i); }
109
- .pb-#{$i}\@#{$breakpoint} { @include pb($i); }
110
- .pl-#{$i}\@#{$breakpoint} { @include pl($i); }
356
+ .p-#{$key}\@#{$breakpoint} { @include p($value); }
357
+ .px-#{$key}\@#{$breakpoint} { @include px($value); }
358
+ .py-#{$key}\@#{$breakpoint} { @include py($value); }
359
+ .pt-#{$key}\@#{$breakpoint} { @include pt($value); }
360
+ .pr-#{$key}\@#{$breakpoint} { @include pr($value); }
361
+ .pb-#{$key}\@#{$breakpoint} { @include pb($value); }
362
+ .pl-#{$key}\@#{$breakpoint} { @include pl($value); }
111
363
 
112
364
  // Margin classes
113
- .m-#{$i}\@#{$breakpoint} { @include m($i); }
114
- .mx-#{$i}\@#{$breakpoint} { @include mx($i); }
115
- .my-#{$i}\@#{$breakpoint} { @include my($i); }
116
- .mt-#{$i}\@#{$breakpoint} { @include mt($i); }
117
- .mr-#{$i}\@#{$breakpoint} { @include mr($i); }
118
- .mb-#{$i}\@#{$breakpoint} { @include mb($i); }
119
- .ml-#{$i}\@#{$breakpoint} { @include ml($i); }
120
-
121
- .gap-#{$i}\@#{$breakpoint} { gap: $i; }
122
- .gap-x-#{$i}\@#{$breakpoint} { column-gap: $i; }
123
- .gap-y-#{$i}\@#{$breakpoint} { row-gap: $i; }
365
+ .m-#{$key}\@#{$breakpoint} { @include m($value); }
366
+ .mx-#{$key}\@#{$breakpoint} { @include mx($value); }
367
+ .my-#{$key}\@#{$breakpoint} { @include my($value); }
368
+ .mt-#{$key}\@#{$breakpoint} { @include mt($value); }
369
+ .mr-#{$key}\@#{$breakpoint} { @include mr($value); }
370
+ .mb-#{$key}\@#{$breakpoint} { @include mb($value); }
371
+ .ml-#{$key}\@#{$breakpoint} { @include ml($value); }
372
+
373
+ .gap-#{$key}\@#{$breakpoint} { gap: $value; }
374
+ .gap-x-#{$key}\@#{$breakpoint} { column-gap: $value; }
375
+ .gap-y-#{$key}\@#{$breakpoint} { row-gap: $value; }
124
376
 
125
-
126
377
  // Space classes
127
- .space-x-#{$i}\@#{$breakpoint} { @include space-x($i); }
128
- .space-y-#{$i}\@#{$breakpoint} { @include space-y($i); }
378
+ .space-x-#{$key}\@#{$breakpoint} { @include space-x($value); }
379
+ .space-y-#{$key}\@#{$breakpoint} { @include space-y($value); }
129
380
  }
130
381
  }
131
382
  }
@@ -0,0 +1,152 @@
1
+ // _transitions.scss
2
+ @use './variables' as *;
3
+
4
+ /**
5
+ * Transition Utilities
6
+ *
7
+ * - .transition: Default transition for common properties
8
+ * - .transition-{property}: Transition specific properties
9
+ * - .duration-{time}: Set transition duration
10
+ * - .ease-{type}: Set transition timing function
11
+ * - .delay-{time}: Set transition delay
12
+ */
13
+
14
+ // Base transition mixins
15
+ @mixin transition {
16
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
17
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
18
+ transition-duration: 150ms;
19
+ }
20
+
21
+ // Property-specific transition mixins
22
+ @mixin transition-none { transition-property: none; }
23
+ @mixin transition-all { transition-property: all; }
24
+ @mixin transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; }
25
+ @mixin transition-opacity { transition-property: opacity; }
26
+ @mixin transition-shadow { transition-property: box-shadow; }
27
+ @mixin transition-transform { transition-property: transform; }
28
+
29
+ // Duration mixins
30
+ @mixin duration($time) {
31
+ transition-duration: $time;
32
+ }
33
+
34
+ // Timing function mixins
35
+ @mixin ease-linear { transition-timing-function: linear; }
36
+ @mixin ease-in { transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
37
+ @mixin ease-out { transition-timing-function: cubic-bezier(0, 0, 0.2, 1); }
38
+ @mixin ease-in-out { transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
39
+
40
+ // Delay mixins
41
+ @mixin delay($time) {
42
+ transition-delay: $time;
43
+ }
44
+
45
+ // Base transition
46
+ .transition {
47
+ @include transition;
48
+ }
49
+
50
+ // Property-specific transitions
51
+ .transition-none { @include transition-none; }
52
+ .transition-all { @include transition-all; }
53
+ .transition-colors { @include transition-colors; }
54
+ .transition-opacity { @include transition-opacity; }
55
+ .transition-shadow { @include transition-shadow; }
56
+ .transition-transform { @include transition-transform; }
57
+
58
+ // Durations
59
+ $durations: (
60
+ '0': 0ms,
61
+ '75': 75ms,
62
+ '100': 100ms,
63
+ '150': 150ms,
64
+ '200': 200ms,
65
+ '300': 300ms,
66
+ '500': 500ms,
67
+ '700': 700ms,
68
+ '1000': 1000ms,
69
+ );
70
+
71
+ @each $name, $value in $durations {
72
+ .duration-#{$name} {
73
+ @include duration($value);
74
+ }
75
+ }
76
+
77
+ // Timing functions
78
+ $timing-functions: (
79
+ 'linear': linear,
80
+ 'in': cubic-bezier(0.4, 0, 1, 1),
81
+ 'out': cubic-bezier(0, 0, 0.2, 1),
82
+ 'in-out': cubic-bezier(0.4, 0, 0.2, 1),
83
+ );
84
+
85
+ @each $name, $value in $timing-functions {
86
+ .ease-#{$name} {
87
+ transition-timing-function: $value;
88
+ }
89
+ }
90
+
91
+ // Specific timing function classes
92
+ .ease-linear { @include ease-linear; }
93
+ .ease-in { @include ease-in; }
94
+ .ease-out { @include ease-out; }
95
+ .ease-in-out { @include ease-in-out; }
96
+
97
+ // Delays
98
+ $delays: (
99
+ '0': 0ms,
100
+ '75': 75ms,
101
+ '100': 100ms,
102
+ '150': 150ms,
103
+ '200': 200ms,
104
+ '300': 300ms,
105
+ '500': 500ms,
106
+ '700': 700ms,
107
+ '1000': 1000ms,
108
+ );
109
+
110
+ @each $name, $value in $delays {
111
+ .delay-#{$name} {
112
+ @include delay($value);
113
+ }
114
+ }
115
+
116
+ // Responsive variants
117
+ @each $breakpoint, $width in $breakpoints {
118
+ @media (min-width: #{$width}) {
119
+ // Base transition
120
+ .transition\@#{$breakpoint} {
121
+ @include transition;
122
+ }
123
+
124
+ // Property-specific transitions
125
+ .transition-none\@#{$breakpoint} { @include transition-none; }
126
+ .transition-all\@#{$breakpoint} { @include transition-all; }
127
+ .transition-colors\@#{$breakpoint} { @include transition-colors; }
128
+ .transition-opacity\@#{$breakpoint} { @include transition-opacity; }
129
+ .transition-shadow\@#{$breakpoint} { @include transition-shadow; }
130
+ .transition-transform\@#{$breakpoint} { @include transition-transform; }
131
+
132
+ // Duration responsive variants
133
+ @each $name, $value in $durations {
134
+ .duration-#{$name}\@#{$breakpoint} {
135
+ @include duration($value);
136
+ }
137
+ }
138
+
139
+ // Timing function responsive variants
140
+ .ease-linear\@#{$breakpoint} { @include ease-linear; }
141
+ .ease-in\@#{$breakpoint} { @include ease-in; }
142
+ .ease-out\@#{$breakpoint} { @include ease-out; }
143
+ .ease-in-out\@#{$breakpoint} { @include ease-in-out; }
144
+
145
+ // Delay responsive variants
146
+ @each $name, $value in $delays {
147
+ .delay-#{$name}\@#{$breakpoint} {
148
+ @include delay($value);
149
+ }
150
+ }
151
+ }
152
+ }