-
Notifications
You must be signed in to change notification settings - Fork 156
refactor(elements): component theme cb to update name/prefix and selector #12974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
damyanpetev
merged 8 commits into
angular-elements
from
dpetev/elements-theme-shenanigans
Jun 21, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ad81d7
refactor(themes): add an internal handler option to transform theme maps
damyanpetev 8e0f62a
refactor(elements): [WIP] component theme cb to update name/prefix an…
damyanpetev 951d0c8
Merge remote-tracking branch 'origin/angular-elements' into dpetev/el…
damyanpetev 280860b
refactor(elements): cleanup leftover selector changes, elements theme…
damyanpetev 0388e26
refactor(elements): update all themes, more cleanup
damyanpetev d4b51d1
Merge remote-tracking branch 'origin/angular-elements' into dpetev/el…
damyanpetev bf3c378
chore(elements): cleanup theme debug logs
damyanpetev 16776e4
fix(elements): pass correct theme schema
damyanpetev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
projects/igniteui-angular-elements/src/themes/_util.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| @use 'sass:map'; | ||
| @use 'sass:meta'; | ||
| @use 'sass:string'; | ||
| @use 'sass:list'; | ||
| @use '../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use './variables' as vars; | ||
|
|
||
| /// Prefix used for 'global' component CSS vars | ||
| $elements-var-prefix: 'ig'; | ||
|
|
||
| /// Prefix used in place of `igx-` in component selectors | ||
| $elements-selector-prefix: 'igc'; | ||
|
|
||
| /// Filter out included items to get exclude list | ||
| /// @access private | ||
| /// @param {Map} $items - The items to include | ||
| /// @param {Map} $register - The full components list `igx.$components` | ||
| /// @return {Map} - The resulting difference of items for excluding | ||
| @function include($items, $register) { | ||
| // @debug map.keys(igx.$components); | ||
| @return map.keys(map.remove($register, $items...)); | ||
| } | ||
|
|
||
| /// Callback to update component's name (for var prefix) and selectors for Elements | ||
| /// @access private | ||
| /// @param {Map} $theme_schema - The component's theme schema | ||
| /// @return {Map} - Updated component theme schema | ||
| @function updateElementName($theme_schema) { | ||
| $prefix: 'ig'; | ||
| $result: $theme_schema; | ||
|
|
||
| @if map.has-key($theme_schema, "name") { | ||
| $name: map.get($theme_schema, "name"); | ||
| $selector: map.get($theme_schema, "selector") or $name; | ||
|
|
||
| // @debug "name: #{$name}"; | ||
|
|
||
| @if string.index($name, 'igx-') { | ||
| $name: list.nth(string.split($name, 'igx-'), -1); | ||
| $name: '#{$elements-var-prefix}-#{$name}'; | ||
| // @debug "name after: #{$name}"; | ||
| } | ||
|
|
||
| // For exposed components also modify selector with updated element prefix: | ||
| @if list.index(vars.$allowed, map.get($theme_schema, "name")) { | ||
| // @debug "selector before: #{$selector}"; | ||
| $selector: updateSelectors($selector); | ||
| // @debug "selector after: #{$selector}";; | ||
| } | ||
|
|
||
| $result: map.merge($result, (name: $name, selector: $selector)); | ||
| } | ||
| @return $result; | ||
| } | ||
|
|
||
| /// Break down the selector and update `igx-` element selectors with matching `igc-` for exposed Elements | ||
| /// @access private | ||
| /// @param {String} $selector - The selector(s) to update | ||
| /// @return {String} - Updated selector(s) with `igc-` prefixed equivalents | ||
| @function updateSelectors($selector) { | ||
| $result: (); | ||
| $selectors: string.split($selector, ", "); | ||
|
|
||
| @each $sel in $selectors { | ||
| $result: list.append($result, $sel, comma); | ||
|
|
||
| @if string.index($sel, 'igx-') == 1 { | ||
| $igc-sel: list.nth(string.split($sel, 'igx-'), -1); | ||
| $igc-sel: '#{$elements-selector-prefix}-#{$igc-sel}'; | ||
| $result: list.append($result, $igc-sel, comma); | ||
| } | ||
| } | ||
|
|
||
| @return "#{$result}"; | ||
| } | ||
|
|
||
| /// Generates an Ignite UI for Angular Elements global theme. | ||
| /// @param {Map} $palette - An palette to be used by the global theme. | ||
| /// @param {Map} $schema [$light-schema] - The schema used as basis for styling the components. | ||
| /// @param {List} $exclude [( )] - A list of igx components to be excluded from the global theme styles. | ||
| /// @param {Number} $roundness [null] - Sets the global roundness factor (the value can be any decimal fraction between 0 and 1) for all components. | ||
| /// @param {Boolean} $elevation [true] - Turns on/off elevations for all components in the theme. | ||
| /// @param {Map} $elevations [$elevations] - The elevation map to be used by all component themes. | ||
| /// @requires $light-material-schema | ||
| /// @requires {function} is-component | ||
| /// @requires {function} is-used | ||
| @mixin elements-theme( | ||
| $palette, | ||
| $schema, | ||
| $exclude, | ||
| // $roundness, | ||
| // $elevation, | ||
| // $elevations, | ||
| ) { | ||
| @include igx.theme-internal( | ||
| $palette: $palette, | ||
| $exclude: $exclude, | ||
| $schema: $schema, | ||
| $theme-handler: meta.get-function("updateElementName") | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
projects/igniteui-angular-elements/src/themes/dark/bootstrap.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,19 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$dark-bootstrap-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$bootstrap-typeface, $type-scale: igx.$bootstrap-type-scale); | ||
| @include igx.bootstrap-dark-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$dark-bootstrap-schema, | ||
| ); | ||
|
|
11 changes: 10 additions & 1 deletion
11
projects/igniteui-angular-elements/src/themes/dark/fluent.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,19 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$dark-fluent-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$fluent-typeface, $type-scale: igx.$fluent-type-scale); | ||
| @include igx.fluent-dark-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$dark-fluent-schema, | ||
| ); | ||
|
|
10 changes: 9 additions & 1 deletion
10
projects/igniteui-angular-elements/src/themes/dark/indigo.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$dark-indigo-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$indigo-typeface, $type-scale: igx.$indigo-type-scale); | ||
| @include igx.indigo-dark-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$dark-indigo-schema, | ||
| ); |
10 changes: 9 additions & 1 deletion
10
projects/igniteui-angular-elements/src/themes/dark/material.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$dark-material-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$material-typeface, $type-scale: igx.$material-type-scale); | ||
| @include igx.dark-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$dark-material-schema, | ||
| ); |
11 changes: 9 additions & 2 deletions
11
projects/igniteui-angular-elements/src/themes/light/bootstrap.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,17 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$light-bootstrap-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$bootstrap-typeface, $type-scale: igx.$bootstrap-type-scale); | ||
| @include igx.bootstrap-light-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$light-bootstrap-schema, | ||
| ); | ||
10 changes: 9 additions & 1 deletion
10
projects/igniteui-angular-elements/src/themes/light/fluent.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$light-fluent-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$fluent-typeface, $type-scale: igx.$fluent-type-scale); | ||
| @include igx.fluent-light-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$light-fluent-schema, | ||
| ); |
11 changes: 10 additions & 1 deletion
11
projects/igniteui-angular-elements/src/themes/light/indigo.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,19 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$light-indigo-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$indigo-typeface, $type-scale: igx.$indigo-type-scale); | ||
| @include igx.indigo-light-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$light-indigo-schema, | ||
| ); | ||
|
|
10 changes: 9 additions & 1 deletion
10
projects/igniteui-angular-elements/src/themes/light/material.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| /* You can add global styles to this file, and also import other style files */ | ||
| @use '../../../../igniteui-angular/src/lib/core/styles/themes' as igx; | ||
| @use '../variables' as vars; | ||
| @use '../util' as util; | ||
| @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); | ||
|
|
||
| $palette: igx.$light-material-palette; | ||
|
|
||
| @include igx.core(); | ||
| @include igx.typography($font-family: igx.$material-typeface, $type-scale: igx.$material-type-scale); | ||
| @include igx.light-theme($palette: $palette, $exclude: vars.$unused-themes); | ||
|
|
||
| @include util.elements-theme( | ||
| $palette: $palette, | ||
| // TODO: adjust dependencies | ||
| // $exclude: util.include(vars.$allowed, igx.$components), | ||
| $exclude: vars.$unused-themes, | ||
| $schema: igx.$light-material-schema, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only concern from moving away from using
bootstrap-light-themeand so on - that mixin seems to do something extra, rather than using thelight-bootstrap-palettedirectly for some reason:igniteui-angular/projects/igniteui-angular/src/lib/core/styles/themes/generators/_bootstrap.scss
Lines 33 to 34 in 91669a6
Kinda odd