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

[Amsterdam] Unify focus states #4242

Merged
merged 18 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
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
3 changes: 1 addition & 2 deletions src/components/collapsible_nav/_collapsible_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
@include euiFocusRing;
}

&,
&:focus {
&:enabled:focus:focus-visible {
// Override default `EuiButtonEmpty` :focus background to ensure better contrast
background: $euiColorEmptyShade;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/color_picker/_hue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}

// Thumb has trouble with animation, so we make something similar to `@include euiFocusRing`
&:focus {
&:focus-visible {
@include euiRangeThumbPerBrowser {
box-shadow: 0 0 0 $euiFocusRingSize $euiFocusRingColor;
border-color: $euiColorPrimary;
Expand Down
4 changes: 2 additions & 2 deletions src/components/color_picker/color_stops/_color_stops.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.euiColorStops:not(.euiColorStops-isDisabled) {
&:focus {
&:focus-visible {
outline: 2px solid $euiFocusRingColor;
}
}
Expand Down 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 @@ -213,7 +213,7 @@ export const useColumnSorting = (
closePopover={() => setAvailableColumnsIsOpen(false)}
anchorPosition="downLeft"
ownFocus
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
2 changes: 1 addition & 1 deletion src/components/form/checkbox/_checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
}

&:focus,
&:focus-visible,
&:active:not(:disabled) {
+ .euiCheckbox__square {
@include euiCustomControlFocused;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@
border-radius: 0;
background-color: $euiFormInputGroupLabelBackground;

&:focus {
box-shadow: inset 0 0 0 2px $euiFocusRingColor;
&: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
4 changes: 4 additions & 0 deletions src/components/form/range/_range_thumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
pointer-events: none;

&:focus {
outline: none;
}

&:focus-visible {
@include euiCustomControlFocused;
}

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
6 changes: 5 additions & 1 deletion src/components/form/switch/_switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
flex-shrink: 0; // ensures the button doesn't lose width because of a long label
line-height: 0; // ensures button takes height of switch inside

&:focus .euiSwitch__track {
&:focus-visible {
outline: none;
}

&:focus-visible .euiSwitch__track {
@include euiCustomControlFocused;
}

Expand Down
10 changes: 6 additions & 4 deletions src/components/link/_link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ $textColors: (
&.euiLink--#{$name} {
color: $color;

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

&:focus {
outline: solid 3px transparentize($color, .9);
background-color: transparentize($color, .9);
&:focus-visible {
@include euiFocusRing;
}
}
}
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
21 changes: 12 additions & 9 deletions src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
&:focus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Edge and Chrome where the outline gest by default a border-radius, do you think we should add a border-radius to the focused tab? So we wouldn't see the corners outside of the outline?

Screenshot 2020-11-16 at 12 38 51

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll agree that will be a good tweak. But I'd like to push that off to when the Tabs are specifically tackled for Amsterdam. Since right now that would require a new Amsterdam specific overrides file.

background-color: $euiFocusBackgroundColor;
text-decoration: underline;
outline-offset: -$euiFocusRingSize;

&::before {
background-color: $euiColorLightShade;
Expand All @@ -66,15 +67,17 @@
color: $euiColorPrimary;
cursor: default;

&::after {
animation: euiTab $euiAnimSpeedFast $euiAnimSlightResistance;
background-color: $euiColorPrimary;
bottom: 0;
content: ' ';
height: $euiBorderWidthThick;
left: 0;
position: absolute;
width: 100%;
&:not(:focus-visible) {
&::after {
animation: euiTab $euiAnimSpeedFast $euiAnimSlightResistance;
background-color: $euiColorPrimary;
bottom: 0;
content: ' ';
height: $euiBorderWidthThick;
left: 0;
position: absolute;
width: 100%;
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/text/_text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,19 @@
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);
}

&:focus-visible {
@include euiFocusRing;
}
}

img {
Expand Down
Loading