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

Improve contrast for EuiCollapsibleNav close link #3465

Merged
merged 12 commits into from
May 13, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added `sortBy` and `sortShift` props to `euiPaletteColorBlind()` for sorting along the color wheel ([#3387](https://github.com/elastic/eui/pull/3387))
- Added `partition` key to `EuiChartThemeType` for Partition chart support ([#3387](https://github.com/elastic/eui/pull/3387))
- Updated `EuiImage`'s `caption` prop type from `string` to `ReactNode` ([#3387](https://github.com/elastic/eui/pull/3387))
- Improved contrast for `EuiCollapsibleNav` close button ([#3465](https://github.com/elastic/eui/pull/3465))

**Breaking changes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton class"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton class"
data-test-subj="test"
type="button"
>
Expand Down Expand Up @@ -113,7 +113,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down Expand Up @@ -174,7 +174,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down Expand Up @@ -229,7 +229,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down Expand Up @@ -282,7 +282,7 @@ exports[`EuiCollapsibleNav props isDocked 1`] = `
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down Expand Up @@ -336,7 +336,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down Expand Up @@ -396,7 +396,7 @@ Array [
id="id"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiCollapsibleNav__closeButton"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiScreenReaderOnly--showOnFocus euiCollapsibleNav__closeButton"
type="button"
>
<span
Expand Down
18 changes: 17 additions & 1 deletion src/components/collapsible_nav/_collapsible_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
position: absolute;
right: 0;
top: $euiSize;
margin-right: -25%;
margin-right: -27%;
padding: $euiSizeM 0;
line-height: 1;
border-radius: $euiBorderRadius;

&:focus {
@include euiFocusRing;
}

&,
&:focus {
background: $euiColorEmptyShade;
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
}
}

// The addition of this class is handled through JS
Expand All @@ -38,6 +50,10 @@
// At tiny screens, reduce the close button to a simple `x`
.euiCollapsibleNav__closeButton {
margin-right: -15%;

.euiButtonEmpty__text {
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
margin-left: 0;
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
}
}

.euiCollapsibleNav__closeButtonLabel {
Expand Down
29 changes: 16 additions & 13 deletions src/components/collapsible_nav/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { EuiOverlayMask } from '../overlay_mask';
import { CommonProps } from '../common';
import { EuiButtonEmpty, EuiButtonEmptyProps } from '../button';
import { EuiI18n } from '../i18n';
import { EuiScreenReaderOnly } from '../accessibility';

export type EuiCollapsibleNavProps = CommonProps &
HTMLAttributes<HTMLElement> & {
Expand Down Expand Up @@ -160,19 +161,21 @@ export const EuiCollapsibleNav: FunctionComponent<EuiCollapsibleNavProps> = ({
});

const closeButton = showCloseButton && (
<EuiButtonEmpty
onClick={collapse}
size="xs"
iconType="cross"
{...closeButtonProps}
className={classNames(
'euiCollapsibleNav__closeButton',
closeButtonProps && closeButtonProps.className
)}>
<span className="euiCollapsibleNav__closeButtonLabel">
<EuiI18n token="euiCollapsibleNav.closeButtonLabel" default="close" />
</span>
</EuiButtonEmpty>
<EuiScreenReaderOnly showOnFocus>
<EuiButtonEmpty
onClick={collapse}
size="xs"
iconType="cross"
{...closeButtonProps}
className={classNames(
'euiCollapsibleNav__closeButton',
closeButtonProps && closeButtonProps.className
)}>
<span className="euiCollapsibleNav__closeButtonLabel">
<EuiI18n token="euiCollapsibleNav.closeButtonLabel" default="close" />
</span>
</EuiButtonEmpty>
</EuiScreenReaderOnly>
);

const flyout = (
Expand Down