Skip to content

Commit

Permalink
refactor(themes): separate mapping from theme (#1490)
Browse files Browse the repository at this point in the history
so that it is possible to import pure theme into the docs
  • Loading branch information
nnixaa authored and yggg committed May 27, 2019
1 parent 5673e98 commit c650ae0
Show file tree
Hide file tree
Showing 5 changed files with 1,695 additions and 1,673 deletions.
1 change: 1 addition & 0 deletions docs/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
$nb-theme-export-mode: true;

@import '../src/framework/theme/styles/theming';
@import '../src/framework/theme/styles/themes';
Expand Down
1 change: 1 addition & 0 deletions src/framework/theme/styles/_theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $nb-theme-process-mode: null !global;
$nb-theme-name: 'default' !global;
$nb-theme: () !global;
$nb-processed-theme: () !global;
$nb-theme-export-mode: false !global !default;
$nb-themes-export: () !global;

@import 'core/mixins';
Expand Down
14 changes: 13 additions & 1 deletion src/framework/theme/styles/core/theming/_register.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../themes/mapping';

/**
* @license
* Copyright Akveo. All Rights Reserved.
Expand All @@ -15,6 +17,12 @@
}

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

$parent-theme: map-get($nb-themes-export, $parent-name);
@if ($parent-theme != null) {
$theme: map-merge(map-get($parent-theme, data), $theme);
}

$theme-data: (
data: $theme,
parent: $parent-name,
Expand All @@ -37,6 +45,10 @@
// Registers a new theme
@function nb-register-theme($theme, $name, $parent-name: null) {

@if ($nb-theme-export-mode == true) {
$nb-themes-export: nb-set-for-export($theme, $name, $parent-name) !global;
}

$theme-data: ();

@if ($parent-name != null) {
Expand All @@ -46,8 +58,8 @@
}
$theme: map-merge($parent-theme, $theme);
}
$theme: map-merge($eva-mapping, $theme);
$nb-themes: map-set($nb-themes, $name, $theme) !global;
$nb-themes-export: nb-set-for-export($theme, $name, $parent-name) !global;

@return $nb-themes;
}
Loading

0 comments on commit c650ae0

Please sign in to comment.