Skip to content

Commit 24affdb

Browse files
simeonoffkdinev
authored andcommitted
feat(themes): add standalone label theme (#13221)
* feat(themes): add standalone label theme Closes #13211 --------- Co-authored-by: Konstantin Dinev <[email protected]>
1 parent dd3f70d commit 24affdb

File tree

10 files changed

+103
-14
lines changed

10 files changed

+103
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ All notable changes for each version of this project will be documented in this
3737
- `IgxCombo`:
3838
- Exposed `comboIgnoreDiacriticsFilter` filter function which normalizes diacritics to their base representation.
3939
When the combo components are configured with it, filtering for **"resume"** will match both **"resume"** and **"résumé"**.
40+
- `Themes`:
41+
- Include a standalone theme for the `igxLabel` directive to allow usage with components outside the Input Group.
4042

4143
### General
4244
- `IgxStepper`:

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@types/source-map": "0.5.2",
6767
"fflate": "^0.7.3",
6868
"hammerjs": "^2.0.8",
69-
"igniteui-theming": "^2.0.0",
69+
"igniteui-theming": "^2.1.0",
7070
"igniteui-trial-watermark": "^2.0.0",
7171
"lodash-es": "^4.17.21",
7272
"rxjs": "^6.6.7",

projects/igniteui-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"igniteui-trial-watermark": "^1.0.3",
7777
"lodash-es": "^4.17.21",
7878
"uuid": "^9.0.0",
79-
"igniteui-theming": "^2.0.0",
79+
"igniteui-theming": "^2.1.0",
8080
"@igniteui/material-icons-extended": "^2.10.0"
8181
},
8282
"peerDependencies": {

projects/igniteui-angular/src/lib/core/styles/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
@forward 'highlight/highlight-theme.scss';
2929
@forward 'icon/icon-theme';
3030
@forward 'input/input-group-theme';
31+
@forward 'label/label-theme';
3132
@forward 'list/list-theme';
3233
@forward 'navbar/navbar-theme';
3334
@forward 'navdrawer/navdrawer-theme';

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -892,20 +892,12 @@
892892
}
893893

894894
%form-group-label {
895-
@include ellipsis();
896-
max-width: 100%;
897895
padding-inline-end: rem(4px);
898-
line-height: normal;
899896
backface-visibility: hidden;
900897
will-change: transform;
901898
transform-origin: top left;
902899
transition: all $transition-timing;
903900
margin-inline-start: pad-inline(0, rem(-2px), rem(-4px));
904-
color: var-get($theme, 'idle-secondary-color');
905-
906-
[dir='rtl'] & {
907-
transform-origin: top right;
908-
}
909901
}
910902

911903
%form-group-label--border {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@use '../../base' as *;
2+
@use 'sass:string';
3+
4+
/// @access private
5+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
6+
7+
@mixin component {
8+
@include register-component(
9+
$name: 'igx-label',
10+
$deps: ()
11+
);
12+
13+
[igxLabel] {
14+
@extend %label-base !optional;
15+
}
16+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@use 'sass:map';
2+
@use 'sass:meta';
3+
@use '../../base' as *;
4+
@use '../../themes/schemas' as *;
5+
6+
////
7+
/// @group themes
8+
/// @access public
9+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
10+
////
11+
12+
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
13+
/// @param {Map} $color [null] - The text color.
14+
@function label-theme(
15+
$schema: $light-material-schema,
16+
$color: null
17+
) {
18+
$name: 'igx-label';
19+
$selector: '[igxLabel]';
20+
$label-schema: ();
21+
22+
@if map.has-key($schema, 'label') {
23+
$label-schema: map.get($schema, 'label');
24+
} @else {
25+
$label-schema: $schema;
26+
}
27+
28+
$theme: digest-schema($label-schema);
29+
30+
@return extend($theme, (
31+
name: $name,
32+
selector: $selector,
33+
color: $color,
34+
variant: map.get($schema, '_meta', 'theme'),
35+
));
36+
}
37+
38+
/// @param {Map} $theme - The theme used to style the component.
39+
@mixin label($theme) {
40+
// The --variant CSS produced by css-vars is needed also
41+
// when dynamically switching between the input `type` attribute.
42+
@include css-vars($theme);
43+
$variant: map.get($theme, 'variant');
44+
45+
%label-base {
46+
@include ellipsis();
47+
position: relative;
48+
color: var-get($theme, 'color');
49+
max-width: 100%;
50+
line-height: normal;
51+
font-size: rem(16px);
52+
53+
[dir='rtl'] & {
54+
transform-origin: top right;
55+
}
56+
57+
@if $variant == 'fluent' or $variant == 'indigo-design' {
58+
font-size: rem(14px);
59+
font-weight: 600;
60+
height: auto;
61+
}
62+
63+
@if $variant == 'bootstrap' {
64+
line-height: rem(24px);
65+
height: auto;
66+
}
67+
}
68+
}

projects/igniteui-angular/src/lib/core/styles/themes/_core.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
@use '../components/highlight/highlight-component' as highlight;
5858
@use '../components/icon/icon-component' as icon;
5959
@use '../components/input/input-group-component' as input-group;
60+
@use '../components/label/label-component' as label;
6061
@use '../components/list/list-component' as list;
6162
@use '../components/navbar/navbar-component' as navbar;
6263
@use '../components/navdrawer/navdrawer-component' as navdrawer;
@@ -152,6 +153,7 @@
152153
@include highlight.component();
153154
@include icon.component();
154155
@include input-group.component();
156+
@include label.component();
155157
@include list.component();
156158
@include navbar.component();
157159
@include navdrawer.component();

projects/igniteui-angular/src/lib/core/styles/themes/generators/_base.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,14 @@
475475
@include list($list-theme-map);
476476
}
477477

478+
@if is-used('igx-label', $exclude) {
479+
$label-theme-map: label-theme(
480+
$schema: $schema,
481+
);
482+
$label-theme-map: meta.call($theme-handler, $label-theme-map);
483+
@include label($label-theme-map);
484+
}
485+
478486
@if is-used('igx-navbar', $exclude) {
479487
$navbar-theme-map: navbar-theme(
480488
$schema: $schema,

0 commit comments

Comments
 (0)