Skip to content

Commit e0a0eaf

Browse files
Merge pull request #5933 from IgniteUI/#fix-5403
feat(highlight): replace inline styles with theme
2 parents 96cb799 + a010dbc commit e0a0eaf

File tree

14 files changed

+193
-33
lines changed

14 files changed

+193
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# Ignite UI for Angular Change Log
1+
# Ignite UI for Angular Change Log
22

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

5+
## 8.2.3
6+
- `IgxTextHighlightDirective` - The default highlight directive styles have been moved to a Sass theme - `igx-highlight-theme`; You can modify the resting and active background and text color styles of the directive by passing the respective properties to the Sass theme. You can still pass your own CSS classes to the highlight directive via the cssClass and activeCssClass inputs.
7+
58
## 8.2.0
69
### New theme
710
Ignite UI for angular now have a new theme that mimics Microsoft "Fluent" design system.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
////
2+
/// @group components
3+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
4+
/// @requires {mixin} bem-block
5+
/// @requires {mixin} bem-elem
6+
/// @requires {mixin} bem-mod
7+
////
8+
@include b(igx-highlight) {
9+
// Register the component in the component registry
10+
$this: bem--selector-to-string(&);
11+
@include register-component(str-slice($this, 2, -1));
12+
13+
@extend %igx-highlight !optional;
14+
15+
@include m(active) {
16+
@extend %igx-highlight !optional;
17+
@extend %igx-highlight--active !optional;
18+
}
19+
}
20+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
////
2+
/// @group themes
3+
/// @access public
4+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
5+
////
6+
7+
/// If only background color(s) specified, text color(s) will be assigned automatically to a contrasting color.
8+
/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component.
9+
/// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component.
10+
/// @param {Color} $resting-background [null]- The background color used for the highlight in its resting state.
11+
/// @param {Color} $resting-color [null] - The text color used for the highlight in its resting state.
12+
/// @param {Color} $active-background [null] - The background color used for the highlight in its active state.
13+
/// @param {Color} $active-color [null] - The text color used for the highlight in its active state.
14+
/// @requires $default-palette
15+
/// @requires $light-schema
16+
/// @requires apply-palette
17+
/// @requires text-contrast
18+
/// @requires extend
19+
///
20+
/// @example scss Change the background and icon colors in icon highlight
21+
/// $my-avatar-theme: igx-avatar-theme($icon-background: black, $icon-color: white);
22+
/// // Pass the theme to the igx-avatar component mixin
23+
/// @include igx-avatar($my-avatar-theme);
24+
@function igx-highlight-theme(
25+
$palette: $default-palette,
26+
$schema: $light-schema,
27+
$resting-background: null,
28+
$resting-color: null,
29+
$active-background: null,
30+
$active-color: null,
31+
) {
32+
$name: 'igx-highlight';
33+
$theme: apply-palette(map-get($schema, $name), $palette);
34+
35+
@if not($resting-color) and $resting-background {
36+
$resting-color: text-contrast($resting-background);
37+
}
38+
39+
@if not($active-color) and $active-background {
40+
$active-color: text-contrast($active-background);
41+
}
42+
43+
@return extend($theme, (
44+
name: $name,
45+
palette: $palette,
46+
resting-background: $resting-background,
47+
resting-color: $resting-color,
48+
active-background: $active-background,
49+
active-color: $active-color,
50+
));
51+
}
52+
53+
/// @param {Map} $theme - The theme used to style the component.
54+
/// @requires {mixin} igx-root-css-vars
55+
/// @requires rem
56+
/// @requires --var
57+
@mixin igx-highlight($theme) {
58+
@include igx-root-css-vars($theme);
59+
60+
%igx-highlight {
61+
color: --var($theme, 'resting-color');
62+
background: --var($theme, 'resting-background');
63+
}
64+
65+
%igx-highlight--active {
66+
color: --var($theme, 'active-color');
67+
background: --var($theme, 'active-background');
68+
}
69+
}
70+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
@import '../components/grid-summary/grid-summary-component';
4343
@import '../components/grid-paginator/grid-paginator-component';
4444
@import '../components/grid-toolbar/grid-toolbar-component';
45+
@import '../components/highlight/highlight-component';
4546
@import '../components/icon/icon-component';
4647
@import '../components/input/input-group-component';
4748
@import '../components/list/list-component';

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@import '../components/grid-summary/grid-summary-theme';
3030
@import '../components/grid-paginator/grid-paginator-theme';
3131
@import '../components/grid-toolbar/grid-toolbar-theme';
32+
@import '../components/highlight/highlight-theme';
3233
@import '../components/overlay/overlay-theme';
3334
@import '../components/toast/toast-theme';
3435
@import '../components/tooltip/tooltip-theme';
@@ -278,6 +279,10 @@
278279
@include igx-grid-toolbar(igx-grid-toolbar-theme($palette, $schema));
279280
}
280281

282+
@if not(index($exclude, 'igx-highlight')) {
283+
@include igx-highlight(igx-highlight-theme($palette, $schema));
284+
}
285+
281286
@if not(index($exclude, 'igx-icon')) {
282287
@include igx-icon(igx-icon-theme($palette, $schema));
283288
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import '../light/highlight';
2+
////
3+
/// @group schemas
4+
/// @access private
5+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
6+
////
7+
8+
/// Generates a dark highlight schema.
9+
/// @type {Map}
10+
/// @requires {function} extend
11+
/// @requires $_light-highlight
12+
/// @see $default-palette
13+
$_dark-highlight: extend($_light-highlight);
14+
15+
/// Generates a dark fluent highlight schema.
16+
/// @type {Map}
17+
/// @requires {function} extend
18+
/// @requires $_fluent-highlight
19+
$_dark-fluent-highlight: extend($_fluent-highlight);
20+

projects/igniteui-angular/src/lib/core/styles/themes/schemas/dark/_index.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
@import './grid-pagination';
2626
@import './grid-summary';
2727
@import './grid-toolbar';
28+
@import './highlight';
2829
@import './icon';
2930
@import './input-group';
3031
@import './list';
@@ -66,6 +67,7 @@
6667
/// @property {Map} igx-grid-paginator [$_dark-grid-pagination]
6768
/// @property {Map} igx-grid-summary [$_dark-grid-summary]
6869
/// @property {Map} igx-grid-toolbar [$_dark-grid-toolbar]
70+
/// @property {Map} igx-highlight [$_dark-highlight]
6971
/// @property {Map} igx-icon [$_dark-icon]
7072
/// @property {Map} igx-input-group [$_dark-input-group]
7173
/// @property {Map} igx-list [$_dark-list]
@@ -106,6 +108,7 @@ $dark-schema: (
106108
igx-grid-paginator: $_dark-grid-pagination,
107109
igx-grid-summary: $_dark-grid-summary,
108110
igx-grid-toolbar: $_dark-grid-toolbar,
111+
igx-highlight: $_dark-highlight,
109112
igx-icon: $_dark-icon,
110113
igx-input-group: $_dark-input-group,
111114
igx-list: $_dark-list,
@@ -149,6 +152,7 @@ $dark-schema: (
149152
/// @property {map} igx-grid-paginator: [$_dark-fluent-grid-pagination],
150153
/// @property {map} igx-grid-summary: [$_dark-fluent-grid-summary],
151154
/// @property {map} igx-grid-toolbar: [$_dark-fluent-grid-toolbar],
155+
/// @property {map} igx-highlight: [$_dark-fluent-highlight],
152156
/// @property {map} igx-icon: [$_dark-fluent-icon],
153157
/// @property {map} igx-input-group: [$_dark-fluent-input-group],
154158
/// @property {map} igx-list: [$_dark-fluent-list],
@@ -189,6 +193,7 @@ $dark-fluent-schema: (
189193
igx-grid-paginator: $_dark-fluent-grid-pagination,
190194
igx-grid-summary: $_dark-fluent-grid-summary,
191195
igx-grid-toolbar: $_dark-fluent-grid-toolbar,
196+
igx-highlight: $_dark-fluent-highlight,
192197
igx-icon: $_dark-fluent-icon,
193198
igx-input-group: $_dark-fluent-input-group,
194199
igx-list: $_dark-fluent-list,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
////
2+
/// @group schemas
3+
/// @access private
4+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
5+
////
6+
7+
/// Generates a light highlight schema.
8+
/// @type {Map}
9+
/// @property {Map} resting-background [igx-color: ('secondary', 400)] - The background color used for the highlight in its resting state.
10+
/// @property {Map} resting-color [igx-color: ('secondary', 400), text-contrast: ()] - The icon color used for the highlight in its resting state.
11+
/// @property {Map} active-background [igx-color: ('secondary', 600)] - The background color used for the highlight in its active state.
12+
/// @property {Map} active-color [igx-color: ('secondary', 400), text-contrast: ()] - The text color used for the highlight in its active state.
13+
/// @see $default-palette
14+
$_light-highlight: (
15+
resting-background: (
16+
igx-color: ('secondary', 50)
17+
),
18+
19+
resting-color: (
20+
igx-color: ('secondary', 50),
21+
text-contrast: ()
22+
),
23+
24+
active-background: (
25+
igx-color: ('secondary', 200)
26+
),
27+
28+
active-color: (
29+
igx-color: ('secondary', 200),
30+
text-contrast: ()
31+
),
32+
);
33+
34+
/// Generates a fluent highlight schema.
35+
/// @type {Map}
36+
/// @requires {function} extend
37+
/// @requires $_light-highlight
38+
$_fluent-highlight: extend($_light-highlight);
39+

projects/igniteui-angular/src/lib/core/styles/themes/schemas/light/_index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@import './grid-pagination';
2727
@import './grid-summary';
2828
@import './grid-toolbar';
29+
@import './highlight';
2930
@import './icon';
3031
@import './input-group';
3132
@import './list';
@@ -67,6 +68,7 @@
6768
/// @property {Map} igx-grid-paginator [$_light-grid-pagination]
6869
/// @property {Map} igx-grid-summary [$_light-grid-summary]
6970
/// @property {Map} igx-grid-toolbar [$_light-grid-toolbar]
71+
/// @property {Map} igx-highlight [$_light-highlight]
7072
/// @property {Map} igx-icon [$_light-icon]
7173
/// @property {Map} igx-input-group [$_light-input-group]
7274
/// @property {Map} igx-list [$_light-list]
@@ -110,6 +112,7 @@ $light-schema: (
110112
igx-grid-paginator: $_light-grid-pagination,
111113
igx-grid-summary: $_light-grid-summary,
112114
igx-grid-toolbar: $_light-grid-toolbar,
115+
igx-highlight: $_light-highlight,
113116
igx-icon: $_light-icon,
114117
igx-input-group: $_light-input-group,
115118
igx-list: $_light-list,
@@ -153,6 +156,7 @@ $light-fluent-schema: (
153156
igx-grid-paginator: $_fluent-grid-pagination,
154157
igx-grid-summary: $_fluent-grid-summary,
155158
igx-grid-toolbar: $_fluent-grid-toolbar,
159+
igx-highlight: $_fluent-highlight,
156160
igx-icon: $_fluent-icon,
157161
igx-input-group: $_fluent-input-group,
158162
igx-list: $_fluent-list,

projects/igniteui-angular/src/lib/core/styles/themes/schemas/round-light/_index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@import '../light/grid-pagination';
2727
@import '../light/grid-summary';
2828
@import '../light/grid-toolbar';
29+
@import '../light/highlight';
2930
@import '../light/icon';
3031
@import '../light/input-group';
3132
@import '../light/list';
@@ -67,6 +68,7 @@
6768
/// @property {Map} igx-grid-paginator [$_light-grid-pagination]
6869
/// @property {Map} igx-grid-summary [$_light-grid-summary]
6970
/// @property {Map} igx-grid-toolbar [$_light-grid-toolbar]
71+
/// @property {Map} igx-highlight [$_light-highlight]
7072
/// @property {Map} igx-icon [$_light-icon]
7173
/// @property {Map} igx-input-group [$_light-input-group]
7274
/// @property {Map} igx-list [$_light-list]
@@ -108,6 +110,7 @@ $light-round-schema: (
108110
igx-grid-paginator: extend($_light-grid-pagination, $_round-shape-grid-pagination),
109111
igx-grid-summary: extend($_light-grid-summary, $_round-shape-grid-summary),
110112
igx-grid-toolbar: extend($_light-grid-toolbar, $_round-shape-tooltip),
113+
igx-highlight: $_light-highlight,
111114
igx-icon: extend($_light-icon, $_round-shape-icon),
112115
igx-input-group: extend($_light-input-group, $_round-shape-input-group),
113116
igx-list: extend($_light-list, $_round-shape-list),

0 commit comments

Comments
 (0)