igniteui-theming 1.2.0 → 1.4.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/index.js +2 -0
- package/package.json +17 -4
- package/sass/color/_functions.scss +1 -1
- package/sass/color/_mixins.scss +36 -16
- package/sass/themes/_functions.scss +11 -2
- package/sass/themes/_mixins.scss +1 -1
- package/sass/typography/_mixins.scss +16 -4
- package/sass/typography/_types.scss +1 -1
- package/sass/utils/_meta.scss +18 -1
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-theming",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A set of Sass variables, mixins, and functions for generating palettes, typography, and elevations used by Ignite UI components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,10 +13,17 @@
|
|
|
13
13
|
"build:docs:en:staging": "set NODE_ENV=staging && npx sassdoc ./sass -d docs",
|
|
14
14
|
"build:e2e": "sass ./test/e2e/theme.scss ./test/e2e/theme.css",
|
|
15
15
|
"build:json": "node scripts/buildJSON.mjs",
|
|
16
|
-
"
|
|
16
|
+
"serve:docs": "npx http-server ./docs",
|
|
17
17
|
"preview:palette": "node scripts/previewPalette.mjs",
|
|
18
|
+
"lint": "stylelint ./sass",
|
|
18
19
|
"test": "jest",
|
|
19
|
-
"
|
|
20
|
+
"format": "stylelint \"**/*.{scss,css}\" --fix --allow-empty-input --ignore-path .gitignore",
|
|
21
|
+
"prepare": "husky install"
|
|
22
|
+
},
|
|
23
|
+
"lint-staged": {
|
|
24
|
+
"**/*.{scss,css}": [
|
|
25
|
+
"npm run format"
|
|
26
|
+
]
|
|
20
27
|
},
|
|
21
28
|
"files": [
|
|
22
29
|
"/sass",
|
|
@@ -44,7 +51,12 @@
|
|
|
44
51
|
"homepage": "https://github.com/IgniteUI/igniteui-theming#readme",
|
|
45
52
|
"exports": {
|
|
46
53
|
".": {
|
|
47
|
-
"sass": "./_index.scss"
|
|
54
|
+
"sass": "./_index.scss",
|
|
55
|
+
"esm2020": "./index.js",
|
|
56
|
+
"es2020": "./index.js",
|
|
57
|
+
"es2015": "./index.js",
|
|
58
|
+
"node": "./index.js",
|
|
59
|
+
"default": "./index.js"
|
|
48
60
|
},
|
|
49
61
|
"./functions": {
|
|
50
62
|
"sass": "./sass/_functions.scss"
|
|
@@ -52,6 +64,7 @@
|
|
|
52
64
|
},
|
|
53
65
|
"devDependencies": {
|
|
54
66
|
"globby": "^13.1.2",
|
|
67
|
+
"husky": "^8.0.2",
|
|
55
68
|
"igniteui-sassdoc-theme": "^1.1.4",
|
|
56
69
|
"jest": "^28.1.1",
|
|
57
70
|
"lunr": "^2.3.9",
|
|
@@ -30,7 +30,7 @@ $_enhanced-accessibility: false;
|
|
|
30
30
|
/// @group Palettes
|
|
31
31
|
/// @param {Color} $primary - The primary color used to generate the primary color palette (required).
|
|
32
32
|
/// @param {Color} $secondary - The secondary color used to generate the secondary color palette (required).
|
|
33
|
-
/// @param {Color} $surface - The color used as a background in components
|
|
33
|
+
/// @param {Color} $surface - The color used as a background in components (required).
|
|
34
34
|
/// @param {Color} $gray [null] - The color used for generating the grayscale palette (optional).
|
|
35
35
|
/// @param {Color} $info [#1377d5] - The information color used throughout the application (optional).
|
|
36
36
|
/// @param {Color} $success [#4eb862] - The success color used throughout the application (optional).
|
package/sass/color/_mixins.scss
CHANGED
|
@@ -5,33 +5,39 @@
|
|
|
5
5
|
@use 'sass:string';
|
|
6
6
|
@use '../utils/meta' as *;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/// @param {Map} $palette - The palette used to generate CSS variables.
|
|
12
|
-
/// @param {Boolean} $contrast [true] - Specify if contrast colors should be included.
|
|
13
|
-
/// @example scss Generate css variables for a palette
|
|
14
|
-
/// $palette: palette($primary: red, $secondary: blue, $gray: #000);
|
|
15
|
-
/// @include palette($palette);
|
|
16
|
-
/// @require {function} is-root
|
|
17
|
-
@mixin palette($palette, $contrast: true) {
|
|
8
|
+
// Generates CSS variables for the base colors.
|
|
9
|
+
// @access private
|
|
10
|
+
@mixin _base-colors($palette) {
|
|
18
11
|
$scope: if(is-root(), ':root', '&');
|
|
19
12
|
|
|
20
13
|
#{$scope} {
|
|
21
14
|
@each $color, $shades in map.remove($palette, '_meta') {
|
|
22
15
|
@each $shade, $value in $shades {
|
|
23
|
-
$
|
|
24
|
-
$_valid
|
|
25
|
-
$_other-shade: meta.type-of($shade) == 'string';
|
|
26
|
-
$_hsl: if($_other-shade, string.index($shade, 'hsl'), false);
|
|
27
|
-
$_contrast: if($_other-shade, string.index($shade, 'contrast'), false);
|
|
16
|
+
$_shade: $shade == 500;
|
|
17
|
+
$_valid: meta.type-of($value == 'color');
|
|
28
18
|
|
|
29
|
-
@if $
|
|
19
|
+
@if $_shade and $_valid {
|
|
30
20
|
--ig-#{$color}-h: #{math.round(color.hue($value))};
|
|
31
21
|
--ig-#{$color}-s: #{math.round(color.saturation($value))};
|
|
32
22
|
--ig-#{$color}-l: #{math.round(color.lightness($value))};
|
|
33
23
|
--ig-#{$color}-a: #{color.alpha($value)};
|
|
34
24
|
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Generates shade CSS variables from the base colors.
|
|
31
|
+
// @access private
|
|
32
|
+
@mixin _shade-colors($palette, $contrast: true) {
|
|
33
|
+
$scope: if(is-root(), '*', '&');
|
|
34
|
+
|
|
35
|
+
#{$scope} {
|
|
36
|
+
@each $color, $shades in map.remove($palette, '_meta') {
|
|
37
|
+
@each $shade, $value in $shades {
|
|
38
|
+
$_shade: meta.type-of($shade) == 'string';
|
|
39
|
+
$_hsl: if($_shade, string.index($shade, 'hsl'), false);
|
|
40
|
+
$_contrast: if($_shade, string.index($shade, 'contrast'), false);
|
|
35
41
|
|
|
36
42
|
@if $_hsl {
|
|
37
43
|
$variant: string.slice($shade, 1, string.index($shade, '-hsl') - 1);
|
|
@@ -46,3 +52,17 @@
|
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
55
|
+
|
|
56
|
+
/// Generates CSS variables for a given palette.
|
|
57
|
+
/// @access public
|
|
58
|
+
/// @group Palettes
|
|
59
|
+
/// @param {Map} $palette - The palette used to generate CSS variables.
|
|
60
|
+
/// @param {Boolean} $contrast [true] - Specify if contrast colors should be included.
|
|
61
|
+
/// @example scss Generate css variables for a palette
|
|
62
|
+
/// $palette: palette($primary: red, $secondary: blue, $gray: #000);
|
|
63
|
+
/// @include palette($palette);
|
|
64
|
+
/// @require {function} is-root
|
|
65
|
+
@mixin palette($palette, $contrast: true) {
|
|
66
|
+
@include _base-colors($palette);
|
|
67
|
+
@include _shade-colors($palette, $contrast);
|
|
68
|
+
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
$result: ();
|
|
27
27
|
|
|
28
28
|
@each $key, $value in $schema {
|
|
29
|
-
@if meta.type-of($value) == 'map' {
|
|
29
|
+
@if meta.type-of($value) == 'map' and $key != '_meta' {
|
|
30
30
|
$result: map.merge($result, (#{$key}: resolve-value($value)));
|
|
31
31
|
} @else {
|
|
32
32
|
$result: map.merge($result, (#{$key}: $value));
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/// Used to switch between values based on the size of the component.
|
|
129
|
+
/// The passed sizes are converted to absolute values before comparing.
|
|
129
130
|
/// @group themes
|
|
130
131
|
/// @access public
|
|
131
132
|
/// @param {Number} $sm - The preferred value when the component's size is small.
|
|
@@ -135,6 +136,10 @@
|
|
|
135
136
|
/// --size: #{sizable(rem(40px), rem(64px), rem(88px))};
|
|
136
137
|
/// @return {Function} - The evaluated value.
|
|
137
138
|
@function sizable($sm, $md: $sm, $lg: $md) {
|
|
139
|
+
$sm: max(#{$sm}, -1 * #{$sm});
|
|
140
|
+
$md: max(#{$md}, -1 * #{$md});
|
|
141
|
+
$lg: max(#{$lg}, -1 * #{$lg});
|
|
142
|
+
|
|
138
143
|
@return max(
|
|
139
144
|
calc(var(--is-large, 1) * #{$lg}),
|
|
140
145
|
calc(var(--is-medium, 1) * #{$md}),
|
|
@@ -142,7 +147,8 @@
|
|
|
142
147
|
);
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
///
|
|
150
|
+
/// Returns a value based on the size of the component taking spacing values into consideration.
|
|
151
|
+
/// The passed sizes are converted to absolute values before comparing.
|
|
146
152
|
/// @group utilities
|
|
147
153
|
/// @access public
|
|
148
154
|
/// @param {Number} $sm - The preferred value when the component's size is small.
|
|
@@ -156,6 +162,9 @@
|
|
|
156
162
|
/// @return {Function} - The evaluated value.
|
|
157
163
|
@function pad($sm, $md: $sm, $lg: $md, $dir: null) {
|
|
158
164
|
$spacing: if($dir, --ig-spacing-#{$dir}, --ig-spacing);
|
|
165
|
+
$sm: max(#{$sm}, -1 * #{$sm});
|
|
166
|
+
$md: max(#{$md}, -1 * #{$md});
|
|
167
|
+
$lg: max(#{$lg}, -1 * #{$lg});
|
|
159
168
|
|
|
160
169
|
@return max(
|
|
161
170
|
calc(var(--is-large, 1) * #{$lg} * var(#{$spacing}-large, var(#{$spacing}, --ig-spacing))),
|
package/sass/themes/_mixins.scss
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
/// A list of ignored keywords to be excluded when generating CSS variables for a theme.
|
|
9
9
|
/// @access private
|
|
10
|
-
$ignored-keys: ('name', 'palette', 'variant', 'selector');
|
|
10
|
+
$ignored-keys: ('name', 'palette', 'variant', 'selector', 'type', '_meta');
|
|
11
11
|
|
|
12
12
|
/// Parses a map of key value pairs from component themes to css variables.
|
|
13
13
|
/// @access private
|
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
@if $valid {
|
|
25
25
|
@each $key, $value in types.$ITypeStyle {
|
|
26
|
-
#{$key}
|
|
26
|
+
@if #{$key} == 'font-family' {
|
|
27
|
+
font-family: var(--ig-#{$category}-#{$key}, var(--ig-font-family));
|
|
28
|
+
} @else {
|
|
29
|
+
#{$key}: var(--ig-#{$category}-#{$key});
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
@content;
|
|
29
33
|
} @else {
|
|
@@ -39,7 +43,13 @@
|
|
|
39
43
|
/// @include type-style-vars('h1', $h1-style);
|
|
40
44
|
@mixin type-style-vars($name, $type-style) {
|
|
41
45
|
@each $key, $value in map.remove($type-style, '_meta') {
|
|
42
|
-
|
|
46
|
+
@if $key == 'font-family' and $value != inherit {
|
|
47
|
+
--ig-#{$name}-#{$key}: #{$value};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@if $key != 'font-family' {
|
|
51
|
+
--ig-#{$name}-#{$key}: #{$value};
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
}
|
|
45
55
|
|
|
@@ -111,7 +121,9 @@
|
|
|
111
121
|
/// @example scss
|
|
112
122
|
/// @include typography('Roboto', $my-type-scale);
|
|
113
123
|
@mixin typography($font-family, $type-scale) {
|
|
114
|
-
$
|
|
124
|
+
$root: is-root();
|
|
125
|
+
$host: is-host();
|
|
126
|
+
$scope: if($root, ':root', '&');
|
|
115
127
|
|
|
116
128
|
#{$scope} {
|
|
117
129
|
--ig-font-family: #{string.unquote($font-family)};
|
|
@@ -121,7 +133,7 @@
|
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
@if
|
|
136
|
+
@if $root or $host {
|
|
125
137
|
.ig-typography {
|
|
126
138
|
@include type-style-elements();
|
|
127
139
|
@include type-style-classes();
|
package/sass/utils/_meta.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:selector';
|
|
2
|
+
|
|
1
3
|
/// Returns true if the scope where it's called is the root of the document.
|
|
2
4
|
/// @access private
|
|
3
5
|
/// @example scss Check if the current scope is root
|
|
@@ -11,6 +13,21 @@
|
|
|
11
13
|
/// @return {Boolean} - Returns a boolean depending on the scope where it's called
|
|
12
14
|
@function is-root() {
|
|
13
15
|
@each $selector in & {
|
|
14
|
-
@return
|
|
16
|
+
@return $selector == null;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
/// Returns true if the scope where it's called is :host.
|
|
21
|
+
/// @access private
|
|
22
|
+
/// @example scss Check if the current scope is :root
|
|
23
|
+
/// @mixin smart-mixin() {
|
|
24
|
+
/// $host: is-host();
|
|
25
|
+
///
|
|
26
|
+
/// @if is-host() {
|
|
27
|
+
/// /* style rules here */
|
|
28
|
+
/// }
|
|
29
|
+
/// }
|
|
30
|
+
/// @return {Boolean} - Returns a boolean depending on the scope where it's called
|
|
31
|
+
@function is-host() {
|
|
32
|
+
@return not(is-root()) and selector.is-superselector(':host', &);
|
|
33
|
+
}
|