Skip to content
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

[Visual Refresh] Add Borealis theme #199993

Merged
merged 16 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added elastic_eui_97.3.1_borealis_prerelease_001.tgz
tkajtoch marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.15.2",
"@elastic/ems-client": "8.5.3",
"@elastic/eui": "97.3.1",
"@elastic/eui": "97.3.1-borealis.2",
"@elastic/eui-theme-borealis": "0.0.2",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "^1.2.3",
"@elastic/numeral": "^2.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,44 @@
*/

import React, { FC } from 'react';
import type { DarkModeValue } from '@kbn/core-ui-settings-common';
import { type DarkModeValue, ThemeName } from '@kbn/core-ui-settings-common';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of ThemeName is now string but will get stricter in follow-up PRs


interface Props {
darkMode: DarkModeValue;
themeName: ThemeName;
stylesheetPaths: string[];
}

export const Styles: FC<Props> = ({ darkMode, stylesheetPaths }) => {
export const Styles: FC<Props> = ({ darkMode, themeName, stylesheetPaths }) => {
return (
<>
{darkMode !== 'system' && <InlineStyles darkMode={darkMode} />}
{darkMode !== 'system' && <InlineStyles darkMode={darkMode} themeName={themeName} />}
{stylesheetPaths.map((path) => (
<link key={path} rel="stylesheet" type="text/css" href={path} />
))}
</>
);
};

const InlineStyles: FC<{ darkMode: boolean }> = ({ darkMode }) => {
const InlineStyles: FC<{ darkMode: boolean; themeName: ThemeName }> = ({ darkMode, themeName }) => {
const getThemeStyles = (theme: ThemeName) => {
if (theme === 'borealis') {
return {
pageBackground: darkMode ? '#07101F' : '#F6F9FC', // colors.body
welcomeText: darkMode ? '#8E9FBC' : '#5A6D8C', // colors.subduedText
progress: darkMode ? '#172336' : '#ECF1F9', // colors.lightestShade
progressBefore: darkMode ? '#599DFF' : '#0B64DD', // colors.primary
};
}

return {
pageBackground: darkMode ? '#141519' : '#F8FAFD',
welcomeText: darkMode ? '#98A2B3' : '#69707D',
progress: darkMode ? '#25262E' : '#F5F7FA',
progressBefore: darkMode ? '#1BA9F5' : '#006DE4',
};
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
};

// must be kept in sync with
// packages/core/apps/core-apps-server-internal/assets/legacy_theme.js
/* eslint-disable react/no-danger */
Expand All @@ -36,19 +55,19 @@ const InlineStyles: FC<{ darkMode: boolean }> = ({ darkMode }) => {
__html: `

html {
background-color: ${darkMode ? '#141519' : '#F8FAFD'}
background-color: ${getThemeStyles(themeName).pageBackground}
}

.kbnWelcomeText {
color: ${darkMode ? '#98A2B3' : '#69707D'};
color: ${getThemeStyles(themeName).welcomeText};
}

.kbnProgress {
background-color: ${darkMode ? '#25262E' : '#F5F7FA'};
background-color: ${getThemeStyles(themeName).progress};
}

.kbnProgress:before {
background-color: ${darkMode ? '#1BA9F5' : '#006DE4'};
background-color: ${getThemeStyles(themeName).progressBefore};
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
}

`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export const Template: FunctionComponent<Props> = ({
{/* Inject EUI reset and global styles before all other component styles */}
<meta name={EUI_STYLES_GLOBAL} />
<meta name="emotion" />
<Styles darkMode={darkMode} stylesheetPaths={stylesheetPaths} />
<Styles
darkMode={darkMode}
themeName={injectedMetadata.theme.name}
stylesheetPaths={stylesheetPaths}
/>
{scriptPaths.map((path) => (
<script key={path} src={path} />
))}
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a slight issue with the aggs-based visualization tooltips. They used to be dark even for light theme so I can tweaks this in a follow-up to work with the new themes.

Before

image

After

image

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export function parseThemeTags(input?: unknown): ThemeTags {
return DEFAULT_THEME_TAGS;
}

// TODO: remove when Borealis is in public beta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create an issue for this to not forget to remove this condition? And then update the comment with the link to the issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely! I'm going to create an issue shortly and will update the comment in a follow-up PR so that we don't need to wait for CI to pass again. Thanks for catching it!

if (input === 'experimental') {
return SUPPORTED_THEME_TAGS;
}

let rawTags: string[];
if (typeof input === 'string') {
rawTags = input.split(',').map((tag) => tag.trim());
Expand Down
17 changes: 10 additions & 7 deletions packages/kbn-eslint-config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,16 @@ module.exports = {
exclude: USES_STYLED_COMPONENTS,
disallowedMessage: `Prefer using @emotion/react instead. To use styled-components, ensure you plugin is enabled in packages/kbn-babel-preset/styled_components_files.js.`,
},
...['@elastic/eui/dist/eui_theme_light.json', '@elastic/eui/dist/eui_theme_dark.json'].map(
(from) => ({
from,
to: false,
disallowedMessage: `Use "@kbn/ui-theme" to access theme vars.`,
})
),
...[
'@elastic/eui/dist/eui_theme_amsterdam_light.json',
'@elastic/eui/dist/eui_theme_amsterdam_dark.json',
'@elastic/eui/dist/eui_theme_borealis_light.json',
'@elastic/eui/dist/eui_theme_borealis_dark.json',
].map((from) => ({
from,
to: false,
disallowedMessage: `Use "@kbn/ui-theme" to access theme vars.`,
})),
{
from: '@kbn/test/jest',
to: '@kbn/test-jest-helpers',
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pageLoadAssetSize:
actions: 20000
advancedSettings: 27596
aiAssistantManagementSelection: 19146
aiops: 16600
aiops: 16670
alerting: 106936
apm: 64385
banners: 17946
Expand Down Expand Up @@ -31,7 +31,7 @@ pageLoadAssetSize:
dataUsage: 30000
dataViewEditor: 28082
dataViewFieldEditor: 42021
dataViewManagement: 5300
dataViewManagement: 5370
dataViews: 65000
dataVisualizer: 30000
devTools: 38637
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-ui-shared-deps-npm/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ module.exports = (_, argv) => {
'@elastic/eui/optimize/es/components/provider/nested',
'@elastic/eui/optimize/es/services',
'@elastic/eui/optimize/es/services/format',
'@elastic/eui/dist/eui_theme_light.json',
'@elastic/eui/dist/eui_theme_dark.json',
'@elastic/eui/dist/eui_theme_amsterdam_light.json',
'@elastic/eui/dist/eui_theme_amsterdam_dark.json',
'@elastic/eui/dist/eui_theme_borealis_light.json',
'@elastic/eui/dist/eui_theme_borealis_dark.json',
'@elastic/numeral',
'@emotion/cache',
'@emotion/react',
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-ui-shared-deps-src/src/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const externals = {
'__kbnSharedDeps__.ElasticEuiLibComponentsUseIsNestedEuiProvider',
'@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices',
'@elastic/eui/lib/services/format': '__kbnSharedDeps__.ElasticEuiLibServicesFormat',
'@elastic/eui-theme-borealis': '__kbnSharedDeps__.ElasticEuiThemeBorealis',

// transient dep of eui
'@hello-pangea/dnd': '__kbnSharedDeps__.HelloPangeaDnd',
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-ui-shared-deps-src/src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const Rxjs = require('rxjs');
export const ElasticNumeral = require('@elastic/numeral');
export const ElasticCharts = require('@elastic/charts');
export const ElasticEui = require('@elastic/eui');
export const ElasticEuiThemeBorealis = require('@elastic/eui-theme-borealis');
export const ElasticEuiLibComponentsUseIsNestedEuiProvider = require('@elastic/eui/optimize/es/components/provider/nested');
export const ElasticEuiLibServices = require('@elastic/eui/optimize/es/services');
export const ElasticEuiLibServicesFormat = require('@elastic/eui/optimize/es/services/format');
Expand Down
46 changes: 35 additions & 11 deletions packages/kbn-ui-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

// TODO(tkajtoch): Add support for multiple themes
/* eslint-disable-next-line @kbn/eslint/module_migration */
import { default as v8Light } from '@elastic/eui/dist/eui_theme_amsterdam_light.json';
/* eslint-disable-next-line @kbn/eslint/module_migration */
import { default as v8Dark } from '@elastic/eui/dist/eui_theme_amsterdam_dark.json';

/* eslint-disable-next-line @kbn/eslint/module_migration */
import { default as v8Light } from '@elastic/eui/dist/eui_theme_light.json';
import { default as borealisLight } from '@elastic/eui/dist/eui_theme_borealis_light.json';
/* eslint-disable-next-line @kbn/eslint/module_migration */
import { default as v8Dark } from '@elastic/eui/dist/eui_theme_dark.json';
import { default as borealisDark } from '@elastic/eui/dist/eui_theme_borealis_dark.json';

const globals: any = typeof window === 'undefined' ? {} : window;

Expand All @@ -27,19 +30,40 @@ export const version = 8;
/** @deprecated theme can be dynamic now, access is discouraged */
export const darkMode = tag.endsWith('dark');

export const euiLightVars: Theme = v8Light;
export const euiDarkVars: Theme = v8Dark;

let isDarkMode = darkMode;
export const _setDarkMode = (mode: boolean) => {
isDarkMode = mode;
};

const getThemeVars = (): { light: Theme; dark: Theme } => {
if (globals?.__kbnThemeTag__?.includes('borealis')) {
return {
light: borealisLight,
dark: borealisDark,
};
}

return {
light: v8Light,
dark: v8Dark,
};
};

export const euiLightVars: Theme = getThemeVars().light;
export const euiDarkVars: Theme = getThemeVars().dark;

/**
* EUI Theme vars that automatically adjust to light/dark theme
*/
export const euiThemeVars: Theme = new Proxy(isDarkMode ? euiDarkVars : euiLightVars, {
get(accessedTarget, accessedKey, ...rest) {
return Reflect.get(isDarkMode ? euiDarkVars : euiLightVars, accessedKey, ...rest);
},
});
export const euiThemeVars: Theme = new Proxy(
isDarkMode ? getThemeVars().dark : getThemeVars().light,
{
get(accessedTarget, accessedKey, ...rest) {
return Reflect.get(
isDarkMode ? getThemeVars().dark : getThemeVars().light,
accessedKey,
...rest
);
},
}
);
4 changes: 4 additions & 0 deletions packages/react/kibana_context/common/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { EuiThemeSystem, EuiThemeAmsterdam } from '@elastic/eui';
import { EuiThemeBorealis } from '@elastic/eui-theme-borealis';

export interface ThemeConfig {
euiTheme: EuiThemeSystem;
Expand All @@ -17,6 +18,9 @@ const THEMES: Record<string, ThemeConfig> = {
amsterdam: {
euiTheme: EuiThemeAmsterdam,
},
borealis: {
euiTheme: EuiThemeBorealis,
},
};

export const getThemeConfigByName = (name: string): ThemeConfig | null => {
Expand Down
9 changes: 9 additions & 0 deletions src/core/public/styles/core_app/_globals_borealisdark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// v9 borealis theme global scope
//
// prepended to all .scss imports (from JS, when borealis dark theme selected)

@import '@elastic/eui-theme-borealis/src/theme_dark.scss';

@import './mixins';

$kbnThemeVersion: 'borealisdark';
9 changes: 9 additions & 0 deletions src/core/public/styles/core_app/_globals_borealislight.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// v9 borealis theme global scope
//
// prepended to all .scss imports (from JS, when borealis light theme selected)

@import '@elastic/eui-theme-borealis/src/theme_light.scss';

@import './mixins';

$kbnThemeVersion: 'borealislight';
3 changes: 2 additions & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const LICENSE_OVERRIDES = {
'[email protected]': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/[email protected]': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/[email protected]': ['Elastic License 2.0'],
'@elastic/[email protected]': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'@elastic/[email protected]': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'@elastic/[email protected]': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'[email protected]': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
'[email protected]': ['MIT'], // license in importing module https://www.npmjs.com/package/binary
'@bufbuild/[email protected]': ['Apache-2.0'], // license (Apache-2.0 AND BSD-3-Clause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
}

&--securitySolution img {
background-color: $euiColorSuccess;
background-color: $euiColorAccentSecondary;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading