@guebbit/css-toolkit 1.1.1 → 1.1.2

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 (104) hide show
  1. package/docs/.postcssrc.cjs +12 -0
  2. package/docs/.vitepress/config.ts +89 -0
  3. package/docs/.vitepress/dist/404.html +21 -0
  4. package/docs/.vitepress/dist/assets/app.CpyNzro9.js +1 -0
  5. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.CYE7S9pS.js +1 -0
  6. package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.DrgBd5f4.js +7 -0
  7. package/docs/.vitepress/dist/assets/chunks/framework.DJJi9g99.js +17 -0
  8. package/docs/.vitepress/dist/assets/chunks/theme.CviQ0biq.js +2 -0
  9. package/docs/.vitepress/dist/assets/colors_bootstrap.md.DiC9aO06.js +1 -0
  10. package/docs/.vitepress/dist/assets/colors_bootstrap.md.DiC9aO06.lean.js +1 -0
  11. package/docs/.vitepress/dist/assets/colors_brands.md.Bp8_jfHR.js +1 -0
  12. package/docs/.vitepress/dist/assets/colors_brands.md.Bp8_jfHR.lean.js +1 -0
  13. package/docs/.vitepress/dist/assets/colors_customs.md.DyEXln8b.js +1 -0
  14. package/docs/.vitepress/dist/assets/colors_customs.md.DyEXln8b.lean.js +1 -0
  15. package/docs/.vitepress/dist/assets/functions_colors.md.CtYahXnA.js +10 -0
  16. package/docs/.vitepress/dist/assets/functions_colors.md.CtYahXnA.lean.js +10 -0
  17. package/docs/.vitepress/dist/assets/functions_helpers.md.DZRTPA4t.js +1 -0
  18. package/docs/.vitepress/dist/assets/functions_helpers.md.DZRTPA4t.lean.js +1 -0
  19. package/docs/.vitepress/dist/assets/functions_strings.md.BMMJdTdo.js +1 -0
  20. package/docs/.vitepress/dist/assets/functions_strings.md.BMMJdTdo.lean.js +1 -0
  21. package/docs/.vitepress/dist/assets/index.md.2uetSBMH.js +1 -0
  22. package/docs/.vitepress/dist/assets/index.md.2uetSBMH.lean.js +1 -0
  23. package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  24. package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  25. package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  26. package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  27. package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  28. package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  29. package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  30. package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  31. package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  32. package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  33. package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  34. package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  35. package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  36. package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  37. package/docs/.vitepress/dist/assets/mixins_build-aspect-ratio.md.8mabvpDg.js +1 -0
  38. package/docs/.vitepress/dist/assets/mixins_build-aspect-ratio.md.8mabvpDg.lean.js +1 -0
  39. package/docs/.vitepress/dist/assets/mixins_build-compatibility.md.cOIJ58bq.js +30 -0
  40. package/docs/.vitepress/dist/assets/mixins_build-compatibility.md.cOIJ58bq.lean.js +30 -0
  41. package/docs/.vitepress/dist/assets/mixins_build-scrollbar.md.DrR7vY38.js +32 -0
  42. package/docs/.vitepress/dist/assets/mixins_build-scrollbar.md.DrR7vY38.lean.js +32 -0
  43. package/docs/.vitepress/dist/assets/mixins_create-colors.md.FiVBK2v9.js +1 -0
  44. package/docs/.vitepress/dist/assets/mixins_create-colors.md.FiVBK2v9.lean.js +1 -0
  45. package/docs/.vitepress/dist/assets/mixins_create-helper-margin.md.B85aWiR9.js +46 -0
  46. package/docs/.vitepress/dist/assets/mixins_create-helper-margin.md.B85aWiR9.lean.js +46 -0
  47. package/docs/.vitepress/dist/assets/mixins_create-helper-padding.md._fxbDV5T.js +45 -0
  48. package/docs/.vitepress/dist/assets/mixins_create-helper-padding.md._fxbDV5T.lean.js +45 -0
  49. package/docs/.vitepress/dist/assets/mixins_create-instruction.md.DKI2LvdM.js +20 -0
  50. package/docs/.vitepress/dist/assets/mixins_create-instruction.md.DKI2LvdM.lean.js +20 -0
  51. package/docs/.vitepress/dist/assets/style.DDLX1Ber.css +1 -0
  52. package/docs/.vitepress/dist/colors/bootstrap.html +24 -0
  53. package/docs/.vitepress/dist/colors/brands.html +24 -0
  54. package/docs/.vitepress/dist/colors/customs.html +24 -0
  55. package/docs/.vitepress/dist/functions/colors.html +33 -0
  56. package/docs/.vitepress/dist/functions/helpers.html +24 -0
  57. package/docs/.vitepress/dist/functions/strings.html +24 -0
  58. package/docs/.vitepress/dist/hashmap.json +1 -0
  59. package/docs/.vitepress/dist/index.html +24 -0
  60. package/docs/.vitepress/dist/mixins/build-aspect-ratio.html +24 -0
  61. package/docs/.vitepress/dist/mixins/build-compatibility.html +53 -0
  62. package/docs/.vitepress/dist/mixins/build-scrollbar.html +55 -0
  63. package/docs/.vitepress/dist/mixins/create-colors.html +24 -0
  64. package/docs/.vitepress/dist/mixins/create-helper-margin.html +69 -0
  65. package/docs/.vitepress/dist/mixins/create-helper-padding.html +68 -0
  66. package/docs/.vitepress/dist/mixins/create-instruction.html +43 -0
  67. package/docs/.vitepress/theme/index.js +12 -0
  68. package/docs/colors/bootstrap.md +1 -0
  69. package/docs/colors/brands.md +1 -0
  70. package/docs/colors/customs.md +1 -0
  71. package/docs/functions/colors.md +66 -0
  72. package/docs/functions/helpers.md +1 -0
  73. package/docs/functions/strings.md +1 -0
  74. package/docs/index.md +1 -0
  75. package/docs/logo.svg +55 -0
  76. package/docs/logotype.svg +149 -0
  77. package/docs/mixins/build-aspect-ratio.md +1 -0
  78. package/docs/mixins/build-compatibility.md +23 -0
  79. package/docs/mixins/build-scrollbar.md +19 -0
  80. package/docs/mixins/create-colors.md +1 -0
  81. package/docs/mixins/create-helper-margin.md +25 -0
  82. package/docs/mixins/create-helper-padding.md +24 -0
  83. package/docs/mixins/create-instruction.md +33 -0
  84. package/package.json +6 -2
  85. package/src/colors/_bootstrap.scss +180 -0
  86. package/src/colors/_brands.scss +20 -0
  87. package/src/colors/_customs.scss +53 -0
  88. package/src/colors/_index.scss +200 -0
  89. package/src/functions/_colors.scss +118 -0
  90. package/src/functions/_helpers.scss +42 -0
  91. package/src/functions/_strings.scss +31 -0
  92. package/src/index.scss +13 -0
  93. package/src/mixins/_build-aspect-ratio.scss +37 -0
  94. package/src/mixins/_build-compatibility.scss +28 -0
  95. package/src/mixins/_build-scrollbar.scss +32 -0
  96. package/src/mixins/_create-colors.scss +119 -0
  97. package/src/mixins/_create-helper-margin.scss +39 -0
  98. package/src/mixins/_create-helper-padding.scss +40 -0
  99. package/src/mixins/_create-instructions.scss +11 -0
  100. package/test/compile.test.js +103 -0
  101. package/test/lint.test.js +50 -0
  102. package/test/test.css +5817 -0
  103. package/test/test.scss +154 -0
  104. package/vite.config.ts +26 -0
@@ -0,0 +1,118 @@
1
+ @use "sass:color";
2
+ @use "sass:math";
3
+ @use "sass: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 mix(rgba($foreground, 1), $background, opacity($foreground) * 100%);
12
+ }
13
+
14
+
15
+ /**
16
+ * Tint a color: mix a color with white
17
+ * function credited to https://getbootstrap.com/
18
+ */
19
+ @function color-tint($color, $weight) {
20
+ @return mix(white, $color, $weight);
21
+ }
22
+
23
+
24
+ /**
25
+ * Shade a color: mix a color with black
26
+ * function credited to https://getbootstrap.com/
27
+ */
28
+ @function color-shade($color, $weight) {
29
+ @return mix(black, $color, $weight);
30
+ }
31
+
32
+
33
+ /**
34
+ * Shade the color if the weight is positive, else tint it
35
+ * function credited to https://getbootstrap.com/
36
+ */
37
+ @function color-shift($color, $weight) {
38
+ @return if($weight > 0, color-shade($color, $weight), color-tint($color, -$weight));
39
+ }
40
+
41
+
42
+ /**
43
+ * Compares contrast of a given color to the light/dark arguments and returns whichever is most "contrasty"
44
+ */
45
+ @function color-contrast($color: #fff, $dark: #000, $light: #fff) {
46
+ @if type-of($color) != color or $color == transparent {
47
+ @return inherit;
48
+ }
49
+ $color-brightness: color-brightness($color);
50
+ $light-text-brightness: color-brightness($light);
51
+ $dark-text-brightness: color-brightness($dark);
52
+
53
+ @return if(abs($color-brightness - $light-text-brightness) > abs($color-brightness - $dark-text-brightness), $light, $dark);
54
+ }
55
+
56
+
57
+
58
+ // Return WCAG2.1 relative luminance
59
+ // See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
60
+ // See https://en.wikipedia.org/wiki/Relative_luminance
61
+ // Gives %, less than 50 darker is better, less than 50, lighter.
62
+ @function color-brightness($color) {
63
+ // fallback
64
+ @if $color == transparent or type-of($color) != color {
65
+ @return 100;
66
+ }
67
+ @return math.div(((red($color) * .299) + (green($color) * .587) + (blue($color) * .114)), 255 * 100%);
68
+ }
69
+
70
+ /**
71
+ * NEW numeric annotation
72
+ * Hex to RGB (only numbers, transparentize would add rgba(*))
73
+ * $color
74
+ * $alpha:
75
+ * - 0: never 4° digit
76
+ * - 1: always 4° digit
77
+ * - 2: 4° digit only when needed
78
+ * $classic: false = new number annotation
79
+ */
80
+ @function extract-colors($color: #fff, $mode: 2, $classic: false){
81
+ // colors only
82
+ @if $color == transparent or type-of($color) != color {
83
+ @return $color;
84
+ }
85
+ // new annotation
86
+ $delimiter: " ";
87
+ $delimiter-alpha: " / ";
88
+ // old annotation
89
+ @if $classic{
90
+ $delimiter: ", ";
91
+ $delimiter-alpha: ", ";
92
+ }
93
+ $alpha: alpha($color);
94
+ @if $mode == 1 or ($mode == 2 and $alpha == 1) {
95
+ @return red($color) + $delimiter + green($color) + $delimiter + blue($color);
96
+ }
97
+ // Regular RGBA compliant result ("number" notation)
98
+ @return red($color) + $delimiter + green($color) + $delimiter + blue($color) + $delimiter-alpha + alpha($color); // * 100%
99
+ }
100
+
101
+ /**
102
+ * Create default collection
103
+ */
104
+ @function create-collection($color){
105
+ $list: (
106
+ "100": color-tint($color, 80%),
107
+ "200": color-tint($color, 60%),
108
+ "300": color-tint($color, 40%),
109
+ "400": color-tint($color, 20%),
110
+ "500": $color,
111
+ "600": color-shade($color, 20%),
112
+ "700": color-shade($color, 40%),
113
+ "800": color-shade($color, 60%),
114
+ "900": color-shade($color, 80%)
115
+ );
116
+
117
+ @return $list
118
+ }
@@ -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,103 @@
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
+ // --
35
+ expect(cssCompiled).to.contain('.blue-400-text {');
36
+ expect(cssCompiled).to.contain('color: #3d8bfd !important;');
37
+ expect(cssCompiled).to.contain('.blue-400-bg {');
38
+ expect(cssCompiled).to.contain('background: #3d8bfd !important;');
39
+ // --
40
+ expect(cssCompiled).to.contain('--blue-400: 61 139 253;');
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
+ // --
62
+ expect(cssCompiled).to.contain('--color-opaque-1: #111111;');
63
+ expect(cssCompiled).to.contain('--color-opaque-2: #6f6f6f;');
64
+ // --
65
+ expect(cssCompiled).to.contain('--color-tint-1: #595959;');
66
+ expect(cssCompiled).to.contain('--color-tint-2: #e6e6e6;');
67
+ // --
68
+ expect(cssCompiled).to.contain('--color-shade-1: #1a1a1a;');
69
+ expect(cssCompiled).to.contain('--color-shade-2: #a6a6a6;');
70
+ // --
71
+ expect(cssCompiled).to.contain('--color-shift-1: #1a1a1a;');
72
+ expect(cssCompiled).to.contain('--color-shift-2: #a6a6a6;');
73
+ // --
74
+ expect(cssCompiled).to.contain('--color-contrast-1: #fff;');
75
+ expect(cssCompiled).to.contain('--color-contrast-2: #000;');
76
+ // --
77
+ expect(cssCompiled).to.contain('--color-brightness-1: #fff;');
78
+ expect(cssCompiled).to.contain('--color-brightness-2: #000;');
79
+ // --
80
+ expect(cssCompiled).to.contain('--extract-colors-1: 255 255 255;');
81
+ expect(cssCompiled).to.contain('--extract-colors-2: 34 34 34;');
82
+ expect(cssCompiled).to.contain('--extract-colors-3: 221 221 221;');
83
+ expect(cssCompiled).to.contain('--extract-colors-4: 34, 34, 34;');
84
+ expect(cssCompiled).to.contain('--extract-colors-5: 221, 221, 221;');
85
+ expect(cssCompiled).to.contain('--extract-colors-6: 0 255 0;');
86
+ expect(cssCompiled).to.contain('--extract-colors-7: 0 255 0 / 0.5;');
87
+ expect(cssCompiled).to.contain('--extract-colors-8: 0, 255, 0;');
88
+ expect(cssCompiled).to.contain('--extract-colors-9: 0, 255, 0, 0.5;');
89
+ expect(cssCompiled).to.contain('--extract-colors-10: 0 255 0;');
90
+ expect(cssCompiled).to.contain('--extract-colors-11: 0 255 0 / 0.5;');
91
+ expect(cssCompiled).to.contain('--extract-colors-12: 0, 255, 0;');
92
+ expect(cssCompiled).to.contain('--extract-colors-13: 0, 255, 0, 0.5;');
93
+ // --
94
+ expect(cssCompiled).to.contain('--no-null-1: transparent;');
95
+ expect(cssCompiled).to.contain('--no-null-2: blue;');
96
+ // --
97
+ expect(cssCompiled).to.contain('--no-trasparent-1: inherit;');
98
+ expect(cssCompiled).to.contain('--no-trasparent-2: inherit;');
99
+ expect(cssCompiled).to.contain('--no-trasparent-3: #123456;');
100
+ // --
101
+ expect(cssCompiled).to.contain('--map-deep-get: 10px;');
102
+ });
103
+ });
@@ -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
+ });