Skip to content

Commit

Permalink
Amsterdam helpers (elastic#93701)
Browse files Browse the repository at this point in the history
* Adds kbnThemeStyle mixin

* Update src/core/public/core_app/styles/_mixins.scss

Co-authored-by: Caroline Horn <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Caroline Horn <[email protected]>
  • Loading branch information
3 people authored Mar 10, 2021
1 parent f428b10 commit 804c862
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rules:
- return
- for
- at-root
- warn
comment-no-empty: true
no-duplicate-at-import-rules: true
no-duplicate-selectors: true
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/core_app/styles/_globals_v7dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
@import '@elastic/eui/src/themes/eui/eui_globals';

@import './mixins';

$kbnThemeVersion: 'v7dark';
2 changes: 2 additions & 0 deletions src/core/public/core_app/styles/_globals_v7light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
@import '@elastic/eui/src/themes/eui/eui_globals';

@import './mixins';

$kbnThemeVersion: 'v7light';
2 changes: 2 additions & 0 deletions src/core/public/core_app/styles/_globals_v8dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
@import '@elastic/eui/src/themes/eui-amsterdam/eui_amsterdam_globals';

@import './mixins';

$kbnThemeVersion: 'v8dark';
2 changes: 2 additions & 0 deletions src/core/public/core_app/styles/_globals_v8light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
@import '@elastic/eui/src/themes/eui-amsterdam/eui_amsterdam_globals';

@import './mixins';

$kbnThemeVersion: 'v8light';
28 changes: 28 additions & 0 deletions src/core/public/core_app/styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,31 @@
}
}
}

@mixin kbnThemeStyle($theme, $mode: 'both') {
$themes: 'v7', 'v8';
@if (index($themes, $theme)) {
@if ($mode == 'both') {
$themeLight: $theme + 'light';
$themeDark: $theme + 'dark';
// $kbnThemeVersion comes from the active theme's globals file (e.g. _globals_v8light.scss)
@if ($kbnThemeVersion == $themeLight or $kbnThemeVersion == $themeDark) {
@content;
}
} @else if ($mode == 'light') {
$themeLight: $theme + 'light';
@if ($kbnThemeVersion == $themeLight) {
@content;
}
} @else if ($mode == 'dark') {
$themeDark: $theme + 'dark';
@if ($kbnThemeVersion == $themeDark) {
@content;
}
} @else {
@warn 'The second parameter must be a valid mode (light, dark, or both) -- got #{$mode}';
}
} @else {
@warn 'Invalid $theme. Valid options are: #{$themes}. Got #{$theme} instead';
}
}

0 comments on commit 804c862

Please sign in to comment.