beathers 5.0.0
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/dist/css/beathers-icons.min.css +1 -0
- package/dist/css/beathers-icons.min.css.map +1 -0
- package/dist/css/beathers.min.css +4 -0
- package/dist/css/beathers.min.css.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/scripts/BuildScssVariables.d.ts +2 -0
- package/dist/scripts/BuildScssVariables.js +111 -0
- package/dist/scripts/BuildTheme.d.ts +1 -0
- package/dist/scripts/BuildTheme.js +99 -0
- package/dist/scripts/CallNewVariables.d.ts +1 -0
- package/dist/scripts/CallNewVariables.js +17 -0
- package/dist/scripts/LoadUserConfigs.d.ts +2 -0
- package/dist/scripts/LoadUserConfigs.js +42 -0
- package/dist/scripts/Merge.d.ts +2 -0
- package/dist/scripts/Merge.js +26 -0
- package/dist/scripts/ReadDefaultValues.d.ts +2 -0
- package/dist/scripts/ReadDefaultValues.js +168 -0
- package/dist/scripts/cli.d.ts +2 -0
- package/dist/scripts/cli.js +14 -0
- package/dist/scripts/types.d.ts +57 -0
- package/dist/scripts/types.js +1 -0
- package/package.json +84 -0
- package/readme.md +235 -0
- package/src/scss/_variables.scss +305 -0
- package/src/scss/beathers-icons.min.scss +265 -0
- package/src/scss/beathers.min.scss +13 -0
- package/src/scss/functions/_colors.scss +232 -0
- package/src/scss/functions/_mediaQueries.scss +128 -0
- package/src/scss/functions/_others.scss +83 -0
- package/src/scss/functions/_typographic.scss +125 -0
- package/src/scss/functions/_validations.scss +256 -0
- package/src/scss/settings/_configs.scss +366 -0
- package/src/scss/settings/_defaults.scss +251 -0
- package/src/scss/settings/_index.scss +68 -0
- package/src/scss/settings/_resets.scss +103 -0
- package/src/scss/style/_colors.scss +139 -0
- package/src/scss/style/_grid.scss +92 -0
- package/src/scss/style/_shaping.scss +372 -0
- package/src/scss/style/_typographic.scss +304 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "../settings/configs" as configs;
|
|
3
|
+
@use "../functions/validations" as val;
|
|
4
|
+
|
|
5
|
+
// @function shadowValue
|
|
6
|
+
// @description Converts a unitless number to a pixel value for shadows, unless the value is 0.
|
|
7
|
+
// @param {Number} $value - The shadow value.
|
|
8
|
+
// @return {String} The shadow value with "px" appended, or 0.
|
|
9
|
+
@function shadowValue($value) {
|
|
10
|
+
@return if($value != 0, #{$value}#{"px"}, $value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @mixin gridDivision
|
|
14
|
+
// @description Generates CSS grid classes for creating grid layouts.
|
|
15
|
+
// @param {String} $axis - The grid axis ('column' or 'row').
|
|
16
|
+
// @param {String | Null} $size - A size prefix for the generated classes (e.g., 'sm', 'md').
|
|
17
|
+
// @param {String} $divider - A divider string for the generated classes (e.g., '-').
|
|
18
|
+
@mixin gridDivision($axis, $size, $divider) {
|
|
19
|
+
// Validate parameters
|
|
20
|
+
$checkedAxis: val.listItem((column, row), $axis, "gridDivision.axis");
|
|
21
|
+
$checkedBase: val.number(configs.$axisDivisions, "gridDivision.axisDivisions");
|
|
22
|
+
|
|
23
|
+
$type: if($axis == "column", "col", "row");
|
|
24
|
+
$mainClass: if($size, "#{$size}#{$divider}#{$type}s", "#{$type}s");
|
|
25
|
+
$subClass: if($size, "#{$size}#{$divider}#{$type}", $type);
|
|
26
|
+
|
|
27
|
+
@for $i from 0 through configs.$axisDivisions {
|
|
28
|
+
@if ($i > 0) {
|
|
29
|
+
&.#{$mainClass}#{\:}#{$i} {
|
|
30
|
+
grid-template-#{$axis}s: repeat($i, 1fr);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$axisProperty: if($i == 0, "grid-#{$axis}-end", "grid-#{$axis}");
|
|
35
|
+
$class: if($i == 0, auto, $i);
|
|
36
|
+
$value: if($i == 0, -1, "span #{$i}");
|
|
37
|
+
|
|
38
|
+
> .#{$subClass}#{\:}#{$class} {
|
|
39
|
+
#{$axisProperty}: #{$value};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// @mixin flexDivision
|
|
45
|
+
// @description Generates CSS flexbox classes for creating flexible layouts.
|
|
46
|
+
// @param {String} $axis - The flex axis ('width' or 'height').
|
|
47
|
+
// @param {String} $type - The type of flex items ('col', 'cols', 'row', 'rows').
|
|
48
|
+
// @param {String | Null} $size - A size prefix for the generated classes (e.g., 'sm', 'md').
|
|
49
|
+
// @param {String} $divider - A divider string for the generated classes (e.g., '-').
|
|
50
|
+
@mixin flexDivision($axis, $type, $size, $divider) {
|
|
51
|
+
// Validate parameters
|
|
52
|
+
$checkedAxis: val.listItem((width, height), $axis, "flexDivision.axis");
|
|
53
|
+
$checkedType: val.listItem(("col", "cols", "rows", "row"), $type, "flexDivision.type");
|
|
54
|
+
$checkedBase: val.number(configs.$axisDivisions, "flexDivision.axisDivisions");
|
|
55
|
+
|
|
56
|
+
$mainClass: if($size, "#{$size}#{$divider}#{$type}", $type);
|
|
57
|
+
|
|
58
|
+
@if (not $size) and $type == "cols" or $type == "rows" {
|
|
59
|
+
> * {
|
|
60
|
+
flex: 0 0 auto;
|
|
61
|
+
max-#{$axis}: 100%;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@for $i from 0 through configs.$axisDivisions {
|
|
66
|
+
@if $type == "cols" or $type == "rows" {
|
|
67
|
+
$class: if($i == 0, auto, $i);
|
|
68
|
+
$axisSize: if($i == 0, auto, calc(100% / $i));
|
|
69
|
+
|
|
70
|
+
&.#{$mainClass}#{\:}#{$class} > * {
|
|
71
|
+
#{$axis}: if($size, $axisSize !important, $axisSize);
|
|
72
|
+
}
|
|
73
|
+
} @else if $type == "col" or $type == "row" {
|
|
74
|
+
$axisSize: if($i == 0, 100%, calc(($i / configs.$axisDivisions) * 100%));
|
|
75
|
+
$class: if($i == 0, "", $i);
|
|
76
|
+
$classSize: if($i == 0, #{$class}, #{\:}#{$class});
|
|
77
|
+
|
|
78
|
+
> .#{$mainClass}#{$classSize} {
|
|
79
|
+
#{$axis}: if($size, $axisSize !important, $axisSize);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
@use 'sass:string';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use '../settings/defaults' as vars;
|
|
4
|
+
@use '../functions/validations' as val;
|
|
5
|
+
@use '../settings/configs' as configs;
|
|
6
|
+
|
|
7
|
+
// Font Face Mixin
|
|
8
|
+
// --------------------------------------
|
|
9
|
+
// Generates an @font-face rule.
|
|
10
|
+
//
|
|
11
|
+
// @param {String} $title - The base name of the font (e.g., "OpenSans").
|
|
12
|
+
// @param {String} $weight - The font weight key (e.g., "regular", "bold").
|
|
13
|
+
// @param {String} $format - The font file format (e.g., "woff2").
|
|
14
|
+
// @param {String} $style - The font style (e.g., "normal", "italic").
|
|
15
|
+
// @param {Number} $index [0] - An index appended to the font-family name if multiple fonts share the same weight name.
|
|
16
|
+
// @param {String | Null} $unicode [null] - Optional unicode range for the font.
|
|
17
|
+
// @param {Boolean} $isLocal [true] - Whether the font is hosted locally or externally.
|
|
18
|
+
// @param {String} $externalUrl [""] - The URL for externally hosted fonts (if $isLocal is false).
|
|
19
|
+
//
|
|
20
|
+
// @example scss
|
|
21
|
+
// @include font("OpenSans", "regular", "woff2", "normal", 0, null, true);
|
|
22
|
+
// // Generates:
|
|
23
|
+
// // @font-face {
|
|
24
|
+
// // font-family: "regular"; // Or "regular-0" if $index is 0 but other fonts exist with same weight
|
|
25
|
+
// // font-weight: 400;
|
|
26
|
+
// // font-style: normal;
|
|
27
|
+
// // font-display: swap;
|
|
28
|
+
// // src: local("OpenSans-regular"),
|
|
29
|
+
// // url("../fonts/OpenSans-regular.woff2") format("woff2");
|
|
30
|
+
// // }
|
|
31
|
+
//
|
|
32
|
+
// @include font("Roboto", "bold", "ttf", "normal", 1, "U+000-5FF", false, "https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmWUlfBBc4.ttf");
|
|
33
|
+
// // Generates:
|
|
34
|
+
// // @font-face {
|
|
35
|
+
// // font-family: "bold-1";
|
|
36
|
+
// // font-weight: 700;
|
|
37
|
+
// // font-style: normal;
|
|
38
|
+
// // font-display: swap;
|
|
39
|
+
// // src: url("https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmWUlfBBc4.ttf");
|
|
40
|
+
// // unicode-range: U+000-5FF;
|
|
41
|
+
// // }
|
|
42
|
+
//
|
|
43
|
+
@mixin font($title, $weight, $format, $style, $index: 0, $unicode: null, $isLocal: true, $externalUrl: '') {
|
|
44
|
+
// Validate parameters
|
|
45
|
+
$checkedIsLocal: val.boolean($isLocal, '#{$title}.font().local');
|
|
46
|
+
$checkedTitle: val.string($title, '#{$title}.font().title');
|
|
47
|
+
$checkedWeight: val.mapItem(
|
|
48
|
+
configs.$fontWeightsValues,
|
|
49
|
+
$weight,
|
|
50
|
+
configs.$fontWeightsValues,
|
|
51
|
+
'Typographic.fontFace.weights.#{$weight}'
|
|
52
|
+
);
|
|
53
|
+
$checkedStyle: val.listItem(('normal', 'italic', 'oblique'), $style, '#{$title}.font().weights.#{$style}');
|
|
54
|
+
$checkIndex: val.number($index, '#{$title}.font().index');
|
|
55
|
+
$checkedFormat: val.string($format, '#{$title}.font().format');
|
|
56
|
+
|
|
57
|
+
@if (not($isLocal)) {
|
|
58
|
+
$checkedExternalUrl: val.string($externalUrl, 'Typographic.fontFace.externalUrl');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
$name: if($index == 0, $title, '#{$title}-#{$index}');
|
|
62
|
+
$weightValue: map.get(configs.$fontWeightsValues, $weight);
|
|
63
|
+
|
|
64
|
+
@font-face {
|
|
65
|
+
font-family: $name;
|
|
66
|
+
font-weight: $weightValue;
|
|
67
|
+
font-style: $style;
|
|
68
|
+
font-display: swap;
|
|
69
|
+
|
|
70
|
+
@if ($isLocal) {
|
|
71
|
+
src:
|
|
72
|
+
local('#{$title}-#{$weight}'),
|
|
73
|
+
url(string.unquote('#{vars.$fontMainPath}#{$title}-#{$weight}.#{$format}')) format('#{$format}');
|
|
74
|
+
} @else {
|
|
75
|
+
src: url(string.unquote('#{$externalUrl}'));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@if $unicode {
|
|
79
|
+
// Validate parameters
|
|
80
|
+
$checkedUnicode: val.string($unicode, '#{$title}.font().unicode');
|
|
81
|
+
|
|
82
|
+
unicode-range: string.unquote($unicode);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Font Shapes Mixin
|
|
88
|
+
// --------------------------------------
|
|
89
|
+
// Applies text transformation, decoration, or style properties to a class.
|
|
90
|
+
//
|
|
91
|
+
// @param {String} $class - The CSS class name to apply the style to.
|
|
92
|
+
// @param {String} $type - The type of shape property ("transform", "decoration", "styles").
|
|
93
|
+
// @param {String} $value - The value for the shape property (e.g., "uppercase", "underline", "italic").
|
|
94
|
+
// @param {String | Null} $size [null] - Optional size prefix for responsive classes, determines if `!important` is added.
|
|
95
|
+
//
|
|
96
|
+
// @example scss
|
|
97
|
+
// @include fontShapes("uppercase", "transform", "uppercase");
|
|
98
|
+
// // Generates:
|
|
99
|
+
// // .uppercase {
|
|
100
|
+
// // text-transform: uppercase;
|
|
101
|
+
// // }
|
|
102
|
+
//
|
|
103
|
+
// @include fontShapes("md:underline", "decoration", "underline", "md");
|
|
104
|
+
// // Generates:
|
|
105
|
+
// // .md\\:underline {
|
|
106
|
+
// // text-decoration: underline !important;
|
|
107
|
+
// // }
|
|
108
|
+
//
|
|
109
|
+
@mixin fontShapes($class, $type, $value) {
|
|
110
|
+
$shapeList: map.get(configs.$fontShapes, $type);
|
|
111
|
+
|
|
112
|
+
// Validate parameters
|
|
113
|
+
$checkedType: val.mapItem(configs.$fontShapes, $type, configs.$fontShapes, 'fontShapes().#{$type}');
|
|
114
|
+
$checkedValue: val.listItem($shapeList, $value, 'fontShapes().#{$value}');
|
|
115
|
+
|
|
116
|
+
.#{$class} {
|
|
117
|
+
@if $type == 'transform' {
|
|
118
|
+
text-transform: $value;
|
|
119
|
+
} @else if $type == 'decoration' {
|
|
120
|
+
text-decoration: $value;
|
|
121
|
+
} @else if $type == 'styles' {
|
|
122
|
+
font-style: $value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
@use "sass:meta";
|
|
2
|
+
@use "sass:list";
|
|
3
|
+
@use "sass:map";
|
|
4
|
+
@use "../settings/configs" as configs;
|
|
5
|
+
|
|
6
|
+
// Basics validations functions
|
|
7
|
+
|
|
8
|
+
// @function number
|
|
9
|
+
// @description Validates if a value is a number.
|
|
10
|
+
// @param {*} $number - The value to validate.
|
|
11
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
12
|
+
// @return {*} The original value if it's a number.
|
|
13
|
+
// @error If the value is not a number.
|
|
14
|
+
@function number($number, $in: null) {
|
|
15
|
+
@if $number != null and (meta.type-of($number) != "number") {
|
|
16
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
17
|
+
@error '❌ Error at "validate.number()": Please enter a valid number | Expected a number, but got "#{$number}"#{$in}';
|
|
18
|
+
}
|
|
19
|
+
@return $number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// @function string
|
|
23
|
+
// @description Validates if a value is a string.
|
|
24
|
+
// @param {*} $string - The value to validate.
|
|
25
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
26
|
+
// @return {*} The original value if it's a string.
|
|
27
|
+
// @error If the value is not a string.
|
|
28
|
+
@function string($string, $in: null) {
|
|
29
|
+
@if $string != null and (meta.type-of($string) != "string") {
|
|
30
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
31
|
+
@error '❌ Error at "validate.string()": Please enter a valid string | Expected a string, but got "#{$string}"#{$in}';
|
|
32
|
+
}
|
|
33
|
+
@return $string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// @function boolean
|
|
37
|
+
// @description Validates if a value is a boolean.
|
|
38
|
+
// @param {*} $boolean - The value to validate.
|
|
39
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
40
|
+
// @return {*} The original value if it's a boolean.
|
|
41
|
+
// @error If the value is not a boolean.
|
|
42
|
+
@function boolean($boolean, $in: null) {
|
|
43
|
+
@if $boolean != null and (meta.type-of($boolean) != "bool") {
|
|
44
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
45
|
+
@error '❌ Error at "validate.boolean()": Please enter a valid boolean | Expected a (true or false), but got "#{$boolean}"#{$in}';
|
|
46
|
+
}
|
|
47
|
+
@return $boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// @function notNull
|
|
51
|
+
// @description Validates if a value is not null.
|
|
52
|
+
// @param {*} $value - The value to validate.
|
|
53
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
54
|
+
// @return {*} The original value if it's not null.
|
|
55
|
+
// @error If the value is null.
|
|
56
|
+
@function notNull($value, $in: null) {
|
|
57
|
+
@if $value == null {
|
|
58
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
59
|
+
@error '❌ Error at "validate.notNull()": Please enter a valid value | Value must not be null#{$in}';
|
|
60
|
+
}
|
|
61
|
+
@return $value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Colors validations functions
|
|
65
|
+
|
|
66
|
+
// @function opacity
|
|
67
|
+
// @description Validates if a value is a valid opacity (number between 0 and 1).
|
|
68
|
+
// @param {*} $opacity - The value to validate.
|
|
69
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
70
|
+
// @return {*} The original value if it's a valid opacity.
|
|
71
|
+
// @error If the value is not a number or not between 0 and 1.
|
|
72
|
+
@function opacity($opacity, $in: null) {
|
|
73
|
+
@if $opacity != null and (meta.type-of($opacity) != "number" or $opacity < 0 or $opacity > 1) {
|
|
74
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
75
|
+
@error '❌ Error at "validate.opacity()": Please enter a valid number | Opacity must be a number between 0 and 1. You entered: "#{$opacity}"#{$in}';
|
|
76
|
+
}
|
|
77
|
+
@return $opacity;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// @function colorMode
|
|
81
|
+
// @description Validates if a value is a valid color mode ('light' or 'dark').
|
|
82
|
+
// @param {*} $mode - The value to validate.
|
|
83
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
84
|
+
// @return {*} The original value if it's a valid color mode.
|
|
85
|
+
// @error If the value is not 'light' or 'dark'.
|
|
86
|
+
@function colorMode($mode, $in: null) {
|
|
87
|
+
@if $mode != null and not($mode == "light" or $mode == "dark") {
|
|
88
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
89
|
+
@error '❌ Error at "validate.colorMode()": Please enter a valid mode | Allowed values are "light" or "dark"#{$in}';
|
|
90
|
+
}
|
|
91
|
+
@return $mode;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// @function hexColor
|
|
95
|
+
// @description Validates if a value is a valid hex color.
|
|
96
|
+
// @param {String} $key - The key name of the color (for error messages).
|
|
97
|
+
// @param {*} $value - The value to validate.
|
|
98
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
99
|
+
// @return {*} The original value if it's a valid hex color.
|
|
100
|
+
// @error If the value is null, not a string/color, or doesn't start with '#'.
|
|
101
|
+
@function hexColor($key, $value, $in: null) {
|
|
102
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
103
|
+
|
|
104
|
+
@if $value == null {
|
|
105
|
+
@error '❌ Error at "validate.hexColor()": Invalid "#{$key}" value | "#{$key}" value is null#{$in}';
|
|
106
|
+
} @else if meta.type-of($value) != "string" and meta.type-of($value) != "color" {
|
|
107
|
+
@error '❌ Error at "validate.hexColor()": Invalid "#{$key}" value | "#{$key}" value must be a string or color, got type #{meta.type-of($value)}#{$in}';
|
|
108
|
+
} @else if meta.type-of($value) == "string" and str-index($value, "#") != 1 {
|
|
109
|
+
@error '❌ Error at "validate.hexColor()": Invalid "#{$key}" value | "#{$key}" value must start with "#", got "#{$value}"#{$in}';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@return $value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Map validations functions
|
|
116
|
+
|
|
117
|
+
// @function map
|
|
118
|
+
// @description Validates if a value is a map.
|
|
119
|
+
// @param {*} $map - The value to validate.
|
|
120
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
121
|
+
// @return {*} The original value if it's a map.
|
|
122
|
+
// @error If the value is not a map.
|
|
123
|
+
@function map($map, $in: null) {
|
|
124
|
+
@if meta.type-of($map) != map {
|
|
125
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
126
|
+
@error '❌ Error at "validate.map()": Invalid type provided | Expected a map, but got "#{$map}" of type "#{meta.type-of($map)}"#{$in}';
|
|
127
|
+
}
|
|
128
|
+
@return $map;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// @function mapItem
|
|
132
|
+
// @description Validates if a map contains a specific key.
|
|
133
|
+
// @param {Map} $map - The map to validate.
|
|
134
|
+
// @param {String} $key - The key to check for.
|
|
135
|
+
// @param {List} $expectedKeys - A list of expected keys (for error messages).
|
|
136
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
137
|
+
// @return {Map} The original map if the key exists.
|
|
138
|
+
// @error If the key is missing from the map.
|
|
139
|
+
@function mapItem($map, $key, $expectedKeys, $in: null) {
|
|
140
|
+
@if not map.has-key($map, $key) {
|
|
141
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
142
|
+
@error '❌ Error at "validate.mapItem()": Missing key | Missing key "#{$key}" in the map "#{$map}" | Expected keys: "#{$expectedKeys}"#{$in}';
|
|
143
|
+
}
|
|
144
|
+
@return $map;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// List validations functions
|
|
148
|
+
|
|
149
|
+
// @function list
|
|
150
|
+
// @description Validates if a value is a list. If it's a single string, number, boolean, or color, it's converted to a single-item list.
|
|
151
|
+
// @param {*} $list - The value to validate.
|
|
152
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
153
|
+
// @return {List} The original value if it's a list, or a new list containing the value.
|
|
154
|
+
// @error If the value is not a list and cannot be converted.
|
|
155
|
+
@function list($list, $in: null) {
|
|
156
|
+
$list-type: meta.type-of($list);
|
|
157
|
+
|
|
158
|
+
@if $list != null and $list-type != "list" {
|
|
159
|
+
@if $list-type ==
|
|
160
|
+
"string" or
|
|
161
|
+
$list-type ==
|
|
162
|
+
"number" or
|
|
163
|
+
$list-type ==
|
|
164
|
+
"bool" or
|
|
165
|
+
$list-type ==
|
|
166
|
+
"color"
|
|
167
|
+
{
|
|
168
|
+
@return ($list);
|
|
169
|
+
} @else {
|
|
170
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
171
|
+
@error '❌ Error at "validate.list()": Please enter a valid list | Expected a list, but got "#{$list}" of type "#{$list-type}"#{$in}';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@return $list;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// @function listItem
|
|
179
|
+
// @description Validates if an item exists in a list.
|
|
180
|
+
// @param {List} $list - The list to search in.
|
|
181
|
+
// @param {*} $item - The item to search for.
|
|
182
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
183
|
+
// @return {*} The item if it's found in the list.
|
|
184
|
+
// @error If the item is not found in the list.
|
|
185
|
+
@function listItem($list, $item, $in: null) {
|
|
186
|
+
@if not list.index($list, $item) {
|
|
187
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
188
|
+
@error '❌ Error at "validate.listItem()": Invalid item | Missing item "#{$item}" not found in the list "#{$list}"#{$in}';
|
|
189
|
+
}
|
|
190
|
+
@return $item;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Custom colors validations functions
|
|
194
|
+
|
|
195
|
+
// @function colorMap
|
|
196
|
+
// @description Validates a map of colors, ensuring each color has 'light' and 'dark' variants that are valid hex colors.
|
|
197
|
+
// @param {Map} $map - The color map to validate.
|
|
198
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
199
|
+
// @return {Map} The original map if all colors and variants are valid.
|
|
200
|
+
// @error If the map structure is incorrect or color values are invalid.
|
|
201
|
+
@function colorMap($map, $in: null) {
|
|
202
|
+
$mapVal: map($map);
|
|
203
|
+
|
|
204
|
+
@each $key, $value in $map {
|
|
205
|
+
$mapVal: map($value, $in);
|
|
206
|
+
$lightKey: colorMode($value, $in);
|
|
207
|
+
$darkKey: colorMode($value, $in);
|
|
208
|
+
$light: hexColor("#{$key}.light", map.get($value, "light"), $in);
|
|
209
|
+
$dark: hexColor("#{$key}.dark", map.get($value, "dark"), $in);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@return $map;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// @function colorOpacity
|
|
216
|
+
// @description Validates if an opacity value is one of the predefined opacities in `configs.$opacities`.
|
|
217
|
+
// @param {*} $opacity - The opacity value to validate.
|
|
218
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
219
|
+
// @return {*} The original opacity value if it's valid.
|
|
220
|
+
// @error If the opacity value is not in `configs.$opacities`.
|
|
221
|
+
@function colorOpacity($opacity, $in: null) {
|
|
222
|
+
@if $opacity != null and not(list.index(configs.$opacities, $opacity)) {
|
|
223
|
+
$in: if($in != null, " | in #{$in}", ".");
|
|
224
|
+
@error '❌ Error at "validate.colorOpacity()": Invalid color property value | Expected one of (#{configs.$opacities}), but got "#{$opacity}"#{$in}';
|
|
225
|
+
}
|
|
226
|
+
@return $opacity;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// @function colorProperty
|
|
230
|
+
// @description Validates if a color property value is one of the allowed values in `configs.$colorsPropertiesMap`.
|
|
231
|
+
// @param {*} $value - The color property value to validate.
|
|
232
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
233
|
+
// @return {*} The original value if it's a valid color property.
|
|
234
|
+
// @error If the value is not an allowed color property.
|
|
235
|
+
@function colorProperty($value, $in: null) {
|
|
236
|
+
@if $value != null and not(list.index(map.values(configs.$colorsPropertiesMap), $value)) {
|
|
237
|
+
@error '❌ Error at "validate.colorProperty()": Invalid color property value | Expected one of #{map.values(configs.$colorsPropertiesMap)}, but got "#{$value}"#{$in}';
|
|
238
|
+
}
|
|
239
|
+
@return $value;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// @function colorClass
|
|
243
|
+
// @description Validates if a color class value is one of the allowed keys in `configs.$colorsPropertiesMap`.
|
|
244
|
+
// @param {*} $value - The color class value to validate.
|
|
245
|
+
// @param {String | Null} $in - Optional context for the error message.
|
|
246
|
+
// @return {*} The original value if it's a valid color class.
|
|
247
|
+
// @error If the value is not an allowed color class.
|
|
248
|
+
@function colorClass($value, $in: null) {
|
|
249
|
+
@if $value !=
|
|
250
|
+
null and
|
|
251
|
+
not($value == null or list.index(map.keys(configs.$colorsPropertiesMap), $value))
|
|
252
|
+
{
|
|
253
|
+
@error '❌ Error at "validate.colorClass()": Invalid color class value | Expected one of #{map.keys(configs.$colorsPropertiesMap)}, but got "#{$value}"#{$in}';
|
|
254
|
+
}
|
|
255
|
+
@return $value;
|
|
256
|
+
}
|