responsive-scale-mixins 1.1.2 → 2.0.1

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/README.md CHANGED
@@ -2,8 +2,55 @@
2
2
 
3
3
  A powerful SCSS mixin system for creating perfectly responsive designs that maintain Figma proportions across all screen sizes.
4
4
 
5
- [![npm version](https://badge.fury.io/js/responsive-scale-mixins.svg)](https://badge.fury.io/js/responsive-scale-mixins)
5
+ [![npm version](https://badge.fury.io/js/responsive-scale-mixins.svg)](https://www.npmjs.com/package/responsive-scale-mixins)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![npm](https://img.shields.io/npm/v/responsive-scale-mixins)](https://www.npmjs.com/package/responsive-scale-mixins)
8
+ [![npm](https://img.shields.io/npm/dm/responsive-scale-mixins)](https://www.npmjs.com/package/responsive-scale-mixins)
9
+
10
+ ## ⚠️ Breaking Changes in v2.0.0
11
+
12
+ **Pure CSS implementations are affected by this breaking change.**
13
+
14
+ - **CSS Variables**: Variable names changed from `--computed-scale-factor-px`/`--computed-scale-factor-rem` to generic `--computed-scale-factor`
15
+ - **Calc Expressions**: Units are now appended to multipliers (e.g., `* 2rem` instead of `* 2`)
16
+ - **SCSS Usage**: Unchanged - existing SCSS mixin calls continue to work
17
+
18
+ **SCSS implementations are NOT affected** - existing `@include responsive-scale()` calls work unchanged.
19
+
20
+ ### Migration Guide (Pure CSS Users)
21
+
22
+ **Update your CSS variable definitions:**
23
+
24
+ ```css
25
+ /* OLD (v1.x) */
26
+ :root {
27
+ --computed-scale-factor-px: calc(100vw / 1440);
28
+ --computed-scale-factor-rem: calc(100vw / 1440 / 16);
29
+ --computed-tablet-scale-factor-px: calc(100vw / 768);
30
+ --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
31
+ --computed-mobile-scale-factor-px: calc(100vw / 375);
32
+ --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
33
+ --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
34
+ }
35
+
36
+ /* NEW (v2.0) */
37
+ :root {
38
+ --computed-scale-factor: calc(100vw / 1440);
39
+ --computed-tablet-scale-factor: calc(100vw / 768);
40
+ --computed-mobile-scale-factor: calc(100vw / 375);
41
+ --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
42
+ }
43
+ ```
44
+
45
+ **Update your calc expressions to include units:**
46
+
47
+ ```css
48
+ /* OLD (v1.x) */
49
+ font-size: calc(var(--computed-scale-factor-px) * 40);
50
+
51
+ /* NEW (v2.0) */
52
+ font-size: calc(var(--computed-scale-factor) * 40px);
53
+ ```
7
54
 
8
55
  ## ✨ Features
9
56
 
@@ -13,6 +60,7 @@ A powerful SCSS mixin system for creating perfectly responsive designs that main
13
60
  - **CSS Custom Properties**: Uses modern CSS variables for optimal performance
14
61
  - **Framework Agnostic**: Works with any CSS framework or vanilla CSS
15
62
  - **TypeScript Ready**: Compatible with CSS Modules and CSS-in-JS solutions
63
+ - **Universal Unit Support**: Handles all CSS units including absolute (px, pt, cm, mm, in, pc) and relative (%, em, rem, vw, vh, vmin, vmax) units
16
64
 
17
65
  ## 🚀 Quick Start
18
66
 
@@ -253,12 +301,9 @@ pnpm add responsive-scale-mixins
253
301
  // Replace 1440 with your design width or leave default (desktop)
254
302
  // Replace 768 with your design width or leave default (tablet)
255
303
  // Replace 375 with your design width or leave default (mobile)
256
- --computed-scale-factor-px: calc(100vw / 1920);
257
- --computed-scale-factor-rem: calc(100vw / 1920 / 16);
258
- --computed-tablet-scale-factor-px: calc(100vw / 768);
259
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
260
- --computed-mobile-scale-factor-px: calc(100vw / 390);
261
- --computed-mobile-scale-factor-rem: calc(100vw / 390 / 16);
304
+ --computed-scale-factor: calc(100vw / 1920);
305
+ --computed-tablet-scale-factor: calc(100vw / 768);
306
+ --computed-mobile-scale-factor: calc(100vw / 390);
262
307
  --tablet-proportion-scale-factor: calc((100vw - 390px) / (1920px - 390px));
263
308
  }
264
309
 
@@ -433,11 +478,56 @@ Easily customize the design widths to match your project's breakpoints:
433
478
  - Tablet: 768px
434
479
  - Mobile: 390px
435
480
 
436
- ### REM Units
481
+ ### REM and EM Units
437
482
 
438
483
  ```scss
439
484
  .element {
440
- @include responsive-scale(font-size, 3, 2, rem); // 3rem / 2rem
485
+ @include responsive-scale(
486
+ font-size,
487
+ 3,
488
+ 2,
489
+ rem
490
+ ); // 3rem / 2rem - uses rem scale factor
491
+ @include responsive-scale(
492
+ font-size,
493
+ 2,
494
+ 1.5,
495
+ em
496
+ ); // 2em / 1.5em - uses rem scale factor
497
+ }
498
+ ```
499
+
500
+ **Universal Unit Support:**
501
+
502
+ The mixin supports **all CSS units** with a single generic scale factor:
503
+
504
+ **Absolute Units:**
505
+
506
+ - `@include responsive-scale(property, value, mobile-value, px)` → `* valuepx`
507
+ - `@include responsive-scale(property, value, mobile-value, pt)` → `* valuept`
508
+ - `@include responsive-scale(property, value, mobile-value, cm)` → `* valuecm`
509
+ - `@include responsive-scale(property, value, mobile-value, mm)` → `* valuemm`
510
+ - `@include responsive-scale(property, value, mobile-value, in)` → `* valuein`
511
+ - `@include responsive-scale(property, value, mobile-value, pc)` → `* valuepc`
512
+
513
+ **Relative Units:**
514
+
515
+ - `@include responsive-scale(property, value, mobile-value, em)` → `* valueem`
516
+ - `@include responsive-scale(property, value, mobile-value, rem)` → `* valuerem`
517
+ - `@include responsive-scale(property, value, mobile-value, %)` → `* value%`
518
+ - `@include responsive-scale(property, value, mobile-value, vw)` → `* valuevw`
519
+ - `@include responsive-scale(property, value, mobile-value, vh)` → `* valuevh`
520
+ - `@include responsive-scale(property, value, mobile-value, vmin)` → `* valuevmin`
521
+ - `@include responsive-scale(property, value, mobile-value, vmax)` → `* valuevmax`
522
+
523
+ **Example Usage:**
524
+
525
+ ```scss
526
+ .element {
527
+ @include responsive-scale(margin, 2, 1, cm); // centimeters
528
+ @include responsive-scale(width, 50, 30, vw); // viewport width
529
+ @include responsive-scale(height, 80, 60, vh); // viewport height
530
+ @include responsive-scale(font-size, 1.5, 1, em); // em units
441
531
  }
442
532
  ```
443
533
 
@@ -450,12 +540,9 @@ If you prefer manual control, you can set the CSS variables directly:
450
540
  // Replace 1440 with your design width or leave default (desktop)
451
541
  // Replace 768 with your design width or leave default (tablet)
452
542
  // Replace 375 with your design width or leave default (mobile)
453
- --computed-scale-factor-px: calc(100vw / 1440); // Your desktop width
454
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
455
- --computed-tablet-scale-factor-px: calc(100vw / 768); // Your tablet width
456
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
457
- --computed-mobile-scale-factor-px: calc(100vw / 375); // Your mobile width
458
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
543
+ --computed-scale-factor: calc(100vw / 1440); // Your desktop width
544
+ --computed-tablet-scale-factor: calc(100vw / 768); // Your tablet width
545
+ --computed-mobile-scale-factor: calc(100vw / 375); // Your mobile width
459
546
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
460
547
  }
461
548
  ```
@@ -476,12 +563,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
476
563
  // Replace 1440 with your design width or leave default (desktop)
477
564
  // Replace 768 with your design width or leave default (tablet)
478
565
  // Replace 375 with your design width or leave default (mobile)
479
- --computed-scale-factor-px: calc(100vw / 1440); // Your design desktop width
480
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
481
- --computed-tablet-scale-factor-px: calc(100vw / 768);
482
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
483
- --computed-mobile-scale-factor-px: calc(100vw / 375);
484
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
566
+ --computed-scale-factor: calc(100vw / 1440); // Your design desktop width
567
+ --computed-tablet-scale-factor: calc(100vw / 768);
568
+ --computed-mobile-scale-factor: calc(100vw / 375);
485
569
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
486
570
  }
487
571
 
@@ -500,12 +584,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
500
584
  // Replace 1440 with your design width or leave default (desktop)
501
585
  // Replace 768 with your design width or leave default (tablet)
502
586
  // Replace 375 with your design width or leave default (mobile)
503
- --computed-scale-factor-px: calc(100vw / 1440);
504
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
505
- --computed-tablet-scale-factor-px: calc(100vw / 768);
506
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
507
- --computed-mobile-scale-factor-px: calc(100vw / 375);
508
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
587
+ --computed-scale-factor: calc(100vw / 1440);
588
+ --computed-tablet-scale-factor: calc(100vw / 768);
589
+ --computed-mobile-scale-factor: calc(100vw / 375);
509
590
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
510
591
  }
511
592
 
@@ -521,12 +602,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
521
602
  // Replace 1440 with your design width or leave default (desktop)
522
603
  // Replace 768 with your design width or leave default (tablet)
523
604
  // Replace 375 with your design width or leave default (mobile)
524
- --computed-scale-factor-px: calc(100vw / 1440);
525
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
526
- --computed-tablet-scale-factor-px: calc(100vw / 768);
527
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
528
- --computed-mobile-scale-factor-px: calc(100vw / 375);
529
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
605
+ --computed-scale-factor: calc(100vw / 1440);
606
+ --computed-tablet-scale-factor: calc(100vw / 768);
607
+ --computed-mobile-scale-factor: calc(100vw / 375);
530
608
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
531
609
  }
532
610
 
@@ -542,12 +620,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
542
620
  // Replace 1440 with your design width or leave default (desktop)
543
621
  // Replace 768 with your design width or leave default (tablet)
544
622
  // Replace 375 with your design width or leave default (mobile)
545
- --computed-scale-factor-px: calc(100vw / 1440);
546
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
547
- --computed-tablet-scale-factor-px: calc(100vw / 768);
548
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
549
- --computed-mobile-scale-factor-px: calc(100vw / 375);
550
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
623
+ --computed-scale-factor: calc(100vw / 1440);
624
+ --computed-tablet-scale-factor: calc(100vw / 768);
625
+ --computed-mobile-scale-factor: calc(100vw / 375);
551
626
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
552
627
  }
553
628
 
@@ -563,12 +638,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
563
638
  // Replace 1440 with your design width or leave default (desktop)
564
639
  // Replace 768 with your design width or leave default (tablet)
565
640
  // Replace 375 with your design width or leave default (mobile)
566
- --computed-scale-factor-px: calc(100vw / 1440);
567
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
568
- --computed-tablet-scale-factor-px: calc(100vw / 768);
569
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
570
- --computed-mobile-scale-factor-px: calc(100vw / 375);
571
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
641
+ --computed-scale-factor: calc(100vw / 1440);
642
+ --computed-tablet-scale-factor: calc(100vw / 768);
643
+ --computed-mobile-scale-factor: calc(100vw / 375);
572
644
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
573
645
  }
574
646
 
@@ -584,12 +656,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
584
656
  // Replace 1440 with your design width or leave default (desktop)
585
657
  // Replace 768 with your design width or leave default (tablet)
586
658
  // Replace 375 with your design width or leave default (mobile)
587
- --computed-scale-factor-px: calc(100vw / 1440);
588
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
589
- --computed-tablet-scale-factor-px: calc(100vw / 768);
590
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
591
- --computed-mobile-scale-factor-px: calc(100vw / 375);
592
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
659
+ --computed-scale-factor: calc(100vw / 1440);
660
+ --computed-tablet-scale-factor: calc(100vw / 768);
661
+ --computed-mobile-scale-factor: calc(100vw / 375);
593
662
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
594
663
  }
595
664
 
@@ -605,12 +674,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
605
674
  // Replace 1440 with your design width or leave default (desktop)
606
675
  // Replace 768 with your design width or leave default (tablet)
607
676
  // Replace 375 with your design width or leave default (mobile)
608
- --computed-scale-factor-px: calc(100vw / 1440);
609
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
610
- --computed-tablet-scale-factor-px: calc(100vw / 768);
611
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
612
- --computed-mobile-scale-factor-px: calc(100vw / 375);
613
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
677
+ --computed-scale-factor: calc(100vw / 1440);
678
+ --computed-tablet-scale-factor: calc(100vw / 768);
679
+ --computed-mobile-scale-factor: calc(100vw / 375);
614
680
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
615
681
  }
616
682
 
@@ -626,12 +692,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
626
692
  // Replace 1440 with your design width or leave default (desktop)
627
693
  // Replace 768 with your design width or leave default (tablet)
628
694
  // Replace 375 with your design width or leave default (mobile)
629
- --computed-scale-factor-px: calc(100vw / 1440);
630
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
631
- --computed-tablet-scale-factor-px: calc(100vw / 768);
632
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
633
- --computed-mobile-scale-factor-px: calc(100vw / 375);
634
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
695
+ --computed-scale-factor: calc(100vw / 1440);
696
+ --computed-tablet-scale-factor: calc(100vw / 768);
697
+ --computed-mobile-scale-factor: calc(100vw / 375);
635
698
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
636
699
  }
637
700
 
@@ -647,12 +710,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
647
710
  // Replace 1440 with your design width or leave default (desktop)
648
711
  // Replace 768 with your design width or leave default (tablet)
649
712
  // Replace 375 with your design width or leave default (mobile)
650
- --computed-scale-factor-px: calc(100vw / 1440);
651
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
652
- --computed-tablet-scale-factor-px: calc(100vw / 768);
653
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
654
- --computed-mobile-scale-factor-px: calc(100vw / 375);
655
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
713
+ --computed-scale-factor: calc(100vw / 1440);
714
+ --computed-tablet-scale-factor: calc(100vw / 768);
715
+ --computed-mobile-scale-factor: calc(100vw / 375);
656
716
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
657
717
  }
658
718
 
@@ -668,12 +728,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
668
728
  // Replace 1440 with your design width or leave default (desktop)
669
729
  // Replace 768 with your design width or leave default (tablet)
670
730
  // Replace 375 with your design width or leave default (mobile)
671
- --computed-scale-factor-px: calc(100vw / 1440);
672
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
673
- --computed-tablet-scale-factor-px: calc(100vw / 768);
674
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
675
- --computed-mobile-scale-factor-px: calc(100vw / 375);
676
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
731
+ --computed-scale-factor: calc(100vw / 1440);
732
+ --computed-tablet-scale-factor: calc(100vw / 768);
733
+ --computed-mobile-scale-factor: calc(100vw / 375);
677
734
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
678
735
  }
679
736
 
@@ -689,12 +746,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
689
746
  // Replace 1440 with your design width or leave default (desktop)
690
747
  // Replace 768 with your design width or leave default (tablet)
691
748
  // Replace 375 with your design width or leave default (mobile)
692
- --computed-scale-factor-px: calc(100vw / 1920);
693
- --computed-scale-factor-rem: calc(100vw / 1920 / 16);
694
- --computed-tablet-scale-factor-px: calc(100vw / 768);
695
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
696
- --computed-mobile-scale-factor-px: calc(100vw / 390);
697
- --computed-mobile-scale-factor-rem: calc(100vw / 390 / 16);
749
+ --computed-scale-factor: calc(100vw / 1920);
750
+ --computed-tablet-scale-factor: calc(100vw / 768);
751
+ --computed-mobile-scale-factor: calc(100vw / 390);
698
752
  --tablet-proportion-scale-factor: calc((100vw - 390px) / (1920px - 390px));
699
753
  }
700
754
 
@@ -713,12 +767,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
713
767
  // Replace 1440 with your design width or leave default (desktop)
714
768
  // Replace 768 with your design width or leave default (tablet)
715
769
  // Replace 375 with your design width or leave default (mobile)
716
- --computed-scale-factor-px: calc(100vw / 1440);
717
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
718
- --computed-tablet-scale-factor-px: calc(100vw / 768);
719
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
720
- --computed-mobile-scale-factor-px: calc(100vw / 375);
721
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
770
+ --computed-scale-factor: calc(100vw / 1440);
771
+ --computed-tablet-scale-factor: calc(100vw / 768);
772
+ --computed-mobile-scale-factor: calc(100vw / 375);
722
773
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
723
774
  }
724
775
 
@@ -738,12 +789,9 @@ The `@include responsive-scale-variables()` mixin may fail in certain SCSS compi
738
789
  // Replace 1440 with your design width or leave default (desktop)
739
790
  // Replace 768 with your design width or leave default (tablet)
740
791
  // Replace 375 with your design width or leave default (mobile)
741
- --computed-scale-factor-px: calc(100vw / 1440);
742
- --computed-scale-factor-rem: calc(100vw / 1440 / 16);
743
- --computed-tablet-scale-factor-px: calc(100vw / 768);
744
- --computed-tablet-scale-factor-rem: calc(100vw / 768 / 16);
745
- --computed-mobile-scale-factor-px: calc(100vw / 375);
746
- --computed-mobile-scale-factor-rem: calc(100vw / 375 / 16);
792
+ --computed-scale-factor: calc(100vw / 1440);
793
+ --computed-tablet-scale-factor: calc(100vw / 768);
794
+ --computed-mobile-scale-factor: calc(100vw / 375);
747
795
  --tablet-proportion-scale-factor: calc((100vw - 375px) / (1440px - 375px));
748
796
  }
749
797
 
@@ -797,11 +845,38 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
797
845
  - Built for modern web development workflows
798
846
  - Compatible with CSS Modules, Styled Components, and traditional CSS
799
847
 
800
- ## 📞 Support
848
+ ## 🧪 Testing
849
+
850
+ The library includes a comprehensive test suite located in the `test/` directory:
851
+
852
+ ```bash
853
+ # Run the test suite
854
+ cd test && ./test.sh # Unix/Linux/macOS
855
+ cd test && test.bat # Windows
856
+ ```
857
+
858
+ See [`test/TEST_README.md`](test/TEST_README.md) for detailed testing instructions.
859
+
860
+ <!-- ## � Linking NPM Package to GitHub Packages
861
+
862
+ To connect your published NPM package to GitHub Packages:
863
+
864
+ 1. **Go to your GitHub repository** → **Settings** → **Packages**
865
+ 2. **Click "Connect repository"** or **"Link to repository"**
866
+ 3. **Search for and select** your NPM package: `responsive-scale-mixins`
867
+ 4. **Confirm the connection**
868
+
869
+ This will display your NPM package statistics and information in the GitHub Packages section of your repository.
870
+
871
+ **Note:** The package will automatically appear in GitHub Packages once published to NPM, as long as the repository URL in `package.json` matches your GitHub repository. -->
872
+
873
+ ## �📞 Support
801
874
 
802
875
  - 📧 Email: saheedodulaja@gmail.com
803
876
  - 🐛 Issues: [GitHub Issues](https://github.com/Sidodus/responsive-scale-mixins/issues)
804
877
  - 📖 Docs: [Full Documentation](https://github.com/Sidodus/responsive-scale-mixins#readme)
878
+ - 📦 NPM: [https://www.npmjs.com/package/responsive-scale-mixins](https://www.npmjs.com/package/responsive-scale-mixins)
879
+ - 👤 NPM Profile: [https://www.npmjs.com/~sidodus](https://www.npmjs.com/~sidodus)
805
880
 
806
881
  ---
807
882
 
package/index.scss CHANGED
@@ -1,8 +1,6 @@
1
1
  // Responsive Scale Mixins
2
2
  // A powerful SCSS mixin system for creating perfectly responsive designs
3
3
 
4
- // Import the variables mixin (must be included in your root element)
5
- @import "scss/variables";
6
-
7
- // Import the responsive scale mixin
8
- @import "scss/mixins";
4
+ // Forward all mixins and functions from modules
5
+ @forward "scss/variables";
6
+ @forward "scss/mixins";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "responsive-scale-mixins",
3
- "version": "1.1.2",
4
- "description": "Powerful SCSS mixins for responsive design with Figma proportions. Automatically scales typography, spacing, and dimensions across desktop, tablet, and mobile breakpoints.",
3
+ "version": "2.0.1",
4
+ "description": "🎨 Revolutionary SCSS mixins for perfect responsive design. Supports ALL CSS units (px, rem, em, vw, vh, %, etc.) with pixel-perfect scaling. Zero manual calculations - just flawless responsive typography, spacing, and dimensions across desktop, tablet, and mobile. Framework-agnostic, modern CSS variables, works everywhere.",
5
5
  "main": "index.scss",
6
6
  "style": "index.scss",
7
7
  "scripts": {
@@ -13,6 +13,14 @@
13
13
  "responsive",
14
14
  "mixins",
15
15
  "figma",
16
+ "sketch",
17
+ "adobe-xd",
18
+ "invision",
19
+ "framer",
20
+ "zeplin",
21
+ "ui-design",
22
+ "ux-design",
23
+ "design-systems",
16
24
  "typography",
17
25
  "spacing",
18
26
  "dimensions",
@@ -32,7 +40,10 @@
32
40
  "mobile-first",
33
41
  "responsive-design",
34
42
  "css-variables",
35
- "custom-properties"
43
+ "custom-properties",
44
+ "pixel-perfect",
45
+ "fluid-typography",
46
+ "responsive-scaling"
36
47
  ],
37
48
  "author": "Saheed Odulaja",
38
49
  "license": "MIT",
package/scss/_mixins.scss CHANGED
@@ -24,7 +24,22 @@
24
24
  // Media queries: Desktop (default), Tablet (768-991px), Mobile (≤767px). */
25
25
 
26
26
  @function scaled-value($val, $scale-var, $unit: px) {
27
- @return calc(var(#{$scale-var}) * #{$val});
27
+ @return calc(var(#{$scale-var}) * #{$val}#{$unit});
28
+ }
29
+
30
+ @function get-scale-factor($unit) {
31
+ // Use generic scale factor - unit is appended in calc expressions
32
+ @return unquote("--computed-scale-factor");
33
+ }
34
+
35
+ @function get-tablet-scale-factor($unit) {
36
+ // Use generic scale factor - unit is appended in calc expressions
37
+ @return unquote("--computed-tablet-scale-factor");
38
+ }
39
+
40
+ @function get-mobile-scale-factor($unit) {
41
+ // Use generic scale factor - unit is appended in calc expressions
42
+ @return unquote("--computed-mobile-scale-factor");
28
43
  }
29
44
 
30
45
  @mixin responsive-scale(
@@ -37,27 +52,21 @@
37
52
  $mobile-relative: null,
38
53
  $important: null
39
54
  ) {
40
- $scale-factor: if(
41
- $unit == px,
42
- unquote("--computed-scale-factor-px"),
43
- unquote("--computed-scale-factor-rem")
44
- );
55
+ $scale-factor: get-scale-factor($unit);
45
56
 
46
57
  // If it's a percentage-based value (like letter-spacing), scale it based on the relative property
47
58
  @if $is-percentage == true {
48
59
  @if $desktop-relative != null {
49
60
  $calc-value: calc(
50
- #{$desktop-value} / 100 * (var(#{$scale-factor}) * #{$desktop-relative})
61
+ #{$desktop-value} /
62
+ 100 *
63
+ (var(#{$scale-factor}) * #{$desktop-relative}#{$unit})
51
64
  );
52
65
  #{$property}: #{$calc-value}#{$important};
53
66
  }
54
67
 
55
68
  @media screen and (min-width: 768px) and (max-width: 991px) {
56
- $tablet-scale-factor: if(
57
- $unit == px,
58
- unquote("--computed-tablet-scale-factor-px"),
59
- unquote("--computed-tablet-scale-factor-rem")
60
- );
69
+ $tablet-scale-factor: get-tablet-scale-factor($unit);
61
70
  @if $desktop-relative != null and $mobile-relative != null {
62
71
  $calc-value: calc(
63
72
  #{$mobile-value} /
@@ -65,9 +74,9 @@
65
74
  (
66
75
  var(#{$tablet-scale-factor}) *
67
76
  (
68
- #{$mobile-relative} +
77
+ #{$mobile-relative}#{$unit} +
69
78
  var(--tablet-proportion-scale-factor) *
70
- (#{$desktop-relative} - #{$mobile-relative})
79
+ (#{$desktop-relative}#{$unit} - #{$mobile-relative}#{$unit})
71
80
  )
72
81
  )
73
82
  );
@@ -76,16 +85,12 @@
76
85
  }
77
86
 
78
87
  @media screen and (max-width: 767px) {
79
- $mobile-scale-factor: if(
80
- $unit == px,
81
- unquote("--computed-mobile-scale-factor-px"),
82
- unquote("--computed-mobile-scale-factor-rem")
83
- );
88
+ $mobile-scale-factor: get-mobile-scale-factor($unit);
84
89
  @if $mobile-relative != null {
85
90
  $calc-value: calc(
86
91
  #{$mobile-value} /
87
92
  100 *
88
- (var(#{$mobile-scale-factor}) * #{$mobile-relative})
93
+ (var(#{$mobile-scale-factor}) * #{$mobile-relative}#{$unit})
89
94
  );
90
95
  #{$property}: #{$calc-value}#{$important};
91
96
  }
@@ -107,11 +112,7 @@
107
112
  }
108
113
 
109
114
  @media screen and (min-width: 768px) and (max-width: 991px) {
110
- $tablet-scale-factor: if(
111
- $unit == px,
112
- unquote("--computed-tablet-scale-factor-px"),
113
- unquote("--computed-tablet-scale-factor-rem")
114
- );
115
+ $tablet-scale-factor: get-tablet-scale-factor($unit);
115
116
  @if type-of($desktop-value) == list {
116
117
  $tablet-scaled: ();
117
118
  @for $i from 1 through length($desktop-value) {
@@ -122,9 +123,9 @@
122
123
  calc(
123
124
  var(#{$tablet-scale-factor}) *
124
125
  (
125
- #{$m-val} +
126
+ #{$m-val}#{$unit} +
126
127
  var(--tablet-proportion-scale-factor) *
127
- (#{$d-val} - #{$m-val})
128
+ (#{$d-val}#{$unit} - #{$m-val}#{$unit})
128
129
  )
129
130
  )
130
131
  );
@@ -134,9 +135,9 @@
134
135
  $calc-value: calc(
135
136
  var(#{$tablet-scale-factor}) *
136
137
  (
137
- #{$mobile-value} +
138
+ #{$mobile-value}#{$unit} +
138
139
  var(--tablet-proportion-scale-factor) *
139
- (#{$desktop-value} - #{$mobile-value})
140
+ (#{$desktop-value}#{$unit} - #{$mobile-value}#{$unit})
140
141
  )
141
142
  );
142
143
  #{$property}: #{$calc-value}#{$important};
@@ -144,11 +145,7 @@
144
145
  }
145
146
 
146
147
  @media screen and (max-width: 767px) {
147
- $mobile-scale-factor: if(
148
- $unit == px,
149
- unquote("--computed-mobile-scale-factor-px"),
150
- unquote("--computed-mobile-scale-factor-rem")
151
- );
148
+ $mobile-scale-factor: get-mobile-scale-factor($unit);
152
149
  @if type-of($mobile-value) == list {
153
150
  $mobile-scaled: ();
154
151
  @each $val in $mobile-value {
@@ -8,17 +8,14 @@
8
8
  $tablet-width: 768px,
9
9
  $mobile-width: 390px
10
10
  ) {
11
- // Desktop scale factor
12
- --computed-scale-factor-px: calc(100vw / #{$desktop-width});
13
- --computed-scale-factor-rem: calc(100vw / #{$desktop-width} / 16);
11
+ // Desktop scale factor (generic - unit is appended in calc expressions)
12
+ --computed-scale-factor: calc(100vw / #{$desktop-width});
14
13
 
15
- // Tablet scale factor
16
- --computed-tablet-scale-factor-px: calc(100vw / #{$tablet-width});
17
- --computed-tablet-scale-factor-rem: calc(100vw / #{$tablet-width} / 16);
14
+ // Tablet scale factor (generic - unit is appended in calc expressions)
15
+ --computed-tablet-scale-factor: calc(100vw / #{$tablet-width});
18
16
 
19
- // Mobile scale factor
20
- --computed-mobile-scale-factor-px: calc(100vw / #{$mobile-width});
21
- --computed-mobile-scale-factor-rem: calc(100vw / #{$mobile-width} / 16);
17
+ // Mobile scale factor (generic - unit is appended in calc expressions)
18
+ --computed-mobile-scale-factor: calc(100vw / #{$mobile-width});
22
19
 
23
20
  // Tablet proportion scale factor for interpolation between mobile and desktop values
24
21
  --tablet-proportion-scale-factor: calc(