Skip to content

Commit

Permalink
[Amsterdam] Unify focus states (#4242)
Browse files Browse the repository at this point in the history
* Resetting _reset and updating focus ring mixin
* Fix us usages of `euiCustomControlFocused`
* Change base outline color to `currentColor` and fix up base buttons
* Fixing up more instances
- Breadcrumbs (not great)
- Button groups (still missing on single-select)
- Tabs
- Links
* Cleaning up the diff between focus and hover states
* Consolidating focus background colors
* Fix up usages of $euiFocusRingColor
* Creating more mixins for interactive states and cleaning up focus ring mixin
* Fixing cross-browser issues and removing faux outline option
- Fixes up the checkbox,radio,switch outlines
- Reduces opacity of focus backgrounds
- Fixes link color in Ams. dark mode
  • Loading branch information
cchaos authored Nov 16, 2020
1 parent 625c8e8 commit 3cef201
Show file tree
Hide file tree
Showing 48 changed files with 449 additions and 102 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `eql` glyph in `EuiIcon` ([#4110](https://github.com/elastic/eui/pull/4110))
- Added `testenv` mock for `htmlIdGenerator` ([#4212](https://github.com/elastic/eui/pull/4212))
- Added `testenv` mock for `htmlIdGenerator` ([#4212](https://github.com/elastic/eui/pull/4212))
- Added several Sass mixins for handling of unified focus/hover states ([#4242](https://github.com/elastic/eui/pull/4242))

**Theme: Amsterdam**

- Unify focus states by leaning into `outline` and restricting to keyboard navigation ([#4242](https://github.com/elastic/eui/pull/4242))
- Removed faux border from `EuiAvatar` ([#4255](https://github.com/elastic/eui/pull/4255))

## [`30.3.0`](https://github.com/elastic/eui/tree/v30.3.0)
Expand Down
5 changes: 4 additions & 1 deletion src-docs/src/views/button/button_ghost.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export default () => {
};

return (
<EuiPanel paddingSize="l" className="guideDemo__ghostBackground">
<EuiPanel
paddingSize="l"
color="transparent"
className="guideDemo__ghostBackground">
<EuiFlexGroup wrap gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButton color="ghost" onClick={() => {}}>
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/icon/icon_colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default () => (
key={iconColor}
style={{ width: '340px' }}>
<EuiPanel
color="transparent"
className={classNames({
guideDemo__ghostBackground: iconColor === 'ghost',
})}>
Expand Down
1 change: 0 additions & 1 deletion src/components/breadcrumbs/_breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
.euiBreadcrumbs--truncate {
white-space: nowrap;
flex-wrap: nowrap;
overflow: hidden;

.euiBreadcrumb:not(.euiBreadcrumb--collapsed) {
max-width: $euiBreadcrumbTruncateWidth;
Expand Down
6 changes: 1 addition & 5 deletions src/components/collapsible_nav/_collapsible_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@

&:focus {
@include euiFocusRing;
}

&,
&:focus {
// Override default `EuiButtonEmpty` :focus background to ensure better contrast
background: $euiColorEmptyShade;
background: $euiColorEmptyShade !important; // sass-lint:disable-line no-important
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/color_picker/color_stops/_color_stops.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
height: 100%;

// Background color can potentially have opacity
// Pseudo element placed below the thumb to prevent the track from showing through
// Pseudo element placed below the thumb to prevent the track from showing through
&:before {
content: '';
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
max-width: 100%;

// Ensure that no input states are visible on the hidden input
input[aria-hidden='true'] {
input {
// sass-lint:disable-block no-important
border: none !important;
box-shadow: none !important;
outline: none !important;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

&.euiComboBoxOption-isFocused {
cursor: pointer;
color: $euiColorPrimary;
color: $euiColorPrimaryText;
background-color: $euiFocusBackgroundColor;
}

Expand Down
1 change: 1 addition & 0 deletions src/components/context_menu/_context_menu_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
width: 100%;
text-align: left;
color: $euiTextColor;
outline-offset: -$euiFocusRingSize;

&:hover,
&:focus {
Expand Down
3 changes: 2 additions & 1 deletion src/components/context_menu/_context_menu_panel.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.euiContextMenuPanel {
width: 100%;
visibility: visible;
outline-offset: -$euiFocusRingSize;

&.euiContextMenuPanel-txInLeft {
pointer-events: none;
Expand Down Expand Up @@ -36,9 +37,9 @@
.euiContextMenuPanelTitle {
@include euiPopoverTitle;
padding: $euiSizeM;

width: 100%;
text-align: left;
outline-offset: -$euiFocusRingSize;

&:enabled:hover,
&:enabled:focus {
Expand Down
11 changes: 5 additions & 6 deletions src/components/datagrid/_data_grid_column_sorting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@

.euiDataGridColumnSorting__fieldList {
@include euiYScrollWithShadows;
padding-top: $euiSizeXS;
padding-bottom: $euiSizeXS;
max-height: 300px;
}

.euiDataGridColumnSorting__field {
@include euiInteractiveStates;
display: block;
padding: $euiSizeXS;
padding: $euiSizeXS $euiSizeS;
width: 100%;

&:focus {
background: $euiFocusBackgroundColor;
text-decoration: underline;
}
outline-offset: -$euiFocusRingSize;
}

.euiDataGridColumnSorting__orderButtons {
Expand Down
3 changes: 3 additions & 0 deletions src/components/datagrid/_data_grid_header_row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

&:focus {
@include euiDataGridCellFocus;
border-top: none;
}

// We only truncate if the cell is not a control column.
&:not(.euiDataGridHeaderCell--controlColumn) {

&:focus-within {
@include euiDataGridCellFocus;
border-top: none;
}

.euiDataGridHeaderCell__button {
Expand All @@ -48,6 +50,7 @@
display: flex;
text-align: left;
font-weight: $euiFontWeightBold;
outline: none;
}

.euiDataGridHeaderCell__content {
Expand Down
1 change: 1 addition & 0 deletions src/components/datagrid/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ $euiDataGridStyles: (
box-shadow: 0 0 0 2px $euiFocusRingColor;
border-radius: 1px;
z-index: 2; // Needed so it sits above potential striping in the next row
outline: none; // Remove outline as we're handling it manually
}

@mixin euiDataGridRowCell {
Expand Down
2 changes: 1 addition & 1 deletion src/components/datagrid/column_sorting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const useColumnSorting = (
isOpen={avilableColumnsisOpen}
closePopover={() => setAvailableColumnsIsOpen(false)}
anchorPosition="downLeft"
panelPaddingSize="s"
panelPaddingSize="none"
button={
<EuiButtonEmpty
size="xs"
Expand Down
19 changes: 3 additions & 16 deletions src/components/filter_group/_filter_select_item.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.euiFilterSelectItem {
@include euiFontSizeS;
@include euiInteractiveStates;

padding: $euiSizeXS $euiSizeM;
display: block; // Necessary to make sure it doesn't force the whole popover to be too wide
Expand All @@ -8,26 +9,12 @@
color: $euiTextColor;
border-bottom: $euiBorderThin;
border-color: darken($euiColorLightestShade, 2%);

&:hover,
&:focus {
text-decoration: underline;
}
outline-offset: -$euiFocusRingSize;

&:focus,
&-isFocused {
cursor: pointer;
@include euiFocusBackground;
color: $euiColorPrimary;
background-color: $euiFocusBackgroundColor;
}

&[disabled] {
color: $euiColorMediumShade;
cursor: not-allowed;

&:hover {
text-decoration: none;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@
padding: 0 $euiSizeS;
width: $euiSizeXL;
border-radius: 0;
background-color: $euiFormInputGroupLabelBackground;

&:focus {
box-shadow: inset 0 0 0 2px $euiFocusRingColor;
&:not(:focus) {
background-color: $euiFormInputGroupLabelBackground;
}

&:focus-visible {
outline: 2px solid $euiFocusRingColor;
outline-offset: -2px;
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/form/range/_range_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@
border-radius: $euiRangeTrackRadius;
}

&:focus,
&:focus {
outline: none;
}

&:focus-visible,
&--hasFocus {
@include euiRangeThumbPerBrowser {
@include euiCustomControlFocused;
box-shadow: 0 0 0 $euiFocusRingSize $euiFocusRingColor;
}

~ .euiRangeThumb {
Expand Down
11 changes: 1 addition & 10 deletions src/components/form/super_select/_super_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,8 @@

.euiSuperSelect__item {
@include euiFontSizeS;
@include euiInteractiveStates;
padding: $euiSizeS;

&:hover:not(:disabled),
&:focus {
text-decoration: none;
background-color: $euiFocusBackgroundColor;
}

&:disabled {
cursor: not-allowed;
}
}

.euiSuperSelect__item--hasDividers:not(:last-of-type) {
Expand Down
12 changes: 7 additions & 5 deletions src/components/link/_link.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$textColors: (
$euiLinkColors: (
subdued: $euiTextSubduedColor,
primary: $euiColorPrimaryText,
secondary: $euiColorSecondaryText,
Expand All @@ -22,17 +22,19 @@ $textColors: (
}

// Create color modifiers based on the map
@each $name, $color in $textColors {
@each $name, $color in $euiLinkColors {
&.euiLink--#{$name} {
color: $color;

&:hover {
&:hover,
&:focus {
color: darken($color, 10%);
text-decoration: underline;
}

&:focus {
outline: solid 3px transparentize($color, .9);
background-color: transparentize($color, .9);
@include euiFocusBackground($color);
@include euiFocusRing(null, 0);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/components/list_group/_list_group_item.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.euiListGroupItem {
padding: 0;
border-radius: $euiBorderRadius;
overflow: hidden;
display: flex;
align-items: center;
transition: background-color $euiAnimSpeedFast;
Expand Down
1 change: 1 addition & 0 deletions src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
&:focus {
background-color: $euiFocusBackgroundColor;
text-decoration: underline;
outline-offset: -$euiFocusRingSize;

&::before {
background-color: $euiColorLightShade;
Expand Down
8 changes: 4 additions & 4 deletions src/components/text/_text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
a:not([class]) {
color: $euiLinkColor;

&:hover {
&:hover,
&:focus {
color: darken($euiLinkColor, 10%);
text-decoration: underline;
}

&:focus {
text-decoration: underline;
outline: solid 3px transparentize($euiLinkColor, .9);
background-color: transparentize($euiLinkColor, .9);
@include euiFocusBackground($euiLinkColor);
@include euiFocusRing;
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/components/tree_view/tree_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@

.euiTreeView__node {
max-height: $euiSizeXL;
overflow: hidden;
cursor: pointer;
line-height: $euiSizeXL;
}

.euiTreeView__node--expanded {
max-height: 100vh;
overflow: auto;
}

.euiTreeView__nodeInner {
Expand All @@ -32,12 +29,13 @@
text-align-last: left;

&:focus {
box-shadow: inset 0 0 0 $euiSizeXS / 4 $euiFocusRingColor;
@include euiFocusRing('small', 'inner');
}

&:hover,
&:active {
background-color: tintOrShade($euiColorLightShade, 50%, 10%);
&:active,
&:focus {
@include euiFocusBackground($euiTextColor);
}

.euiTreeView__iconPlaceholder {
Expand Down Expand Up @@ -85,7 +83,6 @@

.euiTreeView__node--expanded {
max-height: 100vh;
overflow: auto;
}
}

Expand Down
Loading

0 comments on commit 3cef201

Please sign in to comment.