Skip to content

Commit

Permalink
fix(theming): fix nb-theme not working in component mode without nb-i… (
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa committed May 27, 2019
1 parent 0ea3167 commit 0bc9f07
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/framework/theme/styles/_theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $nb-enabled-themes: () !global;
$nb-themes: () !global;

// private variables
$nb-theme-process-mode: null !global;
$nb-theme-name: 'default' !global;
$nb-theme-process-mode: 'lazy-process' !global;
$nb-theme-name: null !global;
$nb-theme: () !global;
$nb-processed-theme: () !global;
$nb-theme-export-mode: false !global !default;
Expand Down
11 changes: 11 additions & 0 deletions src/framework/theme/styles/core/theming/_get-value.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
@return $processed-theme;
}

@function get-current-theme-name() {
@if ($nb-theme-name != null) {
@return $nb-theme-name;
}

@return get-last-enabled-theme();
}

@function nb-theme($key) {

$value: ();
Expand All @@ -39,6 +47,9 @@

// otherwise lazily search for variable value
@if ($nb-theme-process-mode == 'lazy-process') {

$nb-theme-name: get-current-theme-name();

$theme: nb-get-registered-theme($nb-theme-name);
$value: nb-deep-find-value($theme, $key, map-get($theme, $key));
}
Expand Down
5 changes: 1 addition & 4 deletions src/framework/theme/styles/core/theming/_install.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@
$nb-theme-process-mode: 'pre-process' !global;

$nb-theme-name: $theme-name !global;
$nb-theme: nb-get-registered-theme($theme-name) !global;
$nb-processed-theme: nb-process-theme($nb-theme) !global;
$nb-processed-theme: nb-process-theme(nb-get-registered-theme($theme-name)) !global;
}

@mixin nb-lazy-process-context($theme-name) {
$nb-theme-process-mode: 'lazy-process' !global;

$nb-theme-name: $theme-name !global;
$nb-theme: nb-get-registered-theme($theme-name) !global;
$nb-processed-theme: () !global;
}

@mixin nb-install-component-with-css-props() {
// @breaking-change 5.0.0
@warn '`nb-install-component` is unnecessary with css properties. Deprecated and will be removed as of 5.0.0';
:host {
@content;
}
Expand Down
5 changes: 5 additions & 0 deletions src/framework/theme/styles/core/theming/_register.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
@return $nb-enabled-themes;
}

@function get-last-enabled-theme() {
$themes: nb-get-enabled-themes();
@return nth($themes, length($themes));
}

@function nb-set-for-export($theme, $name, $parent-name: null) {

$parent-theme: map-get($nb-themes-export, $parent-name);
Expand Down

0 comments on commit 0bc9f07

Please sign in to comment.