@guebbit/css-toolkit 1.2.0 → 1.2.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 (54) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +5 -5
  3. package/docs/.postcssrc.cjs +11 -11
  4. package/docs/.vitepress/config.ts +88 -88
  5. package/docs/.vitepress/dist/404.html +1 -1
  6. package/docs/.vitepress/dist/assets/{app.Cez_7bx7.js → app.BQiPqeST.js} +1 -1
  7. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.C9A3MdGo.js +1 -0
  8. package/docs/.vitepress/dist/assets/chunks/{VPLocalSearchBox.lfLgIsvm.js → VPLocalSearchBox.Bz_zRP0g.js} +1 -1
  9. package/docs/.vitepress/dist/assets/chunks/{theme.ZIndENJH.js → theme.DOuq-6g9.js} +2 -2
  10. package/docs/.vitepress/dist/colors/bootstrap.html +2 -2
  11. package/docs/.vitepress/dist/colors/brands.html +2 -2
  12. package/docs/.vitepress/dist/colors/customs.html +2 -2
  13. package/docs/.vitepress/dist/functions/colors.html +2 -2
  14. package/docs/.vitepress/dist/functions/helpers.html +2 -2
  15. package/docs/.vitepress/dist/functions/strings.html +2 -2
  16. package/docs/.vitepress/dist/index.html +2 -2
  17. package/docs/.vitepress/dist/mixins/build-aspect-ratio.html +2 -2
  18. package/docs/.vitepress/dist/mixins/build-compatibility.html +2 -2
  19. package/docs/.vitepress/dist/mixins/build-scrollbar.html +2 -2
  20. package/docs/.vitepress/dist/mixins/create-colors.html +2 -2
  21. package/docs/.vitepress/dist/mixins/create-helper-margin.html +2 -2
  22. package/docs/.vitepress/dist/mixins/create-helper-padding.html +2 -2
  23. package/docs/.vitepress/dist/mixins/create-instruction.html +2 -2
  24. package/docs/.vitepress/theme/index.js +11 -11
  25. package/docs/functions/colors.md +65 -65
  26. package/docs/logo.svg +55 -55
  27. package/docs/logotype.svg +149 -149
  28. package/docs/mixins/build-compatibility.md +22 -22
  29. package/docs/mixins/build-scrollbar.md +18 -18
  30. package/docs/mixins/create-helper-margin.md +25 -25
  31. package/docs/mixins/create-helper-padding.md +24 -24
  32. package/docs/mixins/create-instruction.md +32 -32
  33. package/package.json +61 -61
  34. package/src/colors/_bootstrap.scss +179 -179
  35. package/src/colors/_brands.scss +19 -19
  36. package/src/colors/_customs.scss +52 -52
  37. package/src/colors/_index.scss +199 -199
  38. package/src/functions/_colors.scss +133 -121
  39. package/src/functions/_helpers.scss +44 -42
  40. package/src/functions/_strings.scss +30 -30
  41. package/src/index.scss +12 -12
  42. package/src/mixins/_build-aspect-ratio.scss +36 -36
  43. package/src/mixins/_build-compatibility.scss +27 -27
  44. package/src/mixins/_build-scrollbar.scss +31 -31
  45. package/src/mixins/_create-colors.scss +118 -118
  46. package/src/mixins/_create-helper-margin.scss +38 -38
  47. package/src/mixins/_create-helper-padding.scss +40 -40
  48. package/src/mixins/_create-instructions.scss +11 -11
  49. package/test/compile.test.js +105 -105
  50. package/test/lint.test.js +48 -48
  51. package/test/test.css +104 -99
  52. package/test/test.scss +158 -158
  53. package/vite.config.ts +25 -25
  54. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.CkfJPSmi.js +0 -1
@@ -1,200 +1,200 @@
1
- @forward "brands";
2
- @forward "customs";
3
- @forward "bootstrap";
4
-
5
- @use "bootstrap" as bootstrap;
6
- @use "customs" as customs;
7
- @use "brands" as brands;
8
-
9
- $colors-collection: (
10
- // BOOTSTRAP
11
- "grey": (
12
- "100": bootstrap.$gray-100,
13
- "200": bootstrap.$gray-200,
14
- "300": bootstrap.$gray-300,
15
- "400": bootstrap.$gray-400,
16
- "500": bootstrap.$gray-500,
17
- "600": bootstrap.$gray-600,
18
- "700": bootstrap.$gray-700,
19
- "800": bootstrap.$gray-800,
20
- "900": bootstrap.$gray-900,
21
- ),
22
- "blue": (
23
- "100": bootstrap.$blue-100,
24
- "200": bootstrap.$blue-200,
25
- "300": bootstrap.$blue-300,
26
- "400": bootstrap.$blue-400,
27
- "500": bootstrap.$blue-500,
28
- "600": bootstrap.$blue-600,
29
- "700": bootstrap.$blue-700,
30
- "800": bootstrap.$blue-800,
31
- "900": bootstrap.$blue-900,
32
- ),
33
- "indigo": (
34
- "100": bootstrap.$indigo-100,
35
- "200": bootstrap.$indigo-200,
36
- "300": bootstrap.$indigo-300,
37
- "400": bootstrap.$indigo-400,
38
- "500": bootstrap.$indigo-500,
39
- "600": bootstrap.$indigo-600,
40
- "700": bootstrap.$indigo-700,
41
- "800": bootstrap.$indigo-800,
42
- "900": bootstrap.$indigo-900,
43
- ),
44
- "purple": (
45
- "100": bootstrap.$purple-100,
46
- "200": bootstrap.$purple-200,
47
- "300": bootstrap.$purple-300,
48
- "400": bootstrap.$purple-400,
49
- "500": bootstrap.$purple-500,
50
- "600": bootstrap.$purple-600,
51
- "700": bootstrap.$purple-700,
52
- "800": bootstrap.$purple-800,
53
- "900": bootstrap.$purple-900,
54
- ),
55
- "pink": (
56
- "100": bootstrap.$pink-100,
57
- "200": bootstrap.$pink-200,
58
- "300": bootstrap.$pink-300,
59
- "400": bootstrap.$pink-400,
60
- "500": bootstrap.$pink-500,
61
- "600": bootstrap.$pink-600,
62
- "700": bootstrap.$pink-700,
63
- "800": bootstrap.$pink-800,
64
- "900": bootstrap.$pink-900,
65
- ),
66
- "red": (
67
- "100": bootstrap.$red-100,
68
- "200": bootstrap.$red-200,
69
- "300": bootstrap.$red-300,
70
- "400": bootstrap.$red-400,
71
- "500": bootstrap.$red-500,
72
- "600": bootstrap.$red-600,
73
- "700": bootstrap.$red-700,
74
- "800": bootstrap.$red-800,
75
- "900": bootstrap.$red-900,
76
- ),
77
- "orange": (
78
- "100": bootstrap.$orange-100,
79
- "200": bootstrap.$orange-200,
80
- "300": bootstrap.$orange-300,
81
- "400": bootstrap.$orange-400,
82
- "500": bootstrap.$orange-500,
83
- "600": bootstrap.$orange-600,
84
- "700": bootstrap.$orange-700,
85
- "800": bootstrap.$orange-800,
86
- "900": bootstrap.$orange-900,
87
- ),
88
- "yellow": (
89
- "100": bootstrap.$yellow-100,
90
- "200": bootstrap.$yellow-200,
91
- "300": bootstrap.$yellow-300,
92
- "400": bootstrap.$yellow-400,
93
- "500": bootstrap.$yellow-500,
94
- "600": bootstrap.$yellow-600,
95
- "700": bootstrap.$yellow-700,
96
- "800": bootstrap.$yellow-800,
97
- "900": bootstrap.$yellow-900,
98
- ),
99
- "green": (
100
- "100": bootstrap.$green-100,
101
- "200": bootstrap.$green-200,
102
- "300": bootstrap.$green-300,
103
- "400": bootstrap.$green-400,
104
- "500": bootstrap.$green,
105
- "600": bootstrap.$green-500,
106
- "700": bootstrap.$green-600,
107
- "800": bootstrap.$green-700,
108
- "900": bootstrap.$green-800,
109
- ),
110
- "teal": (
111
- "100": bootstrap.$teal-100,
112
- "200": bootstrap.$teal-200,
113
- "300": bootstrap.$teal-300,
114
- "400": bootstrap.$teal-400,
115
- "500": bootstrap.$teal-500,
116
- "600": bootstrap.$teal-600,
117
- "700": bootstrap.$teal-700,
118
- "800": bootstrap.$teal-800,
119
- "900": bootstrap.$teal-900,
120
- ),
121
- "cyan": (
122
- "100": bootstrap.$cyan-100,
123
- "200": bootstrap.$cyan-200,
124
- "300": bootstrap.$cyan-300,
125
- "400": bootstrap.$cyan-400,
126
- "500": bootstrap.$cyan-500,
127
- "600": bootstrap.$cyan-600,
128
- "700": bootstrap.$cyan-700,
129
- "800": bootstrap.$cyan-800,
130
- "900": bootstrap.$cyan-900,
131
- ),
132
- // CUSTOM
133
- "flatrica-green": (
134
- "100": customs.$flatrica-green-100,
135
- "200": customs.$flatrica-green-200,
136
- "300": customs.$flatrica-green-300,
137
- "400": customs.$flatrica-green-400,
138
- "500": customs.$flatrica-green-500,
139
- "600": customs.$flatrica-green-600,
140
- "700": customs.$flatrica-green-700,
141
- "800": customs.$flatrica-green-800,
142
- "900": customs.$flatrica-green-900,
143
- ),
144
- "manga-red": (
145
- "100": customs.$manga-red-100,
146
- "200": customs.$manga-red-200,
147
- "300": customs.$manga-red-300,
148
- "400": customs.$manga-red-400,
149
- "500": customs.$manga-red-500,
150
- "600": customs.$manga-red-600,
151
- "700": customs.$manga-red-700,
152
- "800": customs.$manga-red-800,
153
- "900": customs.$manga-red-900,
154
- ),
155
- // BRANDS
156
- "brand": (
157
- "facebook": brands.$brand-facebook,
158
- "youtube": brands.$brand-youtube,
159
- "twitter": brands.$brand-twitter,
160
- "skype": brands.$brand-skype,
161
- "linkedin": brands.$brand-linkedin,
162
- "whatsapp": brands.$brand-whatsapp,
163
- "telegram": brands.$brand-telegram,
164
- "twitch": brands.$brand-twitch,
165
- "pinterest": brands.$brand-pinterest,
166
- "reddit": brands.$brand-reddit,
167
- "tumblr": brands.$brand-tumblr,
168
- "patreon": brands.$brand-patreon,
169
- "kickstarter":brands.$brand-kickstarter,
170
- "instagram": brands.$brand-instagram,
171
- "tiktok": brands.$brand-tiktok,
172
- "google": brands.$brand-google,
173
- "paypal": brands.$brand-paypal,
174
- "paypal2": brands.$brand-paypal2,
175
- ),
176
- // CORE
177
- "core": (
178
- "blue": bootstrap.$blue,
179
- "indigo": bootstrap.$indigo,
180
- "purple": bootstrap.$purple,
181
- "pink": bootstrap.$pink,
182
- "red": bootstrap.$red,
183
- "orange": bootstrap.$orange,
184
- "yellow": bootstrap.$yellow,
185
- "green": bootstrap.$green,
186
- "teal": bootstrap.$teal,
187
- "cyan": bootstrap.$cyan,
188
- "black": bootstrap.$black,
189
- "white": bootstrap.$white,
190
- "gray": bootstrap.$gray-500,
191
- "gray-dark": bootstrap.$gray-900,
192
- "flatrica-green": customs.$flatrica-green,
193
- "manga-red": customs.$manga-red,
194
- ),
195
- // ADVANCED
196
- "advanced": (
197
- "brand-instagram": brands.$advanced-brand-instagram,
198
- "brand-tiktok": brands.$advanced-brand-tiktok,
199
- ),
1
+ @forward "brands";
2
+ @forward "customs";
3
+ @forward "bootstrap";
4
+
5
+ @use "bootstrap" as bootstrap;
6
+ @use "customs" as customs;
7
+ @use "brands" as brands;
8
+
9
+ $colors-collection: (
10
+ // BOOTSTRAP
11
+ "grey": (
12
+ "100": bootstrap.$gray-100,
13
+ "200": bootstrap.$gray-200,
14
+ "300": bootstrap.$gray-300,
15
+ "400": bootstrap.$gray-400,
16
+ "500": bootstrap.$gray-500,
17
+ "600": bootstrap.$gray-600,
18
+ "700": bootstrap.$gray-700,
19
+ "800": bootstrap.$gray-800,
20
+ "900": bootstrap.$gray-900,
21
+ ),
22
+ "blue": (
23
+ "100": bootstrap.$blue-100,
24
+ "200": bootstrap.$blue-200,
25
+ "300": bootstrap.$blue-300,
26
+ "400": bootstrap.$blue-400,
27
+ "500": bootstrap.$blue-500,
28
+ "600": bootstrap.$blue-600,
29
+ "700": bootstrap.$blue-700,
30
+ "800": bootstrap.$blue-800,
31
+ "900": bootstrap.$blue-900,
32
+ ),
33
+ "indigo": (
34
+ "100": bootstrap.$indigo-100,
35
+ "200": bootstrap.$indigo-200,
36
+ "300": bootstrap.$indigo-300,
37
+ "400": bootstrap.$indigo-400,
38
+ "500": bootstrap.$indigo-500,
39
+ "600": bootstrap.$indigo-600,
40
+ "700": bootstrap.$indigo-700,
41
+ "800": bootstrap.$indigo-800,
42
+ "900": bootstrap.$indigo-900,
43
+ ),
44
+ "purple": (
45
+ "100": bootstrap.$purple-100,
46
+ "200": bootstrap.$purple-200,
47
+ "300": bootstrap.$purple-300,
48
+ "400": bootstrap.$purple-400,
49
+ "500": bootstrap.$purple-500,
50
+ "600": bootstrap.$purple-600,
51
+ "700": bootstrap.$purple-700,
52
+ "800": bootstrap.$purple-800,
53
+ "900": bootstrap.$purple-900,
54
+ ),
55
+ "pink": (
56
+ "100": bootstrap.$pink-100,
57
+ "200": bootstrap.$pink-200,
58
+ "300": bootstrap.$pink-300,
59
+ "400": bootstrap.$pink-400,
60
+ "500": bootstrap.$pink-500,
61
+ "600": bootstrap.$pink-600,
62
+ "700": bootstrap.$pink-700,
63
+ "800": bootstrap.$pink-800,
64
+ "900": bootstrap.$pink-900,
65
+ ),
66
+ "red": (
67
+ "100": bootstrap.$red-100,
68
+ "200": bootstrap.$red-200,
69
+ "300": bootstrap.$red-300,
70
+ "400": bootstrap.$red-400,
71
+ "500": bootstrap.$red-500,
72
+ "600": bootstrap.$red-600,
73
+ "700": bootstrap.$red-700,
74
+ "800": bootstrap.$red-800,
75
+ "900": bootstrap.$red-900,
76
+ ),
77
+ "orange": (
78
+ "100": bootstrap.$orange-100,
79
+ "200": bootstrap.$orange-200,
80
+ "300": bootstrap.$orange-300,
81
+ "400": bootstrap.$orange-400,
82
+ "500": bootstrap.$orange-500,
83
+ "600": bootstrap.$orange-600,
84
+ "700": bootstrap.$orange-700,
85
+ "800": bootstrap.$orange-800,
86
+ "900": bootstrap.$orange-900,
87
+ ),
88
+ "yellow": (
89
+ "100": bootstrap.$yellow-100,
90
+ "200": bootstrap.$yellow-200,
91
+ "300": bootstrap.$yellow-300,
92
+ "400": bootstrap.$yellow-400,
93
+ "500": bootstrap.$yellow-500,
94
+ "600": bootstrap.$yellow-600,
95
+ "700": bootstrap.$yellow-700,
96
+ "800": bootstrap.$yellow-800,
97
+ "900": bootstrap.$yellow-900,
98
+ ),
99
+ "green": (
100
+ "100": bootstrap.$green-100,
101
+ "200": bootstrap.$green-200,
102
+ "300": bootstrap.$green-300,
103
+ "400": bootstrap.$green-400,
104
+ "500": bootstrap.$green,
105
+ "600": bootstrap.$green-500,
106
+ "700": bootstrap.$green-600,
107
+ "800": bootstrap.$green-700,
108
+ "900": bootstrap.$green-800,
109
+ ),
110
+ "teal": (
111
+ "100": bootstrap.$teal-100,
112
+ "200": bootstrap.$teal-200,
113
+ "300": bootstrap.$teal-300,
114
+ "400": bootstrap.$teal-400,
115
+ "500": bootstrap.$teal-500,
116
+ "600": bootstrap.$teal-600,
117
+ "700": bootstrap.$teal-700,
118
+ "800": bootstrap.$teal-800,
119
+ "900": bootstrap.$teal-900,
120
+ ),
121
+ "cyan": (
122
+ "100": bootstrap.$cyan-100,
123
+ "200": bootstrap.$cyan-200,
124
+ "300": bootstrap.$cyan-300,
125
+ "400": bootstrap.$cyan-400,
126
+ "500": bootstrap.$cyan-500,
127
+ "600": bootstrap.$cyan-600,
128
+ "700": bootstrap.$cyan-700,
129
+ "800": bootstrap.$cyan-800,
130
+ "900": bootstrap.$cyan-900,
131
+ ),
132
+ // CUSTOM
133
+ "flatrica-green": (
134
+ "100": customs.$flatrica-green-100,
135
+ "200": customs.$flatrica-green-200,
136
+ "300": customs.$flatrica-green-300,
137
+ "400": customs.$flatrica-green-400,
138
+ "500": customs.$flatrica-green-500,
139
+ "600": customs.$flatrica-green-600,
140
+ "700": customs.$flatrica-green-700,
141
+ "800": customs.$flatrica-green-800,
142
+ "900": customs.$flatrica-green-900,
143
+ ),
144
+ "manga-red": (
145
+ "100": customs.$manga-red-100,
146
+ "200": customs.$manga-red-200,
147
+ "300": customs.$manga-red-300,
148
+ "400": customs.$manga-red-400,
149
+ "500": customs.$manga-red-500,
150
+ "600": customs.$manga-red-600,
151
+ "700": customs.$manga-red-700,
152
+ "800": customs.$manga-red-800,
153
+ "900": customs.$manga-red-900,
154
+ ),
155
+ // BRANDS
156
+ "brand": (
157
+ "facebook": brands.$brand-facebook,
158
+ "youtube": brands.$brand-youtube,
159
+ "twitter": brands.$brand-twitter,
160
+ "skype": brands.$brand-skype,
161
+ "linkedin": brands.$brand-linkedin,
162
+ "whatsapp": brands.$brand-whatsapp,
163
+ "telegram": brands.$brand-telegram,
164
+ "twitch": brands.$brand-twitch,
165
+ "pinterest": brands.$brand-pinterest,
166
+ "reddit": brands.$brand-reddit,
167
+ "tumblr": brands.$brand-tumblr,
168
+ "patreon": brands.$brand-patreon,
169
+ "kickstarter":brands.$brand-kickstarter,
170
+ "instagram": brands.$brand-instagram,
171
+ "tiktok": brands.$brand-tiktok,
172
+ "google": brands.$brand-google,
173
+ "paypal": brands.$brand-paypal,
174
+ "paypal2": brands.$brand-paypal2,
175
+ ),
176
+ // CORE
177
+ "core": (
178
+ "blue": bootstrap.$blue,
179
+ "indigo": bootstrap.$indigo,
180
+ "purple": bootstrap.$purple,
181
+ "pink": bootstrap.$pink,
182
+ "red": bootstrap.$red,
183
+ "orange": bootstrap.$orange,
184
+ "yellow": bootstrap.$yellow,
185
+ "green": bootstrap.$green,
186
+ "teal": bootstrap.$teal,
187
+ "cyan": bootstrap.$cyan,
188
+ "black": bootstrap.$black,
189
+ "white": bootstrap.$white,
190
+ "gray": bootstrap.$gray-500,
191
+ "gray-dark": bootstrap.$gray-900,
192
+ "flatrica-green": customs.$flatrica-green,
193
+ "manga-red": customs.$manga-red,
194
+ ),
195
+ // ADVANCED
196
+ "advanced": (
197
+ "brand-instagram": brands.$advanced-brand-instagram,
198
+ "brand-tiktok": brands.$advanced-brand-tiktok,
199
+ ),
200
200
  );
@@ -1,122 +1,134 @@
1
- @use "sass:color";
2
- @use "sass:math";
3
- @use "sass:string";
4
- @use "sass:meta";
5
-
6
- /**
7
- * Return opaque color
8
- * color-opaque(#fff, rgba(0, 0, 0, .5)) => #808080
9
- * function credited to https://getbootstrap.com/
10
- */
11
- @function color-opaque($background, $foreground) {
12
- @return mix(rgba($foreground, 1), $background, opacity($foreground) * 100%);
13
- }
14
-
15
-
16
- /**
17
- * Tint a color: mix a color with white
18
- * function credited to https://getbootstrap.com/
19
- */
20
- @function color-tint($color, $weight) {
21
- @return mix(#fff, $color, $weight);
22
- }
23
-
24
-
25
- /**
26
- * Shade a color: mix a color with black
27
- * function credited to https://getbootstrap.com/
28
- */
29
- @function color-shade($color, $weight) {
30
- @return mix(#000, $color, $weight);
31
- }
32
-
33
-
34
- /**
35
- * Shade the color if the weight is positive, else tint it
36
- * function credited to https://getbootstrap.com/
37
- */
38
- @function color-shift($color, $weight) {
39
- @return if($weight > 0,
40
- color-shade($color, $weight),
41
- color-tint($color, -$weight)
42
- );
43
- }
44
-
45
-
46
- /**
47
- * Compares contrast of a given color to the light/dark arguments and returns whichever is most "contrasty"
48
- */
49
- @function color-contrast($color: #fff, $dark: #000, $light: #fff) {
50
- @if meta.type-of($color) != color or $color == transparent {
51
- @return inherit;
52
- }
53
- $color-brightness: color-brightness($color);
54
- $light-text-brightness: color-brightness($light);
55
- $dark-text-brightness: color-brightness($dark);
56
-
57
- @return if(abs($color-brightness - $light-text-brightness) > abs($color-brightness - $dark-text-brightness), $light, $dark);
58
- }
59
-
60
-
61
-
62
- // Return WCAG2.1 relative luminance
63
- // See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
64
- // See https://en.wikipedia.org/wiki/Relative_luminance
65
- // Gives %, less than 50 darker is better, less than 50, lighter.
66
- @function color-brightness($color) {
67
- // fallback
68
- @if $color == transparent or meta.type-of($color) != color {
69
- @return 100;
70
- }
71
- @return math.div(((red($color) * .299) + (green($color) * .587) + (blue($color) * .114)), 255 * 100%);
72
- }
73
-
74
- /**
75
- * NEW numeric annotation
76
- * Hex to RGB (only numbers, transparentize would add rgba(*))
77
- * $color
78
- * $alpha:
79
- * - 0: never 4° digit
80
- * - 1: always 4° digit
81
- * - 2: 4° digit only when needed
82
- * $classic: false = new number annotation
83
- */
84
- @function extract-colors($color: #fff, $mode: 2, $classic: false){
85
- // colors only
86
- @if $color == transparent or meta.type-of($color) != color {
87
- @return $color;
88
- }
89
- // new annotation
90
- $delimiter: " ";
91
- $delimiter-alpha: " / ";
92
- // old annotation
93
- @if $classic{
94
- $delimiter: ", ";
95
- $delimiter-alpha: ", ";
96
- }
97
- $alpha: alpha($color);
98
- @if $mode == 1 or ($mode == 2 and $alpha == 1) {
99
- @return red($color) + $delimiter + green($color) + $delimiter + blue($color);
100
- }
101
- // Regular RGBA compliant result ("number" notation)
102
- @return red($color) + $delimiter + green($color) + $delimiter + blue($color) + $delimiter-alpha + alpha($color); // * 100%
103
- }
104
-
105
- /**
106
- * Create default collection
107
- */
108
- @function create-collection($color){
109
- $list: (
110
- "100": color-tint($color, 80%),
111
- "200": color-tint($color, 60%),
112
- "300": color-tint($color, 40%),
113
- "400": color-tint($color, 20%),
114
- "500": $color,
115
- "600": color-shade($color, 20%),
116
- "700": color-shade($color, 40%),
117
- "800": color-shade($color, 60%),
118
- "900": color-shade($color, 80%)
119
- );
120
-
121
- @return $list
1
+ @use "sass:color" as color;
2
+ @use "sass:math" as math;
3
+ @use "sass:meta" as meta;
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, color.opacity($foreground) * 100%);
12
+ }
13
+
14
+ /**
15
+ * Tint a color
16
+ */
17
+ @function color-tint($color, $weight) {
18
+ // Creates a physical mixture with white color
19
+ @return color.mix(#fff, $color, $weight);
20
+ // Adjusts properties (like lightness) relative to the color's current values.
21
+ // @return color.scale($color, $lightness: $weight);
22
+ }
23
+
24
+
25
+ /**
26
+ * Shade a color
27
+ */
28
+ @function color-shade($color, $weight) {
29
+ @return color.mix(#000, $color, $weight);
30
+ // @return color.scale($color, $lightness: -$weight);
31
+ }
32
+
33
+
34
+ /**
35
+ * Shade the color if the weight is positive, else tint it
36
+ * function credited to https://getbootstrap.com/
37
+ */
38
+ @function color-shift($color, $weight) {
39
+ @return if($weight > 0,
40
+ color-shade($color, $weight),
41
+ color-tint($color, -$weight)
42
+ );
43
+ }
44
+
45
+
46
+ /**
47
+ * Return WCAG2.1 relative luminance
48
+ * See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
49
+ * See https://en.wikipedia.org/wiki/Relative_luminance
50
+ * Gives %, less than 50 darker is better, less than 50, lighter.
51
+ * Function like color.channel($color, "lightness", $space: hsl) gives a different %
52
+ */
53
+ @function color-luminance($color) {
54
+ // fallback
55
+ @if $color == transparent or meta.type-of($color) != color {
56
+ @return 100;
57
+ }
58
+ @return math.div((
59
+ (color.channel($color, "red", $space: rgb) * .299) +
60
+ (color.channel($color, "green", $space: rgb) * .587) +
61
+ (color.channel($color, "blue", $space: rgb) * .114)
62
+ ), 255) * 100%;
63
+ }
64
+
65
+
66
+ /**
67
+ * Compares contrast of a given color to the light/dark arguments and returns whichever is most "contrasty"
68
+ */
69
+ @function color-contrast($color: #fff, $dark: #000, $light: #fff) {
70
+ @if meta.type-of($color) != color or $color == transparent {
71
+ @return inherit;
72
+ }
73
+ $color-brightness: color-luminance($color);
74
+ $light-text-brightness: color-luminance($light);
75
+ $dark-text-brightness: color-luminance($dark);
76
+
77
+ @return if(math.abs($color-brightness - $light-text-brightness) > math.abs($color-brightness - $dark-text-brightness), $light, $dark);
78
+ }
79
+
80
+
81
+ /**
82
+ * NEW numeric annotation
83
+ * Hex to RGB (only numbers, transparentize would add rgba(*))
84
+ * $color
85
+ * $alpha:
86
+ * - 0: never digit
87
+ * - 1: always 4° digit
88
+ * - 2: 4° digit only when needed
89
+ * $classic: false = new number annotation
90
+ */
91
+ @function extract-colors($color: #fff, $mode: 2, $classic: false){
92
+ // colors only
93
+ @if $color == transparent or meta.type-of($color) != color {
94
+ @return $color;
95
+ }
96
+ // new annotation
97
+ $delimiter: " ";
98
+ $delimiter-alpha: " / ";
99
+ // old annotation
100
+ @if $classic{
101
+ $delimiter: ", ";
102
+ $delimiter-alpha: ", ";
103
+ }
104
+ $alpha: color.alpha($color);
105
+ @if $mode == 1 or ($mode == 2 and $alpha == 1) {
106
+ @return color.channel($color, "red", $space: rgb) +
107
+ $delimiter + color.channel($color, "green", $space: rgb) +
108
+ $delimiter + color.channel($color, "blue", $space: rgb);
109
+ }
110
+ // Regular RGBA compliant result ("number" notation)
111
+ @return color.channel($color, "red", $space: rgb) +
112
+ $delimiter + color.channel($color, "green", $space: rgb) +
113
+ $delimiter + color.channel($color, "blue", $space: rgb) +
114
+ $delimiter-alpha + color.channel($color, "alpha"); // * 100%
115
+ }
116
+
117
+ /**
118
+ * Create default collection
119
+ */
120
+ @function create-collection($color) {
121
+ $list: (
122
+ "100": color-tint($color, 80%),
123
+ "200": color-tint($color, 60%),
124
+ "300": color-tint($color, 40%),
125
+ "400": color-tint($color, 20%),
126
+ "500": $color,
127
+ "600": color-shade($color, 20%),
128
+ "700": color-shade($color, 40%),
129
+ "800": color-shade($color, 60%),
130
+ "900": color-shade($color, 80%)
131
+ );
132
+
133
+ @return $list
122
134
  }