Skip to content

Commit 7858574

Browse files
authored
Improve Component Themes (#15729)
1 parent 6156bce commit 7858574

File tree

61 files changed

+4656
-1081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4656
-1081
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 20.0.2
6+
7+
### New Features
8+
- **Separating Button and Icon Button Themes** - The `button-theme` and `icon-button-theme` functions are still available, but for more targeted customization, you can now use the specific theme function for each button type.
9+
- **Component Themes Enchancements** - Component themes have been improved to automatically calculate all necessary states (e.g., hover, focus, active) based on just a few key values. For example, customizing a contained button requires only a background color:
10+
```scss
11+
$custom-contained-button: contained-button-theme(
12+
$background: #09f;
13+
);
14+
```
15+
516
## 20.0.0
617

718
### General

projects/igniteui-angular-elements/src/app/wrapper/wrapper.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export class TemplateWrapperComponent {
1616

1717
public templateFunctions: TemplateFunction[] = [];
1818
public templateRendered = new Subject<HTMLElement>();
19-
2019
private childParts: WeakMap<HTMLElement, RootPart> = new WeakMap();
2120

2221
/**
@@ -28,7 +27,7 @@ export class TemplateWrapperComponent {
2827
public templateRefs: QueryList<TemplateRef<any>>;
2928

3029
constructor(private cdr: ChangeDetectorRef) { }
31-
30+
3231
protected litRender(container: HTMLElement, templateFunc: (arg: any) => TemplateResult, arg: any) {
3332
const part = render(templateFunc(arg), container);
3433

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-theme.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
}
4242

4343
$theme: digest-schema($action-strip-schema);
44-
$meta: map.get($theme, '_meta');
4544

4645
@if not($icon-color) and $actions-background {
47-
$icon-color: text-contrast($actions-background);
46+
$icon-color: adaptive-contrast(var(--actions-background));
4847
}
4948

5049
@if not($actions-border-radius) {
@@ -58,10 +57,6 @@
5857
icon-color: $icon-color,
5958
delete-action: $delete-action,
6059
actions-border-radius: $actions-border-radius,
61-
theme: map.get($schema, '_meta', 'theme'),
62-
_meta: map.merge(if($meta, $meta, ()), (
63-
variant: map.get($schema, '_meta', 'theme')
64-
)),
6560
));
6661
}
6762

@@ -71,7 +66,7 @@
7166
@mixin action-strip($theme) {
7267
@include css-vars($theme);
7368

74-
$variant: map.get($theme, '_meta', 'variant');
69+
$variant: map.get($theme, '_meta', 'theme');
7570
$icon-button-size: map.get((
7671
'material': rem(36px),
7772
'fluent': rem(32px),

projects/igniteui-angular/src/lib/core/styles/components/avatar/_avatar-theme.scss

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@
4141
}
4242

4343
$theme: digest-schema($avatar-schema);
44-
$meta: map.get($theme, '_meta');
4544

4645
@if not($color) and $background {
47-
$color: text-contrast($background);
46+
$color: adaptive-contrast(var(--background));
47+
}
48+
49+
@if not($icon-color) and $background {
50+
$icon-color: adaptive-contrast(var(--background));
4851
}
4952

5053
@return extend($theme, (
@@ -54,10 +57,6 @@
5457
icon-color: $icon-color,
5558
border-radius: $border-radius,
5659
size: $size,
57-
theme: map.get($schema, '_meta', 'theme'),
58-
_meta: map.merge(if($meta, $meta, ()), (
59-
variant: map.get($schema, '_meta', 'theme')
60-
)),
6160
));
6261
}
6362

@@ -67,8 +66,8 @@
6766
@mixin avatar($theme) {
6867
@include css-vars($theme);
6968

70-
$variant: map.get($theme, '_meta', 'variant');
71-
69+
$variant: map.get($theme, '_meta', 'theme');
70+
7271
%igx-avatar-display {
7372
@include sizable();
7473

projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@
4848
}
4949

5050
$theme: digest-schema($badge-schema);
51-
$meta: map.get($theme, '_meta');
5251

5352
@if not($icon-color) and $background-color {
54-
$icon-color: text-contrast($background-color);
53+
$icon-color: adaptive-contrast(var(--background-color));
5554
}
5655

5756
@if not($text-color) and $background-color {
58-
$text-color: text-contrast($background-color);
57+
$text-color: adaptive-contrast(var(--background-color));
5958
}
6059

6160
@if not($shadow) {
@@ -71,10 +70,6 @@
7170
border-radius: $border-radius,
7271
background-color: $background-color,
7372
shadow: $shadow,
74-
theme: map.get($schema, '_meta', 'theme'),
75-
_meta: map.merge(if($meta, $meta, ()), (
76-
variant: map.get($schema, '_meta', 'theme'),
77-
)),
7873
));
7974
}
8075

@@ -84,7 +79,7 @@
8479
@mixin badge($theme) {
8580
@include css-vars($theme);
8681

87-
$variant: map.get($theme, '_meta', 'variant');
82+
$variant: map.get($theme, '_meta', 'theme');
8883

8984
%igx-badge-display {
9085
--size: #{rem(22px)};

projects/igniteui-angular/src/lib/core/styles/components/banner/_banner-theme.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
}
4444

4545
$theme: digest-schema($banner-schema);
46-
$meta: map.get($theme, '_meta');
4746

4847
@if not($banner-message-color) and $banner-background {
49-
$banner-message-color: text-contrast($banner-background);
48+
$banner-message-color: adaptive-contrast(var(--banner-background));
49+
}
50+
51+
@if not($banner-illustration-color) and $banner-background {
52+
$banner-illustration-color: adaptive-contrast(var(--banner-background));
5053
}
5154

5255
@return extend($theme, (
@@ -57,10 +60,6 @@
5760
banner-border-color: $banner-border-color,
5861
banner-illustration-color: $banner-illustration-color,
5962
border-radius: $border-radius,
60-
theme: map.get($schema, '_meta', 'theme'),
61-
_meta: map.merge(if($meta, $meta, ()), (
62-
variant: map.get($schema, '_meta', 'theme')
63-
)),
6463
));
6564
}
6665

@@ -69,7 +68,7 @@
6968
/// @param {Map} $theme - The theme used to style the component.
7069
@mixin banner($theme) {
7170
@include css-vars($theme);
72-
$variant: map.get($theme, '_meta', 'variant');
71+
$variant: map.get($theme, '_meta', 'theme');
7372

7473
%igx-banner-host {
7574
igx-expansion-panel-body {

projects/igniteui-angular/src/lib/core/styles/components/bottom-nav/_bottom-nav-theme.scss

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,36 @@
5151

5252
$theme: digest-schema($bottom-nav-schema);
5353

54-
$meta: map.get($theme, '_meta');
55-
56-
@if not($label-color) and $background {
57-
@if meta.type-of($background) == 'color' {
58-
$label-color: text-contrast($background);
59-
}
54+
@if not($label-color) and not($icon-color) and $background {
55+
$label-color: adaptive-contrast(var(--background));
6056
}
6157

6258
@if not($icon-color) and $label-color {
63-
@if meta.type-of($label-color) == 'color' {
64-
$icon-color: $label-color;
65-
}
59+
$icon-color: $label-color;
60+
}
61+
62+
@if not($label-color) and $icon-color {
63+
$label-color: $icon-color;
64+
}
65+
66+
@if not($icon-disabled-color) and not($label-disabled-color) and $label-color {
67+
$label-disabled-color: adaptive-contrast(var(--background));
6668
}
6769

6870
@if not($icon-disabled-color) and $label-disabled-color {
69-
@if meta.type-of($label-disabled-color) == 'color' {
70-
$icon-disabled-color: $label-disabled-color;
71-
}
71+
$icon-disabled-color: $label-disabled-color;
7272
}
7373

7474
@if not($label-disabled-color) and $icon-disabled-color {
75-
@if meta.type-of($icon-disabled-color) == 'color' {
76-
$label-disabled-color: $icon-disabled-color;
77-
}
75+
$label-disabled-color: $icon-disabled-color;
7876
}
7977

8078
@if not($icon-selected-color) and $label-selected-color {
81-
@if meta.type-of($background) == 'color' {
82-
$icon-selected-color: $label-selected-color;
83-
}
79+
$icon-selected-color: $label-selected-color;
8480
}
8581

86-
@if not($icon-color) and $background {
87-
@if meta.type-of($background) == 'color' {
88-
$icon-color: text-contrast($background);
89-
}
82+
@if not($label-selected-color) and $icon-selected-color {
83+
$label-selected-color: $icon-selected-color;
9084
}
9185

9286
@if not($shadow) {
@@ -105,11 +99,6 @@
10599
label-disabled-color: $label-disabled-color,
106100
border-color: $border-color,
107101
shadow: $shadow,
108-
theme: map.get($schema, '_meta', 'theme'),
109-
_meta: map.merge(if($meta, $meta, ()), (
110-
variant: map.get($schema, '_meta', 'theme'),
111-
theme-variant: map.get($schema, '_meta', 'variant')
112-
)),
113102
));
114103
}
115104

@@ -119,7 +108,7 @@
119108
@mixin bottom-nav($theme) {
120109
@include css-vars($theme);
121110

122-
$variant: map.get($theme, '_meta', 'variant');
111+
$variant: map.get($theme, '_meta', 'theme');
123112
$menu-height: rem(56px);
124113
$item-min-width: rem(80px);
125114
$item-max-width: rem(168px);

0 commit comments

Comments
 (0)