Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1f77bf7
[EuiProvider][EuiThemeProvider] `highContrastMode` set up and documen…
cee-chen Nov 21, 2024
2ade74c
Remove `no-extra-semicolons` stylelint rule
cee-chen Nov 12, 2024
c5696ec
[High Contrast Mode] Panels, modals, flyouts, toasts, popovers, and t…
cee-chen Nov 27, 2024
3d45f5b
[High Contrast Mode] Form controls (#8193)
cee-chen Dec 2, 2024
a7bfe92
[High Contrast Mode] Ranges, color pickers, and date pickers (#8199)
cee-chen Dec 5, 2024
6222262
[High Contrast Mode] Allow forced high contrast themes to also force …
cee-chen Dec 4, 2024
40c475e
[High contrast mode] DRY utilities (#8205)
cee-chen Dec 6, 2024
e9f4340
[High Contrast Mode] Buttons, datepicker redux, code blocks, and avat…
cee-chen Dec 10, 2024
f1c9517
[High Contrast Mode] Horizontal rules, side navs, tabs, and breadcrum…
cee-chen Dec 11, 2024
191a646
[High Contrast Mode] Loading components and beacons (#8215)
cee-chen Dec 11, 2024
439fcc5
[High Contrast Mode] Markdown, highlighting, misc text fixes (#8219)
cee-chen Dec 11, 2024
3bbdf93
[High Contrast Mode] EuiKeyPadMenu, EuiImage, EuiOverlayMask, EuiBott…
cee-chen Dec 12, 2024
c946559
[High Contrast Mode] Steps, timelines, and comment lists (#8223)
cee-chen Dec 12, 2024
dff3f77
[High Contrast Mode] Tables and data grid (#8226)
cee-chen Dec 12, 2024
2a94f49
Update changelog file
cee-chen Dec 12, 2024
6c8cf71
[PR feedback] Changelog typo
cee-chen Dec 12, 2024
c248569
[High Contrast Mode] new_final_final(2).psd (#8234)
cee-chen Dec 13, 2024
ad8f0b1
chore: rebase cleanup
mgadewoll Mar 14, 2025
eafb00a
chore: update token usages of renamed tokens in EUI
mgadewoll Mar 14, 2025
4c9994d
refactor: additional high contrast adjustments
mgadewoll Mar 14, 2025
95961b1
test: update tests and snapshots
mgadewoll Mar 14, 2025
67f36a4
test(vrt): update reference images with Borealis
mgadewoll Mar 14, 2025
85e9405
refactor(switch): fine tune high contrast border styles
mgadewoll Mar 14, 2025
e895d15
docs(eui+): add high contrast mode toggle support
mgadewoll Mar 14, 2025
261c92d
chore: cleanup incorrectly added styles
mgadewoll Mar 14, 2025
ccdf738
chore: update changelog
mgadewoll Mar 14, 2025
abb3236
refactor: align updated panel styles with high contrast mode
mgadewoll Mar 18, 2025
753f3b0
test(vrt): update reference images
mgadewoll Mar 18, 2025
7d82e15
test(vrt) update loading chart reference images
mgadewoll Mar 18, 2025
9855680
chore: rebase cleanup
mgadewoll Mar 20, 2025
f7787e9
chore: export high contrast mode styling utils
mgadewoll Mar 20, 2025
1471ac2
docs: update highContrastModeStyles imports
mgadewoll Mar 20, 2025
515de4c
refactor: ensure global search uses default border token in HCM
mgadewoll Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Remove or strikethrough items that do not apply to your PR.

- Browser QA
- [ ] Checked in both **light and dark** modes
- [ ] Checked in both [MacOS](https://support.apple.com/lv-lv/guide/mac-help/unac089/mac) and [Windows](https://support.microsoft.com/en-us/windows/turn-high-contrast-mode-on-or-off-in-windows-909e9d89-a0f9-a3a9-b993-7a6dcee85025) **high contrast modes**
- (_[emulate forced colors](https://devtoolstips.org/tips/en/emulate-forced-colors/) if you do not have access to a Windows machine_.)
- [ ] Checked in **mobile**
- [ ] Checked in **Chrome**, **Safari**, **Edge**, and **Firefox**
- [ ] Checked for **accessibility** including keyboard-only and screenreader modes
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme/src/components/demo/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DemoProps extends PropsWithChildren {

const getDemoStyles = (euiTheme: UseEuiTheme) => ({
demo: css`
--docs-demo-border-color: ${euiTheme.euiTheme.colors.lightShade};
--docs-demo-border-color: ${euiTheme.euiTheme.border.color};
--docs-demo-border-radius: ${euiTheme.euiTheme.size.s};

border: 1px solid var(--docs-demo-border-color);
Expand Down
50 changes: 33 additions & 17 deletions packages/docusaurus-theme/src/components/guideline/guideline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
EuiPanelProps,
useEuiMemoizedStyles,
UseEuiTheme,
highContrastModeStyles,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { GuidelineType } from './types';
Expand All @@ -17,23 +18,38 @@ export interface GuidelineProps extends PropsWithChildren {
panelStyle?: EuiPanelProps['style'];
}

const getGuidelineStyles = ({ euiTheme }: UseEuiTheme) => ({
root: css`
margin-block: var(--eui-theme-content-vertical-spacing);
`,
wrapper: css`
border-block-end: 2px solid ${euiTheme.colors.lightShade};
`,
wrapperDo: css`
border-color: ${euiTheme.colors.success};
`,
wrapperDont: css`
border-color: ${euiTheme.colors.danger};
`,
textWrapper: css`
margin-block-start: var(--eui-size-xs);
`,
});
const getGuidelineStyles = (euiThemeContext: UseEuiTheme) => {
const { euiTheme } = euiThemeContext;
return {
root: css`
margin-block: var(--eui-theme-content-vertical-spacing);
`,
wrapper: css`
border-block-end: ${euiTheme.border.thick};
border-start-start-radius: ${euiTheme.border.radius.medium};
border-start-end-radius: ${euiTheme.border.radius.medium};
overflow: hidden;

${highContrastModeStyles(euiThemeContext, {
// Code block is used within a panel which already has a border - skip doubling up
preferred: `
& > .euiCodeBlock {
border: none;
}
`,
})}
`,
wrapperDo: css`
border-color: ${euiTheme.colors.success};
`,
wrapperDont: css`
border-color: ${euiTheme.colors.danger};
`,
textWrapper: css`
margin-block-start: var(--eui-size-xs);
`,
};
};

export const Guideline = ({
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import {
EUI_THEME,
EuiProvider,
EuiThemeAmsterdam,
EuiThemeColorMode,
Expand All @@ -29,10 +30,19 @@ export const AVAILABLE_THEMES = [

const EUI_COLOR_MODES = ['light', 'dark'] as EuiThemeColorMode[];

const defaultState = {
const defaultState: {
colorMode: EuiThemeColorMode;
highContrastMode: boolean | undefined;
theme: EUI_THEME;
changeColorMode: (colorMode: EuiThemeColorMode) => void;
changeHighContrastMode: (highContrastMode: boolean) => void;
changeTheme: (themeValue: string) => void;
} = {
colorMode: EUI_COLOR_MODES[0] as EuiThemeColorMode,
changeColorMode: (colorMode: EuiThemeColorMode) => {},
highContrastMode: undefined,
theme: AVAILABLE_THEMES[0]!,
changeColorMode: (colorMode: EuiThemeColorMode) => {},
changeHighContrastMode: (highContrastMode: boolean) => {},
changeTheme: (themeValue: string) => {},
};

Expand All @@ -45,14 +55,26 @@ export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
const [colorMode, setColorMode] = useState<EuiThemeColorMode>(() => {
if (isBrowser) {
return (
(localStorage.getItem('theme') as EuiThemeColorMode) ??
(localStorage.getItem('colorMode') as EuiThemeColorMode) ??
defaultState.colorMode
);
}

return defaultState.colorMode;
});

const [highContrastMode, setHighContrastMode] = useState<boolean | undefined>(
() => {
if (isBrowser) {
return localStorage.getItem('highContrastMode')
? localStorage.getItem('highContrastMode') === 'true'
: defaultState.highContrastMode;
}

return defaultState.highContrastMode;
}
);

const [theme, setTheme] = useState(defaultState.theme);

const handleChangeTheme = (themeValue: string) => {
Expand All @@ -61,12 +83,19 @@ export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
setTheme((currentTheme) => themeObj ?? currentTheme);
};

const handleChangeHighContrastMode = (highContrastMode: boolean) => {
localStorage.setItem('highContrastMode', highContrastMode.toString());
setHighContrastMode(highContrastMode);
};

return (
<AppThemeContext.Provider
value={{
colorMode,
highContrastMode,
theme,
changeColorMode: setColorMode,
changeHighContrastMode: handleChangeHighContrastMode,
changeTheme: handleChangeTheme,
}}
>
Expand All @@ -75,6 +104,7 @@ export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
modify={EuiThemeOverrides}
colorMode={colorMode}
theme={theme.provider}
highContrastMode={highContrastMode}
>
{children}
</EuiProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import {
EuiAvatar,
EuiButtonEmpty,
euiFocusRing,
EuiHorizontalRule,
EuiListGroup,
EuiListGroupItem,
EuiPopover,
EuiPopoverFooter,
EuiSwitch,
EuiSwitchEvent,
useEuiMemoizedStyles,
useEuiTheme,
UseEuiTheme,
Expand All @@ -33,12 +37,21 @@ const getStyles = (euiThemeContext: UseEuiTheme) => {
};

export const ThemeSwitcher = () => {
const { euiTheme } = useEuiTheme();
const euiThemeContext = useEuiTheme();
const { euiTheme } = euiThemeContext;

const [currentTheme, setCurrentTheme] = useState(
AVAILABLE_THEMES[0]?.value ?? ''
);
const [isPopoverOpen, setPopoverOpen] = useState(false);
const { theme, changeTheme } = useContext(AppThemeContext);
const appContext = useContext(AppThemeContext);
const { theme, changeTheme, changeHighContrastMode } = appContext;

const isForcedContrastMode = euiThemeContext.highContrastMode === 'forced';
const _highContrastMode =
appContext.colorMode && !isForcedContrastMode
? appContext.highContrastMode
: euiThemeContext.highContrastMode;

useEffect(() => {
changeTheme(currentTheme);
Expand All @@ -63,7 +76,7 @@ export const ThemeSwitcher = () => {
isOpen={isPopoverOpen}
closePopover={() => setPopoverOpen(false)}
button={button}
panelPaddingSize="xs"
panelPaddingSize="none"
repositionOnScroll
aria-label="EUI theme list"
>
Expand All @@ -89,6 +102,17 @@ export const ThemeSwitcher = () => {
);
})}
</EuiListGroup>
<EuiPopoverFooter paddingSize="s">
<EuiSwitch
compressed
label="High contrast"
checked={!!_highContrastMode}
onChange={(e: EuiSwitchEvent) => {
changeHighContrastMode(!_highContrastMode);
}}
disabled={isForcedContrastMode}
/>
</EuiPopoverFooter>
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const getGlobalStyles = ({ euiTheme }: UseEuiTheme) => {
sidebar: css`
--doc-sidebar-width: 258px;
--doc-sidebar-hidden-width: 30px;
--ifm-toc-border-color: ${euiTheme.border.color};

// ensure scrolling still works
display: flex;
Expand All @@ -28,7 +29,7 @@ const getGlobalStyles = ({ euiTheme }: UseEuiTheme) => {
};
};

// converted from css moduels to Emotion
// converted from css modules to Emotion
const styles = {
docSidebarContainer: css`
display: none;
Expand Down
15 changes: 15 additions & 0 deletions packages/eui-theme-borealis/src/variables/_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const component_colors: _EuiThemeComponentColors = {

bottomBarBackground: SEMANTIC_COLORS.plainDark,

buttonGroupBackgroundDisabledSelected:
background_colors.backgroundBaseFormsControlDisabled,
buttonGroupBorderColor: border_colors.borderBasePlain,
buttonGroupBorderColorSelected: border_colors.borderBasePlain,
buttonGroupFocusColor: brand_text_colors.textPrimary,
Expand Down Expand Up @@ -120,6 +122,9 @@ const component_colors: _EuiThemeComponentColors = {

markdownFormatTableBorderColor: border_colors.borderBasePlain,

overlayMaskBackground: background_colors.backgroundBaseInteractiveOverlay,
overlayMaskBackgroundHighContrast: `rgba(${SEMANTIC_COLORS.shade140RGB}, 0.9)`,

popoverPanelBackground: background_colors.backgroundBasePlain,
popoverFooterBorderColor: border_colors.borderBaseSubdued,

Expand All @@ -130,6 +135,8 @@ const component_colors: _EuiThemeComponentColors = {

selectableListItemBorderColor: border_colors.borderBaseSubdued,

skeletonBackgroundSkeletonMiddleHighContrast: `rgba(${SEMANTIC_COLORS.shade100RGB}, 0.04)`,

superDatePickerBackgroundSuccees: background_colors.backgroundBaseSuccess,

switchBackgroundOn: background_colors.backgroundFilledPrimary,
Expand Down Expand Up @@ -181,6 +188,8 @@ export const components: _EuiThemeComponents = {
dark_background_colors.backgroundLightText,
breadcrumbsApplicationColor: dark_text_colors.textSubdued,

buttonGroupBackgroundDisabledSelected:
dark_background_colors.backgroundBaseFormsControlDisabled,
buttonGroupBorderColor: dark_border_colors.borderBasePlain,
buttonGroupBorderColorSelected: dark_border_colors.borderBasePlain,
buttonGroupFocusColor: dark_brand_text_colors.textPrimary,
Expand Down Expand Up @@ -258,6 +267,10 @@ export const components: _EuiThemeComponents = {

markdownFormatTableBorderColor: dark_border_colors.borderBasePlain,

overlayMaskBackground:
dark_background_colors.backgroundBaseInteractiveOverlay,
overlayMaskBackgroundHighContrast: `rgba(${SEMANTIC_COLORS.shade140RGB}, 0.9)`,

popoverPanelBackground: dark_background_colors.backgroundBasePlain,
popoverFooterBorderColor: dark_border_colors.borderBaseSubdued,

Expand All @@ -268,6 +281,8 @@ export const components: _EuiThemeComponents = {

selectableListItemBorderColor: dark_border_colors.borderBaseSubdued,

skeletonBackgroundSkeletonMiddleHighContrast: `rgba(${SEMANTIC_COLORS.plainLightRGB}, 0.3)`,

switchBackgroundOn: dark_background_colors.backgroundFilledPrimary,
switchBackgroundOff: dark_background_colors.backgroundFilledText,
switchUncompressedBackgroundDisabled:
Expand Down
Loading