@guebbit/css-toolkit 1.1.1 → 1.1.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.
Files changed (105) hide show
  1. package/CHANGELOG +2 -0
  2. package/docs/.postcssrc.cjs +12 -0
  3. package/docs/.vitepress/config.ts +89 -0
  4. package/docs/.vitepress/dist/404.html +21 -0
  5. package/docs/.vitepress/dist/assets/app.BlbAZR_S.js +1 -0
  6. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.KjYvZcUz.js +1 -0
  7. package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.BwVVD-os.js +7 -0
  8. package/docs/.vitepress/dist/assets/chunks/framework.Bt53DRYp.js +18 -0
  9. package/docs/.vitepress/dist/assets/chunks/theme.VODMs8XS.js +2 -0
  10. package/docs/.vitepress/dist/assets/colors_bootstrap.md.Bfy-p7dM.js +1 -0
  11. package/docs/.vitepress/dist/assets/colors_bootstrap.md.Bfy-p7dM.lean.js +1 -0
  12. package/docs/.vitepress/dist/assets/colors_brands.md.Ch21qzT7.js +1 -0
  13. package/docs/.vitepress/dist/assets/colors_brands.md.Ch21qzT7.lean.js +1 -0
  14. package/docs/.vitepress/dist/assets/colors_customs.md.CrumAnve.js +1 -0
  15. package/docs/.vitepress/dist/assets/colors_customs.md.CrumAnve.lean.js +1 -0
  16. package/docs/.vitepress/dist/assets/functions_colors.md.Dz-AUCFY.js +8 -0
  17. package/docs/.vitepress/dist/assets/functions_colors.md.Dz-AUCFY.lean.js +8 -0
  18. package/docs/.vitepress/dist/assets/functions_helpers.md.BLiEkjA1.js +1 -0
  19. package/docs/.vitepress/dist/assets/functions_helpers.md.BLiEkjA1.lean.js +1 -0
  20. package/docs/.vitepress/dist/assets/functions_strings.md.BHTeKsax.js +1 -0
  21. package/docs/.vitepress/dist/assets/functions_strings.md.BHTeKsax.lean.js +1 -0
  22. package/docs/.vitepress/dist/assets/index.md.Dwdim14B.js +1 -0
  23. package/docs/.vitepress/dist/assets/index.md.Dwdim14B.lean.js +1 -0
  24. package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  25. package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  26. package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  27. package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  28. package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  29. package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  30. package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  31. package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  32. package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  33. package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  34. package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  35. package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  36. package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  37. package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  38. package/docs/.vitepress/dist/assets/mixins_build-aspect-ratio.md.l9MRJQQl.js +1 -0
  39. package/docs/.vitepress/dist/assets/mixins_build-aspect-ratio.md.l9MRJQQl.lean.js +1 -0
  40. package/docs/.vitepress/dist/assets/mixins_build-compatibility.md.t0sS5a2s.js +30 -0
  41. package/docs/.vitepress/dist/assets/mixins_build-compatibility.md.t0sS5a2s.lean.js +30 -0
  42. package/docs/.vitepress/dist/assets/mixins_build-scrollbar.md.C-TaPgpo.js +32 -0
  43. package/docs/.vitepress/dist/assets/mixins_build-scrollbar.md.C-TaPgpo.lean.js +32 -0
  44. package/docs/.vitepress/dist/assets/mixins_create-colors.md.Bs8hXar1.js +1 -0
  45. package/docs/.vitepress/dist/assets/mixins_create-colors.md.Bs8hXar1.lean.js +1 -0
  46. package/docs/.vitepress/dist/assets/mixins_create-helper-margin.md.BFzwO-0T.js +46 -0
  47. package/docs/.vitepress/dist/assets/mixins_create-helper-margin.md.BFzwO-0T.lean.js +46 -0
  48. package/docs/.vitepress/dist/assets/mixins_create-helper-padding.md.Ci6DL4m-.js +45 -0
  49. package/docs/.vitepress/dist/assets/mixins_create-helper-padding.md.Ci6DL4m-.lean.js +45 -0
  50. package/docs/.vitepress/dist/assets/mixins_create-instruction.md.CGTPQqQv.js +20 -0
  51. package/docs/.vitepress/dist/assets/mixins_create-instruction.md.CGTPQqQv.lean.js +20 -0
  52. package/docs/.vitepress/dist/assets/style.B-ztagZG.css +1 -0
  53. package/docs/.vitepress/dist/colors/bootstrap.html +24 -0
  54. package/docs/.vitepress/dist/colors/brands.html +24 -0
  55. package/docs/.vitepress/dist/colors/customs.html +24 -0
  56. package/docs/.vitepress/dist/functions/colors.html +31 -0
  57. package/docs/.vitepress/dist/functions/helpers.html +24 -0
  58. package/docs/.vitepress/dist/functions/strings.html +24 -0
  59. package/docs/.vitepress/dist/hashmap.json +1 -0
  60. package/docs/.vitepress/dist/index.html +24 -0
  61. package/docs/.vitepress/dist/mixins/build-aspect-ratio.html +24 -0
  62. package/docs/.vitepress/dist/mixins/build-compatibility.html +53 -0
  63. package/docs/.vitepress/dist/mixins/build-scrollbar.html +55 -0
  64. package/docs/.vitepress/dist/mixins/create-colors.html +24 -0
  65. package/docs/.vitepress/dist/mixins/create-helper-margin.html +69 -0
  66. package/docs/.vitepress/dist/mixins/create-helper-padding.html +68 -0
  67. package/docs/.vitepress/dist/mixins/create-instruction.html +43 -0
  68. package/docs/.vitepress/theme/index.js +12 -0
  69. package/docs/colors/bootstrap.md +1 -0
  70. package/docs/colors/brands.md +1 -0
  71. package/docs/colors/customs.md +1 -0
  72. package/docs/functions/colors.md +64 -0
  73. package/docs/functions/helpers.md +1 -0
  74. package/docs/functions/strings.md +1 -0
  75. package/docs/index.md +1 -0
  76. package/docs/logo.svg +55 -0
  77. package/docs/logotype.svg +149 -0
  78. package/docs/mixins/build-aspect-ratio.md +1 -0
  79. package/docs/mixins/build-compatibility.md +23 -0
  80. package/docs/mixins/build-scrollbar.md +19 -0
  81. package/docs/mixins/create-colors.md +1 -0
  82. package/docs/mixins/create-helper-margin.md +25 -0
  83. package/docs/mixins/create-helper-padding.md +24 -0
  84. package/docs/mixins/create-instruction.md +33 -0
  85. package/package.json +18 -14
  86. package/src/colors/_bootstrap.scss +181 -0
  87. package/src/colors/_brands.scss +20 -0
  88. package/src/colors/_customs.scss +55 -0
  89. package/src/colors/_index.scss +200 -0
  90. package/src/functions/_colors.scss +109 -0
  91. package/src/functions/_helpers.scss +42 -0
  92. package/src/functions/_strings.scss +31 -0
  93. package/src/index.scss +13 -0
  94. package/src/mixins/_build-aspect-ratio.scss +37 -0
  95. package/src/mixins/_build-compatibility.scss +28 -0
  96. package/src/mixins/_build-scrollbar.scss +32 -0
  97. package/src/mixins/_create-colors.scss +119 -0
  98. package/src/mixins/_create-helper-margin.scss +39 -0
  99. package/src/mixins/_create-helper-padding.scss +40 -0
  100. package/src/mixins/_create-instructions.scss +11 -0
  101. package/test/compile.test.js +97 -0
  102. package/test/lint.test.js +50 -0
  103. package/test/test.css +5805 -0
  104. package/test/test.scss +148 -0
  105. package/vite.config.ts +26 -0
@@ -0,0 +1,109 @@
1
+ @use "sass:color" as color;
2
+ @use "sass:math" as math;
3
+ @use "sass:string" as string;
4
+
5
+ /**
6
+ * Return opaque color
7
+ * color-opaque(#fff, rgba(0, 0, 0, .5)) => #808080
8
+ * function credited to https://getbootstrap.com/
9
+ */
10
+ @function color-opaque($background, $foreground) {
11
+ @return color.mix(rgba($foreground, 1), $background, opacity($foreground) * 100%, $method: rgb);
12
+ }
13
+
14
+ /**
15
+ * Shade the color if the weight is positive, else tint it
16
+ * function credited to https://getbootstrap.com/
17
+ */
18
+ @function color-shift($color, $weight) {
19
+ @return if($weight > 0, color.scale($color, $lightness: $weight), color.scale($color, $lightness: -$weight));
20
+ }
21
+
22
+
23
+ /**
24
+ * Compares contrast of a given color to the light/dark arguments and returns whichever is most "contrasty"
25
+ */
26
+ @function color-contrast($color: #fff, $dark: #000, $light: #fff) {
27
+ @if type-of($color) != color or $color == transparent {
28
+ @return inherit;
29
+ }
30
+ $color-brightness: color-brightness($color);
31
+ $light-text-brightness: color-brightness($light);
32
+ $dark-text-brightness: color-brightness($dark);
33
+
34
+ @return if(abs($color-brightness - $light-text-brightness) > abs($color-brightness - $dark-text-brightness), $light, $dark);
35
+ }
36
+
37
+
38
+
39
+ // Return WCAG2.1 relative luminance
40
+ // See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
41
+ // See https://en.wikipedia.org/wiki/Relative_luminance
42
+ // Gives %, less than 50 darker is better, less than 50, lighter.
43
+ @function color-brightness($color) {
44
+ // fallback
45
+ @if $color == transparent or type-of($color) != color {
46
+ @return 100;
47
+ }
48
+ @return math.div((
49
+ (color.channel($color, "red", $space: rgb) * .299) +
50
+ (color.channel($color, "green", $space: rgb) * .587) +
51
+ (color.channel($color, "blue", $space: rgb) * .114)
52
+ ), 255 * 100%);
53
+ }
54
+
55
+ /**
56
+ * NEW numeric annotation
57
+ * Hex to RGB (only numbers, transparentize would add rgba(*))
58
+ * $color
59
+ * $alpha:
60
+ * - 0: never 4° digit
61
+ * - 1: always 4° digit
62
+ * - 2: 4° digit only when needed
63
+ * $classic: false = new number annotation
64
+ */
65
+ @function extract-colors($color: #fff, $mode: 2, $classic: false){
66
+ // colors only
67
+ @if $color == transparent or type-of($color) != color {
68
+ @return $color;
69
+ }
70
+ // new annotation
71
+ $delimiter: " ";
72
+ $delimiter-alpha: " / ";
73
+ // old annotation
74
+ @if $classic{
75
+ $delimiter: ", ";
76
+ $delimiter-alpha: ", ";
77
+ }
78
+ $alpha: alpha($color);
79
+ @if $mode == 1 or ($mode == 2 and $alpha == 1) {
80
+ @return color.channel($color, "red", $space: rgb) +
81
+ $delimiter + color.channel($color, "green", $space: rgb) +
82
+ $delimiter + color.channel($color, "blue", $space: rgb);
83
+ }
84
+ // Regular RGBA compliant result ("number" notation)
85
+ @return color.channel($color, "red", $space: rgb) +
86
+ $delimiter + color.channel($color, "green", $space: rgb) +
87
+ $delimiter + color.channel($color, "blue", $space: rgb) +
88
+ $delimiter-alpha + color.channel($color, "alpha"); // * 100%
89
+ }
90
+
91
+ /**
92
+ * Create default collection
93
+ */
94
+ // TODO CHECK
95
+ @function create-collection($color){
96
+ $list: (
97
+ "100": color.scale($color, $lightness: 80%),
98
+ "200": color.scale($color, $lightness: 60%),
99
+ "300": color.scale($color, $lightness: 40%),
100
+ "400": color.scale($color, $lightness: 20%),
101
+ "500": $color,
102
+ "600": color.scale($color, $lightness: -20%),
103
+ "700": color.scale($color, $lightness: -40%),
104
+ "800": color.scale($color, $lightness: -60%),
105
+ "900": color.scale($color, $lightness: -80%)
106
+ );
107
+
108
+ @return $list
109
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Giving a list of variables and values,
3
+ * from start to end, try all the values until a non-null is found
4
+ */
5
+ @function no-null-var($list: ()){
6
+ @each $value in $list {
7
+ // stylelint-disable-next-line scss/at-if-no-null
8
+ @if $value != null and $value != undefined {
9
+ @return $value;
10
+ }
11
+ }
12
+ @return null;
13
+ }
14
+
15
+ /**
16
+ * If the color is the checked one, return inherit
17
+ */
18
+ @function no-target-var($check: transparent, $color: transparent){
19
+ @if $color == $check {
20
+ @return inherit;
21
+ }
22
+ @return $color;
23
+ }
24
+
25
+
26
+ /**
27
+ * This function is to be used to return nested key values within a nested map
28
+ * @parameter {Variable} $map [null] - pass in map to be evaluated
29
+ * @parameter {Variable} $keys [null] - pass in keys to be evaluated
30
+ */
31
+ // $map: (
32
+ // 'size': (
33
+ // 'sml': 10px
34
+ // )
35
+ // );
36
+ // $var: map-deep-get($map, 'size', 'sml'); // => 10px
37
+ @function map-deep-get($map, $keys...) {
38
+ @each $key in $keys {
39
+ $map: map-get($map, $key);
40
+ }
41
+ @return $map;
42
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ Split string into lists
3
+ */
4
+ @function string-split($string, $separator: "-") {
5
+ // empty array/list
6
+ $split-arr: ();
7
+ // first index of separator in string
8
+ $index : str-index($string, $separator);
9
+ // loop through string
10
+ @while $index != null {
11
+ // get the substring from the first character to the separator
12
+ $item: str-slice($string, 1, $index - 1);
13
+ // push item to array
14
+ $split-arr: append($split-arr, $item);
15
+ // remove item and separator from string
16
+ $string: str-slice($string, $index + 1);
17
+ // find new index of separator
18
+ $index : str-index($string, $separator);
19
+ }
20
+ // add the remaining string to list (the last item)
21
+ $split-arr: append($split-arr, $string);
22
+
23
+ @return $split-arr;
24
+ }
25
+
26
+ /**
27
+ Check if $string ends with $find
28
+ */
29
+ @function string-ends-with($string, $find) {
30
+ @return (str-length($string) >= str-length($find)) and (str-slice($string, (str-length($string) - str-length($find) + 1)) == $find);
31
+ }
package/src/index.scss ADDED
@@ -0,0 +1,13 @@
1
+ @forward "./colors";
2
+
3
+ @forward "./functions/colors";
4
+ @forward "./functions/helpers";
5
+ @forward "./functions/strings";
6
+
7
+ @forward "./mixins/build-aspect-ratio";
8
+ @forward "./mixins/build-compatibility";
9
+ @forward "./mixins/build-scrollbar";
10
+ @forward "./mixins/create-colors";
11
+ @forward "./mixins/create-instructions";
12
+ @forward "./mixins/create-helper-margin";
13
+ @forward "./mixins/create-helper-padding";
@@ -0,0 +1,37 @@
1
+ @use "../functions/strings" as guebbit;
2
+
3
+ /**
4
+ * Use in the parent\container, to be coupled with {build-aspect-ratio-anchor}
5
+ */
6
+ @mixin build-aspect-ratio-container($ratio: 100%){
7
+ position: relative;
8
+ // aspect-ratio: #{$height} / #{$width};
9
+
10
+ &::before{
11
+ content: "";
12
+ display: block;
13
+ padding-top: #{$ratio};
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Use in the child that "gives" form to the parent that has the respective {build-aspect-ratio-container}
19
+ */
20
+ @mixin build-aspect-ratio-anchor{
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ }
27
+
28
+ /**
29
+ * aspect ratio shortcut
30
+ */
31
+ @mixin build-aspect-ratio($ratio: 100%){
32
+ @include build-aspect-ratio-container($ratio);
33
+
34
+ & > * {
35
+ @include build-aspect-ratio-anchor;
36
+ }
37
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Compatibility mode for browsers
3
+ * @param string $browser: target browser
4
+ * @content
5
+ **/
6
+ @mixin build-compatibility($browser) {
7
+ // INTERNET EXPLORER
8
+ @if $browser == "ie" {
9
+ @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
10
+ @content;
11
+ }
12
+ }
13
+ // MICROSOFT EDGE
14
+ @if $browser == "edge" {
15
+ @supports (-ms-ime-align:auto) {
16
+ @content;
17
+ }
18
+ }
19
+ // FIREFOX
20
+ @if $browser == "firefox" {
21
+ @supports (-moz-appearance:none) {
22
+ @content;
23
+ }
24
+ }
25
+
26
+ // OPERA TODO
27
+ // SAFARI TODO
28
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Builder - scrollbars of element
3
+ * @param string $color
4
+ * @param pixels $size
5
+ * @param $background: if false, has default lighten 40%
6
+ */
7
+ @mixin build-scrollbar($size: "4px", $color: "#fff", $bg: "auto", $radius: "10px") {
8
+ $fallback-color: #fff;
9
+ $fallback-bg: transparent;
10
+
11
+ @if $bg == "auto" {
12
+ $bg: $fallback-bg;
13
+ }
14
+
15
+ &::-webkit-scrollbar {
16
+ width: $size;
17
+ height: $size;
18
+ background-color: $fallback-bg;
19
+ background-color: $bg;
20
+ }
21
+
22
+ &::-webkit-scrollbar-thumb {
23
+ border-radius: $radius;
24
+ background-color: $fallback-color;
25
+ background-color: $color;
26
+ }
27
+
28
+ &::-webkit-scrollbar-corner {
29
+ background-color: $fallback-bg;
30
+ background-color: $bg;
31
+ }
32
+ }
@@ -0,0 +1,119 @@
1
+ @use "sass:list";
2
+ @use "sass:string";
3
+ @use "../functions/colors" as color-functions;
4
+
5
+ /**
6
+ * Create all the needed classes for the requested colors
7
+ * $color-list - list of colors (like $colors-collection: ("branch": ( "leaf: $color" )))
8
+ * $branch-list: - when filled: becomes a whitelist (aka: include only listed brands)
9
+ * $feature-list: - when filled: becomes a whitelist. May become cumbersome and many are not needed. Use with care.
10
+ * - root
11
+ * - on-root (color's "best contrast" partner color)
12
+ * - color
13
+ * - background
14
+ * - border
15
+ * - pseudo (bg only, color very rarely used)
16
+ * - hover
17
+ * $prefix: prefix that applies to classes
18
+ */
19
+ @mixin create-colors($color-list: (), $branch-list: (), $feature-list: (), $prefix: "") {
20
+ // for every branch
21
+ @each $branch-name, $branch in $color-list {
22
+ // check that there is no $branch-list or, if present, it's correctly whitelisted
23
+ @if list.length($branch-list) < 1 or list.index($branch-list, $branch-name) {
24
+
25
+ // for every leaf
26
+ @each $sname, $scolor in $branch {
27
+
28
+ @if not list.index($branch-name, "advanced"){
29
+ @if list.length($feature-list) < 1 or list.index($feature-list, "color") {
30
+ .#{$prefix}#{$branch-name}-#{$sname}-text {
31
+ color: $scolor !important;
32
+ }
33
+ }
34
+ @if list.length($feature-list) < 1 or list.index($feature-list, "border") {
35
+ .#{$prefix}#{$branch-name}-#{$sname}-border {
36
+ border-color: $scolor !important;
37
+ }
38
+ }
39
+ }
40
+
41
+ @if list.length($feature-list) < 1 or list.index($feature-list, "background") {
42
+ .#{$prefix}#{$branch-name}-#{$sname}-bg {
43
+ background: $scolor !important;
44
+ }
45
+ }
46
+
47
+ @if list.length($feature-list) < 1 or list.index($feature-list, "pseudo") {
48
+ .#{$prefix}#{$branch-name}-#{$sname}-pseudo-bg {
49
+ &::after,
50
+ &::before {
51
+ background: $scolor !important;
52
+ }
53
+ }
54
+ }
55
+
56
+ @if list.length($feature-list) < 1 or list.index($feature-list, "hover"){
57
+
58
+ @if not list.index($branch-name, "advanced"){
59
+ @if list.length($feature-list) < 1 or list.index($feature-list, "color"){
60
+ .#{$prefix}#{$branch-name}-#{$sname}-hover-text {
61
+ &:hover {
62
+ color: $scolor !important;
63
+ }
64
+ }
65
+ }
66
+ @if list.length($feature-list) < 1 or list.index($feature-list, "border"){
67
+ .#{$prefix}#{$branch-name}-#{$sname}-hover-border {
68
+ &:hover {
69
+ border-color: $scolor !important;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ @if list.length($feature-list) < 1 or list.index($feature-list, "background") {
76
+ .#{$prefix}#{$branch-name}-#{$sname}-hover-bg {
77
+ &:hover {
78
+ background: $scolor !important;
79
+ }
80
+ }
81
+ }
82
+
83
+ @if list.length($feature-list) < 1 or list.index($feature-list, "pseudo") {
84
+ .#{$prefix}#{$branch-name}-#{$sname}-hover-pseudo-bg {
85
+ &:hover{
86
+ &::after,
87
+ &::before {
88
+ background: $scolor !important;
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * CSS VARS on root (they will be translated in "RGB" instead of "HEX"
100
+ */
101
+ :root{
102
+ @if list.length($feature-list) < 1 or list.index($feature-list, "root"){
103
+ @each $branch-name, $branch in $color-list {
104
+ @each $sname, $scolor in $branch {
105
+ --#{$prefix}#{$branch-name}-#{$sname}: #{color-functions.extract-colors($scolor)};
106
+ }
107
+ }
108
+ }
109
+ @if list.length($feature-list) < 1 or list.index($feature-list, "on-root"){
110
+ @each $branch-name, $branch in $color-list {
111
+ @each $sname, $scolor in $branch {
112
+ // @if type-of($scolor) == color {
113
+ --#{$prefix}on-#{$branch-name}-#{$sname}: #{color-functions.extract-colors(color-functions.color-contrast($scolor))};
114
+ // _}
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ *
3
+ * t - applies the spacing for margin-top
4
+ * b - applies the spacing for margin-bottom
5
+ * l - applies the spacing for margin-left
6
+ * r - applies the spacing for margin-right
7
+ * x - applies the spacing for both *-left and *-right
8
+ * y - applies the spacing for both *-top and *-bottom
9
+ * a - applies the spacing for the property in all directions
10
+ *
11
+ * @param {Array<name,value>[]} measure-list - postfix name and value
12
+ */
13
+ @mixin create-helper-margin($measure-list: (), $important: false, $prefix: "") {
14
+ @each $name, $val in $measure-list {
15
+ .#{$prefix}mt-#{$name} {
16
+ margin-top: #{$val} #{if($important == true, "!important", "")};
17
+ }
18
+ .#{$prefix}mb-#{$name} {
19
+ margin-bottom: #{$val} #{if($important == true, "!important", "")};
20
+ }
21
+ .#{$prefix}ml-#{$name} {
22
+ margin-left: #{$val} #{if($important == true, "!important", "")};
23
+ }
24
+ .#{$prefix}mr-#{$name} {
25
+ margin-right: #{$val} #{if($important == true, "!important", "")};
26
+ }
27
+ .#{$prefix}mx-#{$name} {
28
+ margin-right: #{$val} #{if($important == true, "!important", "")};
29
+ margin-left: #{$val} #{if($important == true, "!important", "")};
30
+ }
31
+ .#{$prefix}my-#{$name} {
32
+ margin-top: #{$val} #{if($important == true, "!important", "")};
33
+ margin-bottom: #{$val} #{if($important == true, "!important", "")};
34
+ }
35
+ .#{$prefix}ma-#{$name} {
36
+ margin: #{$val} #{if($important == true, "!important", "")};
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ *
3
+ * t - applies the spacing for padding-top
4
+ * b - applies the spacing for padding-bottom
5
+ * l - applies the spacing for padding-left
6
+ * r - applies the spacing for padding-right
7
+ * x - applies the spacing for both *-left and *-right
8
+ * y - applies the spacing for both *-top and *-bottom
9
+ * a - applies the spacing for the property in all directions
10
+
11
+ * @param {Array<name,value>[]} measure-list - postfix name and value
12
+ */
13
+ @mixin create-helper-padding($measure-list: (), $important: false, $prefix: "") {
14
+
15
+ @each $name, $val in $measure-list {
16
+ .#{$prefix}pt-#{$name} {
17
+ padding-top: #{$val} #{if($important == true, "!important", "")};
18
+ }
19
+ .#{$prefix}pb-#{$name} {
20
+ padding-bottom: #{$val} #{if($important == true, "!important", "")};
21
+ }
22
+ .#{$prefix}pl-#{$name} {
23
+ padding-left: #{$val} #{if($important == true, "!important", "")};
24
+ }
25
+ .#{$prefix}pr-#{$name} {
26
+ padding-right: #{$val} #{if($important == true, "!important", "")};
27
+ }
28
+ .#{$prefix}px-#{$name} {
29
+ padding-right: #{$val} #{if($important == true, "!important", "")};
30
+ padding-left: #{$val} #{if($important == true, "!important", "")};
31
+ }
32
+ .#{$prefix}py-#{$name} {
33
+ padding-top: #{$val} #{if($important == true, "!important", "")};
34
+ padding-bottom: #{$val} #{if($important == true, "!important", "")};
35
+ }
36
+ .#{$prefix}pa-#{$name} {
37
+ padding: #{$val} #{if($important == true, "!important", "")};
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ CSS single instructions generator
3
+ @param {Array<name,value>[]} measure-list - postfix name and value
4
+ */
5
+ @mixin create-instructions($instruction, $measure-list: (), $important: false, $prefix: "", $delimiter: "-") {
6
+ @each $name, $val in $measure-list {
7
+ .#{$prefix}#{$instruction}#{$delimiter}#{$name} {
8
+ #{$instruction}: #{$val} #{if($important == true, "!important", "")}
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,97 @@
1
+ import { describe, it } from "mocha";
2
+ import { expect } from "chai";
3
+ import fs from "fs";
4
+ import util from "util";
5
+ import * as sass from "sass";
6
+ import path from "path";
7
+ import { fileURLToPath } from "url";
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ let cssCompiled;
13
+
14
+ function sassCompiler(){
15
+ return util.promisify(sass.render)({
16
+ includePaths: ['./scss'],
17
+ file: path.join(__dirname, './test.scss'),
18
+ // outputStyle: 'compressed'
19
+ })
20
+ .then(result => result?.css?.toString());
21
+ }
22
+
23
+ describe("COMPILE", function() {
24
+ // to remove timeout error
25
+ this.timeout(10000);
26
+
27
+ it('Should compile', async function() {
28
+ cssCompiled = await sassCompiler();
29
+ // Not necessary, but let's compile the file
30
+ fs.writeFile(path.join(__dirname, 'test.css'), cssCompiled, () => {});
31
+ });
32
+
33
+ it('Check some rules', function() {
34
+ // -- TODO
35
+ expect(cssCompiled).to.contain('.blue-400-text {');
36
+ expect(cssCompiled).to.contain('color: rgb(61.4, 139, 253.4) !important');
37
+ expect(cssCompiled).to.contain('.blue-500-bg {');
38
+ expect(cssCompiled).to.contain('background: #0d6efd !important');
39
+ // --
40
+ expect(cssCompiled).to.contain('--blue-400: 61.4 139 253.4;');
41
+ expect(cssCompiled).to.contain('--manga-red-500: 212 24 22;');
42
+ expect(cssCompiled).to.contain('--advanced-brand-instagram: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);');
43
+ expect(cssCompiled).to.contain('.mt-auto {');
44
+ expect(cssCompiled).to.contain('margin-top: auto;');
45
+ expect(cssCompiled).to.contain('.my-48 {');
46
+ expect(cssCompiled).to.contain('margin-top: 48px;');
47
+ expect(cssCompiled).to.contain('margin-bottom: 48px;');
48
+ expect(cssCompiled).to.contain('.width-100 {');
49
+ expect(cssCompiled).to.contain('width: 100% !important;');
50
+ expect(cssCompiled).to.contain('.flex-gap-24 {');
51
+ expect(cssCompiled).to.contain('gap: 24px !important;');
52
+ // -
53
+ expect(cssCompiled).to.contain('.aspect-ratio-1-1::before {');
54
+ expect(cssCompiled).to.contain('padding-top: 100%;');
55
+ expect(cssCompiled).to.contain('.aspect-ratio-16-9::before {');
56
+ expect(cssCompiled).to.contain('padding-top: 56%;');
57
+ // -
58
+ expect(cssCompiled).to.contain('@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {');
59
+ expect(cssCompiled).to.contain('@supports (-ms-ime-align: auto) {');
60
+ expect(cssCompiled).to.contain('@supports (-moz-appearance: none) {');
61
+ // -- RGB or hex based on color precision. Use sass:color hex or rgb to be sure
62
+ expect(cssCompiled).to.contain('--color-opaque-1: #111111;');
63
+ expect(cssCompiled).to.contain('--color-opaque-2: rgb(110.5, 110.5, 110.5);');
64
+ // --
65
+ expect(cssCompiled).to.contain('--color-shift-1: rgb(89.25, 89.25, 89.25);');
66
+ expect(cssCompiled).to.contain('--color-shift-2: rgb(229.5, 229.5, 229.5);');
67
+ // --
68
+ expect(cssCompiled).to.contain('--color-contrast-1: #fff;');
69
+ expect(cssCompiled).to.contain('--color-contrast-2: #000;');
70
+ // --
71
+ expect(cssCompiled).to.contain('--color-brightness-1: #fff;');
72
+ expect(cssCompiled).to.contain('--color-brightness-2: #000;');
73
+ // --
74
+ expect(cssCompiled).to.contain('--extract-colors-1: 255 255 255;');
75
+ expect(cssCompiled).to.contain('--extract-colors-2: 34 34 34;');
76
+ expect(cssCompiled).to.contain('--extract-colors-3: 221 221 221;');
77
+ expect(cssCompiled).to.contain('--extract-colors-4: 34, 34, 34;');
78
+ expect(cssCompiled).to.contain('--extract-colors-5: 221, 221, 221;');
79
+ expect(cssCompiled).to.contain('--extract-colors-6: 0 255 0;');
80
+ expect(cssCompiled).to.contain('--extract-colors-7: 0 255 0 / 0.5;');
81
+ expect(cssCompiled).to.contain('--extract-colors-8: 0, 255, 0;');
82
+ expect(cssCompiled).to.contain('--extract-colors-9: 0, 255, 0, 0.5;');
83
+ expect(cssCompiled).to.contain('--extract-colors-10: 0 255 0;');
84
+ expect(cssCompiled).to.contain('--extract-colors-11: 0 255 0 / 0.5;');
85
+ expect(cssCompiled).to.contain('--extract-colors-12: 0, 255, 0;');
86
+ expect(cssCompiled).to.contain('--extract-colors-13: 0, 255, 0, 0.5;');
87
+ // --
88
+ expect(cssCompiled).to.contain('--no-null-1: transparent;');
89
+ expect(cssCompiled).to.contain('--no-null-2: blue;');
90
+ // --
91
+ expect(cssCompiled).to.contain('--no-trasparent-1: inherit;');
92
+ expect(cssCompiled).to.contain('--no-trasparent-2: inherit;');
93
+ expect(cssCompiled).to.contain('--no-trasparent-3: #123456;');
94
+ // --
95
+ expect(cssCompiled).to.contain('--map-deep-get: 10px;');
96
+ });
97
+ });
@@ -0,0 +1,50 @@
1
+ import { describe, it } from 'mocha';
2
+ import { expect } from "chai";
3
+ import stylelint from "stylelint";
4
+ import path from "path";
5
+ import styleLintFormatter from "stylelint-config-standard-scss";
6
+ import { fileURLToPath } from "url";
7
+
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+
13
+ describe("LINT", function() {
14
+ // to remove timeout error
15
+ this.timeout(10000);
16
+
17
+ it('Generic linting', async () => {
18
+ return stylelint.lint({
19
+ configFile: path.join(__dirname, '../.stylelintrc.json'),
20
+ ignorePath: path.join(__dirname, '../.stylelintignore'),
21
+ formatter: styleLintFormatter,
22
+ files: [
23
+ path.join(__dirname, './test.scss'),
24
+ ],
25
+ })
26
+ .then(function ({ errored, report }) {
27
+ if(!errored)
28
+ return false;
29
+ // show me errors
30
+ const reportsArray = JSON.parse(report);
31
+ for(let i = reportsArray.length; i--; ){
32
+ const reportKeys = Object.keys(reportsArray[i]);
33
+ for(let k = reportKeys.length; k--; ){
34
+ const reportsValues = reportsArray[i][reportKeys[k]];
35
+ if(reportsValues.length <= 0)
36
+ continue;
37
+ if(Array.isArray(reportsValues)){
38
+ console.log("-----------" + reportKeys[k] + "-----------");
39
+ for(let x = reportsValues.length; x--; )
40
+ console.log(reportsValues[x]);
41
+ }else{
42
+ console.log(reportKeys[k] + ": " + reportsValues);
43
+ }
44
+ }
45
+ }
46
+ return true;
47
+ })
48
+ .then(result => expect(result).to.be.false);
49
+ });
50
+ });