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] Setup semantic color tokens #8097

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ce1cee2
feat: add primitive and first level semantic color tokens
mgadewoll Oct 9, 2024
1d7e6b0
refactor: ensure semantic color tokens are available on the theme
mgadewoll Oct 23, 2024
d9d0928
chore: cleanup
mgadewoll Oct 23, 2024
b24e626
feat: add background and border tokens
mgadewoll Oct 14, 2024
a1fcc5f
feat: add util for retrieving a token name based on a dynamic variant
mgadewoll Oct 14, 2024
ec9a21b
refactor: update EUI background color usages
mgadewoll Oct 14, 2024
7025398
refactor: update EUI+ background token usages
mgadewoll Oct 14, 2024
9d45ecc
refactor: update background color usage in EUI docs
mgadewoll Oct 14, 2024
982fa34
refactor: return tokens from mixins and add deprecations
mgadewoll Oct 16, 2024
617caaf
refactor: update sass variables and add background sass vars
mgadewoll Oct 16, 2024
7a50f17
feat: add new base border value
mgadewoll Oct 16, 2024
1f4f63d
refactor: update border mixin usages
mgadewoll Oct 16, 2024
ee4c713
feat: update primitive token values
mgadewoll Oct 16, 2024
17b7dcd
reafactor: move button mixin file
mgadewoll Oct 17, 2024
29d58db
refactor: update paths
mgadewoll Oct 17, 2024
5c278a7
refactor: update token mappings and usages
mgadewoll Oct 20, 2024
fce2cf6
feat: support accentSecondary background variants
mgadewoll Oct 25, 2024
61e5bc9
feat: support accentSecondary variant for more components
mgadewoll Oct 25, 2024
052ab99
refactor: resolve most usages of shade and tint
mgadewoll Oct 21, 2024
2183b13
feat: add transparent color scale tokens
mgadewoll Oct 22, 2024
75350ef
refactor: resolve most usages of transparentize
mgadewoll Oct 22, 2024
e389571
refactor: update to form and switch color mapping
mgadewoll Oct 22, 2024
8f62f0d
refactor: add empty button background token to resolve usage of temp …
mgadewoll Oct 23, 2024
c3ce5da
refactor: remove TEMP_INTERNAL key
mgadewoll Oct 24, 2024
bcf3800
refactor: implement mapping changes
mgadewoll Oct 24, 2024
c980206
refactor: update sass tokens
mgadewoll Oct 24, 2024
2ee22d1
fix: typo
mgadewoll Oct 25, 2024
2a521d6
refactor: token changes + form token changes
mgadewoll Oct 25, 2024
e5c32ff
fix: revert unexpected body token change
mgadewoll Oct 26, 2024
7e59ef0
refactor: update primitive color tokens
mgadewoll Oct 28, 2024
faa7352
fix: update mutedBlack usage to blueBlack
mgadewoll Oct 28, 2024
b903199
refactor: update border mappings
mgadewoll Oct 28, 2024
70aa39a
fix: map accentSecondary to success in current theme
mgadewoll Oct 28, 2024
0869404
chore: renamae variable for more clarity
mgadewoll Oct 31, 2024
322fc90
refactor: flatten primitive color tokens
mgadewoll Oct 31, 2024
410fcd8
test: update test
mgadewoll Oct 31, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,24 @@ const getDemoActionsBarStyles = (euiTheme: UseEuiTheme) => {
&:last-child {
// border radius should be 1px smaller to work nicely
// with the wrapper border width of 1px
border-radius: 0 0 calc(var(--docs-demo-border-radius) - 1px) calc(var(--docs-demo-border-radius) - 1px);
border-radius: 0 0 calc(var(--docs-demo-border-radius) - 1px)
calc(var(--docs-demo-border-radius) - 1px);
}
`,
button: css`
background: var(--eui-background-color-primary-opaque);
background: var(--eui-background-color-primary);
border: 1px solid var(--eui-border-color-primary);
margin-right: auto;
`,
};
}
};

export const DemoActionsBar = ({
isSourceOpen,
setSourceOpen,
onClickOpenInCodeSandbox,
onClickReloadExample,
onClickCopyToClipboard
onClickCopyToClipboard,
}: DemoActionsBarProps) => {
const styles = useEuiMemoizedStyles(getDemoActionsBarStyles);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Props } from '@theme-original/EditThisPage';
import { EuiButton, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
// @ts-ignore - eui only has module declarations for '@elastic/eui/src/themes/amsterdam/global_styling/mixins/button'
// but importing from /src results in "Module not found" error
import { euiButtonColor } from '@elastic/eui/lib/themes/amsterdam/global_styling/mixins/button';
import { euiButtonColor } from '@elastic/eui/lib/global_styling/mixins/_button';

const getStyles = (theme: UseEuiTheme) => {
const { euiTheme } = theme;
Expand Down
141 changes: 67 additions & 74 deletions packages/docusaurus-theme/src/theme/Root.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
*/

import {
euiBorderColor,
euiFontSizeFromScale,
euiLineHeightFromBaseline,
useEuiBackgroundColor,
useEuiFocusRing,
UseEuiTheme,
} from '@elastic/eui';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -48,76 +45,72 @@ export const getGlobalStyles = (theme: UseEuiTheme) => {
const lineHeightXXS = euiLineHeightFromBaseline('xxs', euiTheme);

return css`
// color theme related variables
:root,
[data-theme='dark']:root {
/* EUI theme variables */
--eui-background-color-primary: ${useEuiBackgroundColor('primary')};
--eui-background-color-primary-opaque: ${useEuiBackgroundColor(
'primary',
{ method: 'opaque' }
)};
--eui-background-color-success: ${useEuiBackgroundColor('success')};
--eui-background-color-danger: ${useEuiBackgroundColor('danger')};
--eui-background-color-warning: ${useEuiBackgroundColor('warning')};
--eui-background-color-accent: ${useEuiBackgroundColor('accent')};

--eui-color-danger-text: ${euiTheme.colors.dangerText};

/* Docusaurus theme variables */
--ifm-background-color: ${colors.body};
--ifm-font-color-base: ${colors.text};
--ifm-link-color: ${colors.link};
--ifm-link-hover-color: ${colors.link};

--ifm-menu-color: ${euiTheme.colors.text};
--ifm-menu-color-background-active: ${euiTheme.colors.lightestShade};
--ifm-menu-color-background-hover: var(--eui-background-color-primary);

--ifm-pre-background: ${euiTheme.colors.lightestShade};
}

:root {
/* EUI theme variables */
--eui-font-size-base: ${fontBase.fontSize};
--eui-font-size-xxl: ${fontSizeXXL};
--eui-font-size-xl: ${fontSizeXL};
--eui-font-size-l: ${fontSizeL};
--eui-font-size-m: ${fontSizeM};
--eui-font-size-s: ${fontSizeS};
--eui-font-size-xs: ${fontSizeXS};
--eui-font-size-xxs: ${fontSizeXXS};

--eui-line-height-base: ${lineHeightXL};
--eui-line-height-xxl: ${lineHeightXXL};
--eui-line-height-xl: ${lineHeightXL};
--eui-line-height-l: ${lineHeightL};
--eui-line-height-m: ${lineHeightM};
--eui-line-height-s: ${lineHeightS};
--eui-line-height-xs: ${lineHeightXS};
--eui-line-height-xxs: ${lineHeightXXS};

--eui-size-xs: ${euiTheme.size.xs};
--eui-size-s: ${euiTheme.size.s};

--eui-border-color-primary: ${euiBorderColor(theme, 'primary')};

--eui-theme-content-vertical-spacing: ${euiTheme.size.base};

/* Docusaurus theme variables */
--ifm-font-family-base: ${fontBase.fontFamily};
--ifm-font-size-base: var(--eui-font-size-base);
--ifm-font-weight-base: ${fontBase.fontWeight};
--ifm-line-height-base: var(--eui-line-height-base);

--ifm-h1-font-size: var(--eui-font-size-xl);
--ifm-h2-font-size: var(--eui-font-size-l);
--ifm-h3-font-size: var(--eui-font-size-m);
--ifm-h4-font-size: var(--eui-font-size-s);
--ifm-h5-font-size: var(--eui-font-size-xs);
--ifm-h6-font-size: var(--eui-font-size-xxs);

--ifm-global-radius: ${euiTheme.border.radius.small};
}
// color theme related variables
:root,
[data-theme='dark']:root {
/* EUI theme variables */
--eui-background-color-primary: ${colors.backgroundBasePrimary};
--eui-background-color-success: ${colors.backgroundBaseSuccess};
--eui-background-color-danger: ${colors.backgroundBaseDanger};
--eui-background-color-warning: ${colors.backgroundBaseWarning};
--eui-background-color-accent: ${colors.backgroundBaseAccent};

--eui-color-danger-text: ${colors.textDanger};

/* Docusaurus theme variables */
--ifm-background-color: ${colors.backgroundBasePlain};
--ifm-font-color-base: ${colors.textParagraph};
--ifm-link-color: ${colors.link};
--ifm-link-hover-color: ${colors.link};

--ifm-menu-color: ${colors.textParagraph};
--ifm-menu-color-background-active: ${colors.backgroundBaseSubdued};
--ifm-menu-color-background-hover: var(--eui-background-color-primary);

--ifm-pre-background: ${colors.lightestShade};
}

:root {
/* EUI theme variables */
--eui-font-size-base: ${fontBase.fontSize};
--eui-font-size-xxl: ${fontSizeXXL};
--eui-font-size-xl: ${fontSizeXL};
--eui-font-size-l: ${fontSizeL};
--eui-font-size-m: ${fontSizeM};
--eui-font-size-s: ${fontSizeS};
--eui-font-size-xs: ${fontSizeXS};
--eui-font-size-xxs: ${fontSizeXXS};

--eui-line-height-base: ${lineHeightXL};
--eui-line-height-xxl: ${lineHeightXXL};
--eui-line-height-xl: ${lineHeightXL};
--eui-line-height-l: ${lineHeightL};
--eui-line-height-m: ${lineHeightM};
--eui-line-height-s: ${lineHeightS};
--eui-line-height-xs: ${lineHeightXS};
--eui-line-height-xxs: ${lineHeightXXS};

--eui-size-xs: ${size.xs};
--eui-size-s: ${size.s};

--eui-border-color-primary: ${colors.borderStrongPrimary};

--eui-theme-content-vertical-spacing: ${size.base};

/* Docusaurus theme variables */
--ifm-font-family-base: ${fontBase.fontFamily};
--ifm-font-size-base: var(--eui-font-size-base);
--ifm-font-weight-base: ${fontBase.fontWeight};
--ifm-line-height-base: var(--eui-line-height-base);

--ifm-h1-font-size: var(--eui-font-size-xl);
--ifm-h2-font-size: var(--eui-font-size-l);
--ifm-h3-font-size: var(--eui-font-size-m);
--ifm-h4-font-size: var(--eui-font-size-s);
--ifm-h5-font-size: var(--eui-font-size-xs);
--ifm-h6-font-size: var(--eui-font-size-xxs);

--ifm-global-radius: ${euiTheme.border.radius.small};
}
`;
};
2 changes: 1 addition & 1 deletion packages/eui-theme-borealis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "yarn tsc --noEmit && yarn lint-es && yarn lint-sass",
"lint-es": "eslint --cache src/**/*.ts --max-warnings 0",
"lint-sass": "yarn stylelint \"**/*.scss\" --quiet-deprecation-warnings",
"test": "jest",
"test": "jest ./src",
"pre-push": "yarn build:workspaces && yarn lint && yarn test"
},
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion packages/eui-theme-borealis/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

import { buildTheme, EuiThemeShape } from '@elastic/eui-theme-common';

import { colors } from './variables/_colors';
import { colors } from './variables/colors';
import { animation } from './variables/_animation';
import { breakpoint } from './variables/_breakpoint';
import { base, size } from './variables/_size';
import { border } from './variables/_borders';
import { levels } from './variables/_levels';
import { font } from './variables/_typography';
import { focus } from './variables/_states';
import { components } from './variables/_components';

export const EUI_THEME_BOREALIS_KEY = 'EUI_THEME_BOREALIS';

Expand All @@ -29,6 +30,7 @@ export const euiThemeBorealis: EuiThemeShape = {
breakpoint,
levels,
focus,
components,
};

export const EuiThemeBorealis = buildTheme(
Expand Down
6 changes: 3 additions & 3 deletions packages/eui-theme-borealis/src/theme_dark.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

// color mode specific variables
@import './variables/colors_dark';
@import './variables/colors/colors_dark';


// Global styling
@import 'node_modules/@elastic/eui-theme-common/src/global_styling/index';
@import './variables/index';
@import './variables/index';
@import 'node_modules/@elastic/eui-theme-common/src/global_styling/index';
6 changes: 3 additions & 3 deletions packages/eui-theme-borealis/src/theme_light.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// color mode specific variables
@import './variables/colors_light';
@import './variables/colors/colors_light';


// Global styling
@import 'node_modules/@elastic/eui-theme-common/src/global_styling/index';
@import './variables/index';
@import './variables/index';
@import 'node_modules/@elastic/eui-theme-common/src/global_styling/index';
3 changes: 3 additions & 0 deletions packages/eui-theme-borealis/src/variables/_borders.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Borders

$euiBorderColor: #00ff00 !default;
5 changes: 4 additions & 1 deletion packages/eui-theme-borealis/src/variables/_borders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
} from '@elastic/eui-theme-common';

export const border: _EuiThemeBorder = {
color: computed(([lightShade]) => lightShade, ['colors.lightShade']),
color: computed(
([borderBasePlain]) => borderBasePlain,
['colors.borderBasePlain']
),
width: {
thin: '1px',
thick: '2px',
Expand Down
22 changes: 18 additions & 4 deletions packages/eui-theme-borealis/src/variables/_buttons.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
$euiButtonColorDisabled: $euiColorDisabled;
$euiButtonColorDisabledText: $euiColorDisabledText;
$euiButtonDefaultTransparency: .8;
$euiButtonFontWeight: $euiFontWeightMedium;
$euiButtonHeight: $euiSizeXXL !default;
$euiButtonHeightSmall: $euiSizeXL !default;
$euiButtonHeightXSmall: $euiSizeL !default;

// Modifier naming and colors.
$euiButtonTypes: (
primary: $euiColorBackgroundFilledPrimary,
accent: $euiColorBackgroundFilledAccent,
success: $euiColorBackgroundFilledSuccess,
warning: $euiColorBackgroundFilledWarning,
danger: $euiColorBackgroundFilledDanger,
ghost: $euiColorGhost, // Ghost is special, and does not care about theming.
text: $euiColorBackgroundFilledText, // Reserved for special use cases
) !default;

// TODO: Remove this once elastic-charts no longer uses this variable
// @see https://github.com/elastic/elastic-charts/pull/2528
$euiButtonColorDisabledText: $euiColorTextDisabled;
Loading