1mpacto-sass 0.0.1 → 0.0.3

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,453 @@
1
+ @use "sass:map";
2
+ @use "sass:list";
3
+
4
+ @mixin preflight($font-family-map: (), $border-color: #e5e7eb) {
5
+ // RESOLVE FONTS
6
+ $sans-font: map.get($font-family-map, 'sans');
7
+
8
+ @if not $sans-font {
9
+ $sans-font: (ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
10
+ }
11
+
12
+ $mono-font: map.get($font-family-map, 'mono');
13
+
14
+ @if not $mono-font {
15
+ $mono-font: (ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
16
+ }
17
+
18
+ // ==========================================
19
+ // BROWSER PREFLIGHT (Opinionated Reset)
20
+ // Based on Modern Normalize & Opinionated Resets
21
+ // ==========================================
22
+
23
+ /*
24
+ 1. Prevent padding and border from affecting element width.
25
+ 2. Allow adding a border to an element by just adding a border-width.
26
+ */
27
+
28
+ *,
29
+ ::before,
30
+ ::after {
31
+ box-sizing: border-box;
32
+ /* 1 */
33
+ border-width: 0;
34
+ /* 2 */
35
+ border-style: solid;
36
+ /* 2 */
37
+ border-color: #{$border-color};
38
+ /* 2 */
39
+ }
40
+
41
+ ::before,
42
+ ::after {
43
+ --tw-content: '';
44
+ }
45
+
46
+ /*
47
+ 1. Use a consistent sensible line-height in all browsers.
48
+ 2. Prevent adjustments of font size after orientation changes in iOS.
49
+ 3. Use a more readable tab size.
50
+ 4. Use the user's configured `sans` font-family by default.
51
+ 5. Use the user's configured `sans` font-feature-settings by default.
52
+ 6. Use the user's configured `sans` font-variation-settings by default.
53
+ 7. Disable tap highlights on iOS
54
+ */
55
+
56
+ html,
57
+ :host {
58
+ line-height: 1.5;
59
+ /* 1 */
60
+ -webkit-text-size-adjust: 100%;
61
+ /* 2 */
62
+ -moz-tab-size: 4;
63
+ /* 3 */
64
+ tab-size: 4;
65
+ /* 3 */
66
+ font-family: $sans-font;
67
+ /* 4 */
68
+ font-feature-settings: normal;
69
+ /* 5 */
70
+ font-variation-settings: normal;
71
+ /* 6 */
72
+ -webkit-tap-highlight-color: transparent;
73
+ /* 7 */
74
+ }
75
+
76
+ /*
77
+ 1. Remove the margin in all browsers.
78
+ 2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
79
+ */
80
+
81
+ body {
82
+ margin: 0;
83
+ /* 1 */
84
+ line-height: inherit;
85
+ /* 2 */
86
+ }
87
+
88
+ /*
89
+ 1. Add the correct height in Firefox.
90
+ 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
91
+ 3. Ensure horizontal rules are visible by default.
92
+ */
93
+
94
+ hr {
95
+ height: 0;
96
+ /* 1 */
97
+ color: inherit;
98
+ /* 2 */
99
+ border-top-width: 1px;
100
+ /* 3 */
101
+ }
102
+
103
+ /*
104
+ Add the correct text decoration in Chrome, Edge, and Safari.
105
+ */
106
+
107
+ abbr:where([title]) {
108
+ text-decoration: underline dotted;
109
+ }
110
+
111
+ /*
112
+ Remove the default font size and weight for headings.
113
+ */
114
+
115
+ h1,
116
+ h2,
117
+ h3,
118
+ h4,
119
+ h5,
120
+ h6 {
121
+ font-size: inherit;
122
+ font-weight: inherit;
123
+ }
124
+
125
+ /*
126
+ Reset links to optimize for opt-in styling instead of opt-out.
127
+ */
128
+
129
+ a {
130
+ color: inherit;
131
+ text-decoration: inherit;
132
+ }
133
+
134
+ /*
135
+ Add the correct font weight in Edge and Safari.
136
+ */
137
+
138
+ b,
139
+ strong {
140
+ font-weight: bolder;
141
+ }
142
+
143
+ /*
144
+ 1. Use the user's configured `mono` font-family by default.
145
+ 2. Use the user's configured `mono` font-feature-settings by default.
146
+ 3. Use the user's configured `mono` font-variation-settings by default.
147
+ 4. Correct the odd `em` font sizing in all browsers.
148
+ */
149
+
150
+ code,
151
+ kbd,
152
+ samp,
153
+ pre {
154
+ font-family: $mono-font;
155
+ /* 1 */
156
+ font-feature-settings: normal;
157
+ /* 2 */
158
+ font-variation-settings: normal;
159
+ /* 3 */
160
+ font-size: 1em;
161
+ /* 4 */
162
+ }
163
+
164
+ /*
165
+ Add the correct font size in all browsers.
166
+ */
167
+
168
+ small {
169
+ font-size: 80%;
170
+ }
171
+
172
+ /*
173
+ Prevent `sub` and `sup` elements from affecting the line height in all browsers.
174
+ */
175
+
176
+ sub,
177
+ sup {
178
+ font-size: 75%;
179
+ line-height: 0;
180
+ position: relative;
181
+ vertical-align: baseline;
182
+ }
183
+
184
+ sub {
185
+ bottom: -0.25em;
186
+ }
187
+
188
+ sup {
189
+ top: -0.5em;
190
+ }
191
+
192
+ /*
193
+ 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
194
+ 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
195
+ 3. Remove gaps between table borders by default.
196
+ */
197
+
198
+ table {
199
+ text-indent: 0;
200
+ /* 1 */
201
+ border-color: inherit;
202
+ /* 2 */
203
+ border-collapse: collapse;
204
+ /* 3 */
205
+ }
206
+
207
+ /*
208
+ 1. Change the font styles in all browsers.
209
+ 2. Remove the margin in Firefox and Safari.
210
+ 3. Remove default padding in all browsers.
211
+ */
212
+
213
+ button,
214
+ input,
215
+ optgroup,
216
+ select,
217
+ textarea {
218
+ font-family: inherit;
219
+ /* 1 */
220
+ font-feature-settings: inherit;
221
+ /* 1 */
222
+ font-variation-settings: inherit;
223
+ /* 1 */
224
+ font-size: 100%;
225
+ /* 1 */
226
+ font-weight: inherit;
227
+ /* 1 */
228
+ line-height: inherit;
229
+ /* 1 */
230
+ color: inherit;
231
+ /* 1 */
232
+ margin: 0;
233
+ /* 2 */
234
+ padding: 0;
235
+ /* 3 */
236
+ }
237
+
238
+ /*
239
+ Remove the inheritance of text transform in Edge and Firefox.
240
+ */
241
+
242
+ button,
243
+ select {
244
+ text-transform: none;
245
+ }
246
+
247
+ /*
248
+ 1. Correct the inability to style clickable types in iOS and Safari.
249
+ 2. Remove default button styles.
250
+ */
251
+
252
+ button,
253
+ input:where([type='button']),
254
+ input:where([type='reset']),
255
+ input:where([type='submit']) {
256
+ -webkit-appearance: button;
257
+ /* 1 */
258
+ background-color: transparent;
259
+ /* 2 */
260
+ background-image: none;
261
+ /* 2 */
262
+ }
263
+
264
+ /*
265
+ Use the modern Firefox focus style for all focusable elements.
266
+ */
267
+
268
+ :-moz-focusring {
269
+ outline: auto;
270
+ }
271
+
272
+ /*
273
+ Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
274
+ */
275
+
276
+ :-moz-ui-invalid {
277
+ box-shadow: none;
278
+ }
279
+
280
+ /*
281
+ Add the correct vertical alignment in Chrome and Firefox.
282
+ */
283
+
284
+ progress {
285
+ vertical-align: baseline;
286
+ }
287
+
288
+ /*
289
+ Correct the cursor style of increment and decrement buttons in Safari.
290
+ */
291
+
292
+ ::-webkit-inner-spin-button,
293
+ ::-webkit-outer-spin-button {
294
+ height: auto;
295
+ }
296
+
297
+ /*
298
+ 1. Correct the odd appearance in Chrome and Safari.
299
+ 2. Correct the outline style in Safari.
300
+ */
301
+
302
+ [type='search'] {
303
+ -webkit-appearance: textfield;
304
+ /* 1 */
305
+ outline-offset: -2px;
306
+ /* 2 */
307
+ }
308
+
309
+ /*
310
+ Remove the inner padding in Chrome and Safari on macOS.
311
+ */
312
+
313
+ ::-webkit-search-decoration {
314
+ -webkit-appearance: none;
315
+ }
316
+
317
+ /*
318
+ 1. Correct the inability to style clickable types in iOS and Safari.
319
+ 2. Change font properties to `inherit` in Safari.
320
+ */
321
+
322
+ ::-webkit-file-upload-button {
323
+ -webkit-appearance: button;
324
+ /* 1 */
325
+ font: inherit;
326
+ /* 2 */
327
+ }
328
+
329
+ /*
330
+ Add the correct display in Chrome and Safari.
331
+ */
332
+
333
+ summary {
334
+ display: list-item;
335
+ }
336
+
337
+ /*
338
+ Removes the default spacing and border for appropriate elements.
339
+ */
340
+
341
+ blockquote,
342
+ dl,
343
+ dd,
344
+ h1,
345
+ h2,
346
+ h3,
347
+ h4,
348
+ h5,
349
+ h6,
350
+ hr,
351
+ figure,
352
+ p,
353
+ pre {
354
+ margin: 0;
355
+ }
356
+
357
+ fieldset {
358
+ margin: 0;
359
+ padding: 0;
360
+ }
361
+
362
+ legend {
363
+ padding: 0;
364
+ }
365
+
366
+ ol,
367
+ ul,
368
+ menu {
369
+ list-style: none;
370
+ margin: 0;
371
+ padding: 0;
372
+ }
373
+
374
+ /*
375
+ Reset default styling for dialogs.
376
+ */
377
+ dialog {
378
+ padding: 0;
379
+ }
380
+
381
+ /*
382
+ Prevent resizing textareas horizontally by default.
383
+ */
384
+
385
+ textarea {
386
+ resize: vertical;
387
+ }
388
+
389
+ /*
390
+ 1. Reset the default placeholder opacity in Firefox.
391
+ 2. Set the default placeholder color to the user's configured gray 400 color.
392
+ */
393
+
394
+ input::placeholder,
395
+ textarea::placeholder {
396
+ opacity: 1;
397
+ /* 1 */
398
+ color: #9ca3af;
399
+ /* 2 */
400
+ }
401
+
402
+ /*
403
+ Set the default cursor for buttons.
404
+ */
405
+
406
+ button,
407
+ [role="button"] {
408
+ cursor: pointer;
409
+ }
410
+
411
+ /*
412
+ Make sure disabled buttons don't get the pointer cursor.
413
+ */
414
+ :disabled {
415
+ cursor: default;
416
+ }
417
+
418
+ /*
419
+ 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
420
+ 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
421
+ This can trigger a poorly considered lint error in some tools but is included
422
+ by design.
423
+ */
424
+
425
+ img,
426
+ svg,
427
+ video,
428
+ canvas,
429
+ audio,
430
+ iframe,
431
+ embed,
432
+ object {
433
+ display: block;
434
+ /* 1 */
435
+ vertical-align: middle;
436
+ /* 2 */
437
+ }
438
+
439
+ /*
440
+ Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
441
+ */
442
+
443
+ img,
444
+ video {
445
+ max-width: 100%;
446
+ height: auto;
447
+ }
448
+
449
+ /* Make elements with the HTML hidden attribute stay hidden by default */
450
+ [hidden] {
451
+ display: none;
452
+ }
453
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "1mpacto-sass",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "sass generator for css utility first",
5
5
  "type": "module",
6
6
  "exports": {
7
- "./_config.sass": "./_config.scss",
8
- "./_engine.sass": "./_engine.scss"
7
+ "./_config.scss": "./_config.scss",
8
+ "./_engine.scss": "./_engine.scss",
9
+ "./_preflight.scss": "./_preflight.scss"
9
10
  },
10
11
  "scripts": {
11
12
  "test": "node tests/run_tests.cjs",
package/readme.md CHANGED
@@ -407,6 +407,26 @@ Contoh (dengan `$class-prefix: '1ru-'`):
407
407
 
408
408
  ---
409
409
 
410
+ ## Fitur Preflight (Browser Reset)
411
+
412
+ Generator ini menyediakan fitur "Preflight" yang mengadopsi reset CSS opinionated (mirip dengan modern framework) untuk memastikan tampilan elemen HTML konsisten di semua browser.
413
+
414
+ **Cara Penggunaan:**
415
+ Import modul `preflight` dan panggil mixin-nya di bagian paling atas file SCSS Anda, sebelum melakukan generate utility lain.
416
+
417
+ ```scss
418
+ @use "preflight";
419
+ @use "config";
420
+
421
+ // Panggil mixin preflight dengan memasukkan map font family dari config
422
+ @include preflight.preflight(
423
+ $font-family-map: config.$font-family-map,
424
+ $border-color: #e5e7eb // Opsional: set warna border default (default: #e5e7eb)
425
+ );
426
+ ```
427
+
428
+ ---
429
+
410
430
  ## Integrasi di SCSS
411
431
 
412
432
  Berikut adalah contoh lengkap cara mengintegrasikan generator ini, menggabungkan konfigurasi default dengan konfigurasi project Anda, dan mengatur prefix custom.
@@ -417,6 +437,7 @@ Contoh di entry point SCSS Anda (misal `src/styles/utilities.scss`):
417
437
  @use "sass:map";
418
438
  @use "config"as config;
419
439
  @use "engine"as engine;
440
+ @use "preflight"as preflight; // <--- Import Preflight
420
441
 
421
442
  // ==========================================================================
422
443
  // 1. DEFINISI CONFIGURATION CUSTOM PROJECT
@@ -520,6 +541,9 @@ $final-ring-width: map.merge(config.$ring-width-map, $project-ring-width-map);
520
541
  // 3. GENERATE CSS
521
542
  // ==========================================================================
522
543
 
544
+ // 1. Activate Preflight (Optional but recommended)
545
+ @include preflight.preflight($font-family-map: $final-font-family);
546
+
523
547
  $whitelistclassname : ('w-1/2', 'p-128', 'h-hero');
524
548
  // Whitelist Base
525
549
  $whitelistresponsive : ();
@@ -1,38 +1,32 @@
1
- @use '../config' as config;
2
- @use '../engine' as engine;
1
+ @use '../config'as config;
2
+ @use '../engine'as engine;
3
+ @use '../preflight'as preflight; // <--- Import Preflight
3
4
  @use 'sass:map';
4
5
 
5
6
  // ==========================================
6
7
  // 1. MOCK CONFIGURATION
7
8
  // ==========================================
8
- $test-colors: (
9
- 'primary': #007bff,
9
+ $test-colors: ('primary': #007bff,
10
10
  'red': #ff0000,
11
11
  'black': #000000,
12
12
  'white': #ffffff,
13
- 'slate-500': #64748b
14
- );
13
+ 'slate-500': #64748b);
15
14
 
16
- $test-breakpoints: (
17
- 'sm': 640px,
15
+ $test-breakpoints: ('sm': 640px,
18
16
  'md': 768px,
19
- '2xl': 1536px
20
- );
17
+ '2xl': 1536px);
21
18
 
22
19
  // ==========================================
23
20
  // 2. GENERATE CONFIGURATION
24
21
  // ==========================================
25
- $utilities: config.dynamicUtilities(
26
- $colors: $test-colors,
27
- $breakpoints: $test-breakpoints
28
- );
22
+ $utilities: config.dynamicUtilities($colors: $test-colors,
23
+ $breakpoints: $test-breakpoints);
29
24
 
30
25
  // ==========================================
31
26
  // 3. DEFINE WHITELIST (FULL COVERAGE)
32
27
  // ==========================================
33
28
 
34
- $test-cases-base: (
35
- // --- STATIC UTILITIES ---
29
+ $test-cases-base: ( // --- STATIC UTILITIES ---
36
30
  'static', 'fixed', 'absolute', 'relative', 'sticky', // Position
37
31
  'block', 'inline-block', 'inline', 'flex', 'grid', 'hidden', // Display
38
32
  'flex-row', 'flex-col', // Flex Direction
@@ -157,18 +151,19 @@ $test-cases-base: (
157
151
  );
158
152
 
159
153
  // ==========================================
160
- // 4. EXECUTE GENERATOR
154
+ // 4. ACTIVATE PREFLIGHT
161
155
  // ==========================================
162
- @include engine.generatorStyle(
163
- $static-map: config.$static-utilities-map,
156
+ @include preflight.preflight(config.$font-family-map);
157
+
158
+ // ==========================================
159
+ // 5. EXECUTE GENERATOR
160
+ // ==========================================
161
+ @include engine.generatorStyle($static-map: config.$static-utilities-map,
164
162
  $dynamic-map: $utilities,
165
163
  $config-breakpoints: $test-breakpoints,
166
164
  $whitelist-base: $test-cases-base,
167
- $whitelist-responsive: (
168
- 'sm': $test-cases-base,
169
- '2xl': $test-cases-base
170
- ),
165
+ $whitelist-responsive: ('sm': $test-cases-base, '2xl': $test-cases-base),
171
166
  $whitelist-hover: $test-cases-base,
172
167
  $whitelist-focus: $test-cases-base,
173
168
  $var-prefix: 'is'
174
- );
169
+ );