Skip to content

Commit

Permalink
[Amsterdam] Fixing some focus states (#4876)
Browse files Browse the repository at this point in the history
* Removing a few intrusive focus rings
* [EuiHeaderBreadcrumbs] Fixing focus states
* [EuiButtonGroup] Prioritizing visible focus rings over :focus-visible support
* Fix position of popover panel outline
* Addressing some feedback for color picker, context menu, and accordion
* Also fixing EuiBetaBadge and disabled EuiCard
* [EuiCard] Allowing a `hasBorder` option
* Fixed EuiPanel border radius
  • Loading branch information
cchaos authored Jun 17, 2021
1 parent 7681e5c commit 80e2489
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 56 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- Fixed DataGrid footer and header rows jumps in Firefox ([#4869](https://github.com/elastic/eui/issues/4869))

**Theme: Amsterdam**

- Fixed more unique focus states using `outline` ([#4876](https://github.com/elastic/eui/pull/4876))
- Fixed `border-radius` value of `EuiPanel` ([#4876](https://github.com/elastic/eui/pull/4876))
- Fixed `disabled` background color of `EuiCard` for better visiblity on subdued backgrounds ([#4876](https://github.com/elastic/eui/pull/4876))

## [`34.4.0`](https://github.com/elastic/eui/tree/v34.4.0)

- Added draggable highlight area to `EuiDualRange` ([#4776](https://github.com/elastic/eui/pull/4776))
Expand Down
9 changes: 9 additions & 0 deletions src-docs/src/views/home/home_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const HomeView = () => (
justifyContent="spaceBetween">
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/navigation/button"
textAlign="left"
image={imageButtons}
Expand All @@ -131,6 +132,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/display/card"
textAlign="left"
image={imageCards}
Expand All @@ -140,6 +142,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/elastic-charts/creating-charts"
textAlign="left"
image={imageCharts}
Expand All @@ -149,6 +152,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/layout/flex"
textAlign="left"
image={imageFlexgrid}
Expand All @@ -158,6 +162,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/forms/form-layouts"
textAlign="left"
image={imageForms}
Expand All @@ -167,6 +172,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/display/icons"
textAlign="left"
image={imageIcons}
Expand All @@ -176,6 +182,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/layout/page"
textAlign="left"
image={imagePages}
Expand All @@ -185,6 +192,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/tabular-content/tables"
textAlign="left"
image={imageTables}
Expand All @@ -194,6 +202,7 @@ export const HomeView = () => (
</EuiFlexItem>
<EuiFlexItem grow={false} className="guideHomePage__blockformCard">
<EuiCard
hasBorder
href="#/display/text"
textAlign="left"
image={imageText}
Expand Down
5 changes: 5 additions & 0 deletions src/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
&:focus {
.euiAccordion__iconWrapper {
@include euiAccordionIconFocus;
outline: none; // The `outline` gets applied to the whole button, we don't need a second one on the icon
}
}
}
Expand Down Expand Up @@ -73,6 +74,10 @@
transition:
height $euiAnimSpeedNormal $euiAnimSlightResistance,
opacity $euiAnimSpeedNormal $euiAnimSlightResistance;

&:focus {
outline: none; // Hide focus ring because of `tabindex=-1` on Safari
}
}

$paddingSizes: (
Expand Down
7 changes: 5 additions & 2 deletions src/components/badge/beta_badge/_beta_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

&:focus {
@include euiFocusRing;
// Can't use `currentColor` because of possible white text, so always keep it black
outline-color: lightOrDarkTheme($euiColorInk, $euiColorGhost);
// The rounded corners of the badge doesn't match well with the outline, so push it outward
outline-offset: 2px;
}

&:not(.euiBetaBadge--hollow) {
Expand All @@ -27,7 +31,6 @@
line-height: $euiSize + $euiSizeXS;
padding: 0 $euiSizeM;
}

}

// When it's just an icon, make it a circle
Expand Down Expand Up @@ -81,4 +84,4 @@
&.euiBetaBadge-isClickable {
color: chooseLightOrDarkText($backgroundColor, $euiColorGhost, $euiColorInk);
}
}
}
25 changes: 25 additions & 0 deletions src/components/card/__snapshots__/card.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,31 @@ exports[`EuiCard props footer 1`] = `
</div>
`;

exports[`EuiCard props hasBorder 1`] = `
<div
class="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPanel--hasBorder euiCard euiCard--centerAligned"
>
<div
class="euiCard__content"
>
<span
class="euiTitle euiTitle--small euiCard__title"
id="generated-idTitle"
>
Card title
</span>
<div
class="euiText euiText--small euiCard__description"
id="generated-idDescription"
>
<p>
Card description
</p>
</div>
</div>
</div>
`;

exports[`EuiCard props horizontal 1`] = `
<div
class="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiCard euiCard--centerAligned euiCard--horizontal"
Expand Down
1 change: 1 addition & 0 deletions src/components/card/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
transform: none !important;
box-shadow: none !important;
text-decoration: none !important;
background-color: transparentize($euiButtonColorDisabled, .9) !important;
color: $euiColorDisabledText;

.euiCard__top {
Expand Down
8 changes: 8 additions & 0 deletions src/components/card/card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ describe('EuiCard', () => {
expect(component).toMatchSnapshot();
});

test('hasBorder', () => {
const component = render(
<EuiCard title="Card title" description="Card description" hasBorder />
);

expect(component).toMatchSnapshot();
});

test('horizontal', () => {
const component = render(
<EuiCard
Expand Down
4 changes: 4 additions & 0 deletions src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export type EuiCardProps = Omit<CommonProps, 'aria-label'> &
* Adds a button to the bottom of the card to allow for in-place selection
*/
selectable?: EuiCardSelectProps;
/**
* Use a border style of card instead of shadow
*/
hasBorder?: EuiPanelProps['hasBorder'];
} & (
| {
// description becomes optional when children is present
Expand Down
4 changes: 3 additions & 1 deletion src/components/color_picker/_hue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
margin: $euiSizeXS 0;
position: relative;


// To make our fake range skinny, we add some pseudo borders to fake the height of the gradient
&:before,
&:after {
Expand Down Expand Up @@ -82,5 +81,8 @@
box-shadow: 0 0 0 $euiFocusRingSize $euiFocusRingColor;
border-color: $euiColorPrimary;
}

// Focus is added to the thumb ^^ so we can remove the outer wrapping outline
outline: none;
}
}
5 changes: 4 additions & 1 deletion src/components/color_picker/_saturation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@
}

&:focus {
outline: none; // Hide focus ring because of `tabindex=0` on Safari

.euiSaturation__indicator {
@include euiFocusRing;
box-shadow: 0 0 0 $euiFocusRingSize $euiFocusRingColor;
border-color: $euiColorPrimary;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`EuiContextMenu can pass-through horizontal rule props 1`] = `
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<div
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -42,7 +42,7 @@ exports[`EuiContextMenu panel item can be a separator line 1`] = `
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<div
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -98,7 +98,7 @@ exports[`EuiContextMenu panel item can contain JSX 1`] = `
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<div
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -142,7 +142,7 @@ exports[`EuiContextMenu props panels and initialPanelId allows you to click the
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -181,7 +181,7 @@ exports[`EuiContextMenu props panels and initialPanelId allows you to click the
>
<div
class="euiContextMenuPanel euiContextMenu__panel euiContextMenuPanel-txOutRight"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -212,7 +212,7 @@ exports[`EuiContextMenu props panels and initialPanelId allows you to click the
</div>
<div
class="euiContextMenuPanel euiContextMenu__panel euiContextMenuPanel-txInRight"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -301,7 +301,7 @@ exports[`EuiContextMenu props panels and initialPanelId renders the referenced p
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -339,7 +339,7 @@ exports[`EuiContextMenu props size m is rendered 1`] = `
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle"
Expand Down Expand Up @@ -377,7 +377,7 @@ exports[`EuiContextMenu props size s is rendered 1`] = `
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
tabindex="-1"
>
<button
class="euiContextMenuPanelTitle euiContextMenuPanelTitle--small"
Expand Down
Loading

0 comments on commit 80e2489

Please sign in to comment.