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

High contrast mode support #8232

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5fe668e
[EuiProvider][EuiThemeProvider] `highContrastMode` set up and documen…
cee-chen Nov 21, 2024
a55ed3d
Remove `no-extra-semicolons` stylelint rule
cee-chen Nov 12, 2024
8339bf7
[High Contrast Mode] Panels, modals, flyouts, toasts, popovers, and t…
cee-chen Nov 27, 2024
112f1e5
[High Contrast Mode] Form controls (#8193)
cee-chen Dec 2, 2024
478ea3f
[High Contrast Mode] Ranges, color pickers, and date pickers (#8199)
cee-chen Dec 5, 2024
7edd66c
[High Contrast Mode] Allow forced high contrast themes to also force …
cee-chen Dec 4, 2024
7ca2a69
[High contrast mode] DRY utilities (#8205)
cee-chen Dec 6, 2024
569f13d
[High Contrast Mode] Buttons, datepicker redux, code blocks, and avat…
cee-chen Dec 10, 2024
5d0084b
[High Contrast Mode] Horizontal rules, side navs, tabs, and breadcrum…
cee-chen Dec 11, 2024
6c415ca
[High Contrast Mode] Loading components and beacons (#8215)
cee-chen Dec 11, 2024
841ef86
[High Contrast Mode] Markdown, highlighting, misc text fixes (#8219)
cee-chen Dec 11, 2024
8e6f8c1
[High Contrast Mode] EuiKeyPadMenu, EuiImage, EuiOverlayMask, EuiBott…
cee-chen Dec 12, 2024
82c62d4
[High Contrast Mode] Steps, timelines, and comment lists (#8223)
cee-chen Dec 12, 2024
bdbbdf6
[High Contrast Mode] Tables and data grid (#8226)
cee-chen Dec 12, 2024
0997448
Update changelog file
cee-chen Dec 12, 2024
03229db
[PR feedback] Changelog typo
cee-chen Dec 12, 2024
578de0b
docs: ensure high contrast mode works in EUI+
mgadewoll Dec 12, 2024
34e5db8
[High Contrast Mode] new_final_final(2).psd (#8234)
cee-chen Dec 13, 2024
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/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@docusaurus/theme-common": "^3.5.2",
"@docusaurus/utils-validation": "^3.5.2",
"@elastic/datemath": "^5.0.3",
"@elastic/eui": "97.2.0",
"@elastic/eui": "workspace:^",
"@elastic/eui-docgen": "workspace:^",
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.4",
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 @@ -6,6 +6,7 @@ import {
useEuiMemoizedStyles,
UseEuiTheme,
} from '@elastic/eui';
import { highContrastModeStyles } from '@elastic/eui/lib/global_styling/functions/high_contrast';
import { css } from '@emotion/react';
import { GuidelineType } from './types';
import { GuidelineText } from './guideline_text';
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, highContrastMode } = 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 @@ -9,13 +9,13 @@ import { EUI_THEMES, EuiProvider, EuiThemeColorMode } from '@elastic/eui';

import { EuiThemeOverrides } from './theme_overrides';

const EUI_THEME_NAMES = EUI_THEMES.map(
({ value }) => value
) as EuiThemeColorMode[];
const EUI_THEME_NAMES = EUI_THEMES.map(({ value }) => value);

const defaultState = {
theme: EUI_THEME_NAMES[0] as EuiThemeColorMode,
theme: EUI_THEME_NAMES[0] as string,
colorMode: 'LIGHT' as EuiThemeColorMode,
changeTheme: (themeValue: EuiThemeColorMode) => {},
changeColorMode: (colorMode: EuiThemeColorMode) => {},
};

export const AppThemeContext = createContext(defaultState);
Expand All @@ -24,25 +24,42 @@ export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
children,
}) => {
const isBrowser = useIsBrowser();
const [theme, setTheme] = useState<EuiThemeColorMode>(() => {

const [theme, setTheme] = useState<string>(() => {
if (isBrowser) {
return localStorage.getItem('theme') as EuiThemeColorMode ?? defaultState.theme;
return (
(localStorage.getItem('theme') as EuiThemeColorMode) ??
defaultState.theme
);
}

return defaultState.theme;
});

const [colorMode, setColorMode] = useState<EuiThemeColorMode>(() => {
if (isBrowser) {
return (
(localStorage.getItem('colorMode') as EuiThemeColorMode) ??
defaultState.colorMode
);
}

return defaultState.colorMode;
});

return (
<AppThemeContext.Provider
value={{
theme,
theme: theme,
colorMode,
changeTheme: setTheme,
changeColorMode: setColorMode,
}}
>
<EuiProvider
globalStyles={false}
modify={EuiThemeOverrides}
colorMode={theme}
colorMode={colorMode}
>
{children}
</EuiProvider>
Expand Down
12 changes: 6 additions & 6 deletions packages/docusaurus-theme/src/theme/ColorModeToggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ function ColorModeToggle({
onChange,
...rest
}: WrappedProps): JSX.Element {
const { theme, changeTheme } = useContext(AppThemeContext);
const { colorMode, changeColorMode } = useContext(AppThemeContext);

useEffect(() => {
changeTheme(value);
changeColorMode;
}, []);

const handleOnChange = (themeName: EuiThemeColorMode) => {
changeTheme(themeName);
onChange?.(themeName);
const handleOnChange = (colorMode: EuiThemeColorMode) => {
changeColorMode(colorMode);
onChange?.(colorMode);
};

return (
<OriginalColorModeToggle
value={theme}
value={colorMode}
onChange={handleOnChange}
{...rest}
/>
Expand Down
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Loading
Loading