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 spike #8036

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a5525c9
Create `highContrastMode` prop + theme context
cee-chen Sep 20, 2024
bae45ce
Implement system detection of high contrast mode
cee-chen Sep 22, 2024
b4fe916
Modify border color when in `highContrastMode`
cee-chen Sep 23, 2024
0b289f5
Update shadow mixins to detect high contrast mode
cee-chen Sep 23, 2024
7688ff0
[EuiForm] Increase contrast of form control inputs across the board
cee-chen Sep 23, 2024
4ab3941
[EuiForm] Increase contrast of selection checkboxes/radios/switches
cee-chen Sep 23, 2024
392f8dd
[EuiForm] Add borders to prepend/append labels
cee-chen Sep 23, 2024
ca28724
[EuiSuperDatePicker] Fix duplicate high contrast borders
cee-chen Nov 11, 2024
c411714
[EuiComboBox] Fix list dividers to match EuiSelectable
cee-chen Sep 23, 2024
135fb80
[EuiButton] Add high contrast borders
cee-chen Sep 23, 2024
f0a3816
[shadows] Add new option to allow components to specify border-all in…
cee-chen Sep 23, 2024
5b85964
[shadows] Update more usages to set all-around borders where it makes…
cee-chen Sep 23, 2024
f31f628
[EuiPanel] High contrast mode updates
cee-chen Sep 23, 2024
3c2b8d4
[EuiPopover] Update for high contrast mode
cee-chen Sep 23, 2024
f7db310
[EuiToolTip] Fix rendering in Windows high contrast mode
cee-chen Nov 12, 2024
8e96f17
[EuiForm][EuiToast] Increase gradient/colored highlights to account f…
cee-chen Sep 23, 2024
5aa3b9d
[EuiForm] Fix invisible clear button on Windows high contrast themes
cee-chen Nov 12, 2024
ff6c9b6
[EuiCodeBlock] Add high contrast border
cee-chen Nov 11, 2024
8344d43
[EuiMark] Increase contrast of highlighted text
cee-chen Sep 23, 2024
578d47f
[EuiMarkdown] Adjust border colors
cee-chen Sep 23, 2024
990a20c
[EuiHorizontalRule] Fix lack of rendering in Windows high contrast th…
cee-chen Nov 11, 2024
65d6df5
[EuiSteps][EuiTimeline] Add borders and darken lines
cee-chen Sep 23, 2024
127acc3
[EuiCommentEvent] Tweak high contrast borders
cee-chen Nov 12, 2024
332f8ad
[EuiTabs] Fix 'borders' in Windows high contrast themes
cee-chen Nov 11, 2024
178da8e
[EuiBottomBar] Add border UI matching dark themed EuiHeaders
cee-chen Nov 12, 2024
a7be16d
[EuiResizableButton] Fix indicator being completely invisible on Wind…
cee-chen Nov 12, 2024
2e4c1b2
[EuiAvatar][EuiBadge*] Render borders in Windows high contrast themes
cee-chen Nov 12, 2024
8ead0f8
[EuiBreadcrumbs] Fix rendering in Windows high contrast themes
cee-chen Nov 12, 2024
1b58e9d
[EuiBeacon] Fix rendering in Windows high contrast themes
cee-chen Nov 12, 2024
aa62fa4
[EuiSideNav] Fix lines/ticks missing in Windows high contrast themes
cee-chen Nov 12, 2024
51b2bc7
[EuiFilterGroup] Fix borders to work with Windows high contrast themes
cee-chen Nov 12, 2024
75407b3
[EuiExpression] Better Windows high contrast theme support
cee-chen Nov 12, 2024
11fc940
[EuiText] Fix misc border issue in Windows high contrast mode
cee-chen Nov 12, 2024
2ac88f4
[EuiKeyPadMenu] Improve high contrast UX
cee-chen Nov 12, 2024
ce73701
[EuiRange] Fix rendering for Windows high contrast mode
cee-chen Nov 12, 2024
97ea0a3
[EuiProgress] Fix rendering for Windows high contrast themes
cee-chen Nov 12, 2024
3abe96d
[EuiSkeleton] Fix rendering for Windows high contrast themes
cee-chen Nov 12, 2024
97beead
[EuiLoadingSpinner/Chart] Fix rendering for Windows high contrast themes
cee-chen Nov 13, 2024
7680d70
[EuiColorPicker] Fix rendering for Windows high contrast themes
cee-chen Nov 13, 2024
dd0cc0e
[docs] Spike out contrast switchers
cee-chen Sep 23, 2024
d6f4d89
[src-docs continued] refactor `locale` out from redux and store it in…
cee-chen Sep 23, 2024
ae285d1
[docs] Fix various panel border issues
cee-chen Nov 11, 2024
92c1bd1
changelog
cee-chen Sep 23, 2024
ccda13b
Remove `no-extra-semicolons` stylelint rule
cee-chen Nov 12, 2024
49b28f5
Update PR template checklist to include browser QAing high contrast m…
cee-chen Nov 12, 2024
57da1ba
[EuiTextTruncate] Fix "broken" truncation in Windows high contrast th…
cee-chen Nov 13, 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export interface GuidelineProps extends PropsWithChildren {
panelStyle?: EuiPanelProps['style'];
}

const getGuidelineStyles = ({ euiTheme }: UseEuiTheme) => ({
// @ts-expect-error - Typing doesn't exist until EUI is released/upgraded
const getGuidelineStyles = ({ euiTheme, highContrastMode }: UseEuiTheme) => ({
root: css`
margin-block: var(--eui-theme-content-vertical-spacing);
`,
Expand All @@ -31,7 +32,9 @@ const getGuidelineStyles = ({ euiTheme }: UseEuiTheme) => ({
border-color: ${euiTheme.colors.danger};
`,
textWrapper: css`
margin-block-start: var(--eui-size-xs);
${highContrastMode // High contrast mode adds borders around split panels, so we should tweak text margins to account for that
? 'margin: var(--eui-size-s);'
: 'margin-block-start: var(--eui-size-xs);'}
`,
});

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.
18 changes: 18 additions & 0 deletions packages/eui/.storybook/decorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ const storybookToolbarColorModes: Array<
{ value: 'dark', title: 'Dark mode', icon: 'circle' },
];

const storybookToolbarHighContrastMode: Array<
ToolbarDisplay & { value: boolean }
> = [
{ value: false, title: 'High contrast off', icon: 'circlehollow' },
{ value: true, title: 'High contrast on', icon: 'circle' },
];

const storybookToolbarWritingModes: Array<
ToolbarDisplay & { value: WritingModes }
> = [
Expand All @@ -112,6 +119,17 @@ export const euiProviderDecoratorGlobals: Preview['globalTypes'] = {
dynamicTitle: true,
},
},
highContrastMode: {
description: 'High contrast mode for EuiProvider theme',
defaultValue: window?.matchMedia?.('(prefers-contrast: more)').matches
? true
: false,
toolbar: {
title: 'Contrast mode',
items: storybookToolbarHighContrastMode,
dynamicTitle: true,
},
},
writingMode: {
description: 'Writing mode for testing logical property directions',
defaultValue: 'ltr',
Expand Down
1 change: 1 addition & 0 deletions packages/eui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const preview: Preview = {
(Story, context) => (
<EuiProviderDecorator
colorMode={context.globals.colorMode}
highContrastMode={context.globals.highContrastMode}
{...(context.componentId === 'theming-euiprovider' && context.args)}
writingMode={context.globals.writingMode}
>
Expand Down
3 changes: 0 additions & 3 deletions packages/eui/.stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ module.exports = {
ignoreKeywords: [camelCaseValueRegex],
},
],
// This is set to deprecate after stylelint v16, but in the meanwhile, is helpful
// for finding extraneous semicolons after utils that already output semicolons (e.g. logicalCSS())
'no-extra-semicolons': true,

// Emotion uses the `label` property to generate the output className string
'property-no-unknown': [true, { ignoreProperties: 'label' }],
Expand Down
3 changes: 3 additions & 0 deletions packages/eui/changelogs/upcoming/8036.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Updated `EuiProvider` `and `EuiThemeProvider` with a new `highContrastMode`
- This prop allows toggling a higher contrast visual style that primarily affects borders and shadows
- On `EuiProvider`, if the `highContrastMode` prop is not passed, this setting will inherit from the user's OS/system light/dark mode setting
3 changes: 0 additions & 3 deletions packages/eui/src-docs/src/actions/action_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ export default {
// Example nav actions
REGISTER_SECTION: 'REGISTER_SECTION',
UNREGISTER_SECTION: 'UNREGISTER_SECTION',

// Locale actions
TOGGLE_LOCALE: 'TOGGLE_LOCALE',
};
1 change: 0 additions & 1 deletion packages/eui/src-docs/src/actions/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/eui/src-docs/src/actions/locale_actions.js

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,5 @@ export class GuidePageChrome extends Component {

GuidePageChrome.propTypes = {
currentRoute: PropTypes.object.isRequired,
onToggleLocale: PropTypes.func.isRequired,
selectedLocale: PropTypes.string.isRequired,
navigation: PropTypes.array.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ import { VersionSwitcher } from './version_switcher';

const GITHUB_URL = 'https://github.com/elastic/eui';

export type GuidePageHeaderProps = {
onToggleLocale: () => {};
selectedLocale: string;
};

export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
onToggleLocale,
selectedLocale,
}) => {
export const GuidePageHeader = () => {
const isMobileSize = useIsWithinBreakpoints(['xs', 's']);

const logo = useMemo(() => {
Expand Down Expand Up @@ -112,18 +104,9 @@ export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
}, [codesandbox, github]);

const rightSideItems = isMobileSize
? [
<GuideThemeSelector
onToggleLocale={onToggleLocale}
selectedLocale={selectedLocale}
/>,
mobileMenu,
]
? [<GuideThemeSelector />, mobileMenu]
: [
<GuideThemeSelector
onToggleLocale={onToggleLocale}
selectedLocale={selectedLocale}
/>,
<GuideThemeSelector />,
github,
<GuideFigmaLink key="figma" />,
codesandbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

.guideRule__example__panelFooter {
padding: $euiSize 0;

/* High contrast mode has borders, so we should tweak the text padding to account for that */
@media (prefers-contrast: more), (prefers-contrast: custom), (forced-colors: active) {
padding: $euiSize;
}
}

.guideRule__example--do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,25 @@ export const GuideSectionPropsDescription: FunctionComponent<

return (
<>
<div className={classNames('guideSection__propsTableIntro', className)}>
<EuiFlexGroup alignItems="baseline" wrap>
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3 id={componentName}>{componentName}</h3>
</EuiTitle>
<EuiFlexGroup
className={classNames('guideSection__propsTableIntro', className)}
alignItems="baseline"
wrap
>
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3 id={componentName}>{componentName}</h3>
</EuiTitle>
</EuiFlexItem>
{extendedTypesElements.length > 0 && (
<EuiFlexItem>
<EuiText size="s">
<p>[ extends {extendedTypesElements} ]</p>
</EuiText>
</EuiFlexItem>
{extendedTypesElements.length > 0 && (
<EuiFlexItem>
<EuiText size="s">
<p>[ extends {extendedTypesElements} ]</p>
</EuiText>
</EuiFlexItem>
)}
</EuiFlexGroup>
{descriptionElement}
</div>
)}
</EuiFlexGroup>
{descriptionElement}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const GuideSectionPropsTable: FunctionComponent<
const { props } = docgenInfo;

return (
<div>
<>
{componentName && (
<GuideSectionPropsDescription
componentName={componentName}
Expand All @@ -38,7 +38,7 @@ export const GuideSectionPropsTable: FunctionComponent<
scope: component,
}}
/>
</div>
</>
);
};

Expand Down
Loading
Loading