Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netdata/netdata-ui",
"version": "5.5.13",
"version": "5.5.14",
"description": "netdata UI kit",
"main": "dist/index.js",
"module": "dist/es6/index.js",
Expand Down
79 changes: 79 additions & 0 deletions src/components/button/__snapshots__/button.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ exports[`Borderless Button renders 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand All @@ -76,6 +81,13 @@ exports[`Borderless Button renders 1`] = `
stroke: #00AB44;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down Expand Up @@ -146,6 +158,11 @@ exports[`Button states renders loading icon 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand Down Expand Up @@ -180,6 +197,20 @@ exports[`Button states renders loading icon 1`] = `
stroke: #FFFFFF;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

@media (prefers-reduced-motion:reduce) {
.c1 {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down Expand Up @@ -269,6 +300,11 @@ exports[`Button states renders only icon 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand Down Expand Up @@ -307,6 +343,13 @@ exports[`Button states renders only icon 1`] = `
color: #526161;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down Expand Up @@ -391,6 +434,11 @@ exports[`Button states renders smaller only icon 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand Down Expand Up @@ -429,6 +477,13 @@ exports[`Button states renders smaller only icon 1`] = `
color: #526161;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down Expand Up @@ -509,6 +564,11 @@ exports[`Default Button renders 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand All @@ -529,6 +589,13 @@ exports[`Default Button renders 1`] = `
stroke: #FFFFFF;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down Expand Up @@ -598,6 +665,11 @@ exports[`Hollow Button renders 1`] = `
outline: none;
}

.c0.c0:focus-visible {
outline: 2px solid #4A5757;
outline-offset: 2px;
}

.c0.c0 .button-icon {
height: 14px;
width: 14px;
Expand All @@ -618,6 +690,13 @@ exports[`Hollow Button renders 1`] = `
stroke: #00AB44;
}

@media (prefers-reduced-motion:reduce) {
.c0.c0 .ntd-spinner {
animation: none;
stroke-dashoffset: 0;
}
}

<button
class="c0"
colors="[object Object]"
Expand Down
19 changes: 19 additions & 0 deletions src/components/button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ import { renderWithProviders, fireEvent } from "testUtilities"
import { Button } from "./button"

describe("Button states", () => {
it("shows a focus ring for keyboard focus only", () => {
const { container } = renderWithProviders(<Button label="Test prop text" />)
const button = container.firstChild
expect(button).toHaveStyleRule("outline", "none", { modifier: "&&:focus" })
expect(button).toHaveStyleRule("outline", expect.stringMatching(/^2px solid /), {
modifier: "&&:focus-visible",
})
expect(button).toHaveStyleRule("outline-offset", "2px", { modifier: "&&:focus-visible" })
})

it("stops the loading spinner when reduced motion is requested", () => {
const { container } = renderWithProviders(<Button label="Save" isLoading />)
const button = container.firstChild
expect(button).toHaveStyleRule("animation", "none", {
modifier: "&& .ntd-spinner",
media: "(prefers-reduced-motion:reduce)",
})
})

it("renders disabled", () => {
const { container } = renderWithProviders(<Button label="Test prop text" disabled />)
const button = container.firstChild
Expand Down
10 changes: 10 additions & 0 deletions src/components/button/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ export const StyledButton = styled.button.attrs(
outline: none;
}

&:focus-visible {
outline: ${getSizeBy(0.25)} solid ${getColor("textFocus")};
outline-offset: ${getSizeBy(0.25)};
}

.button-icon {
height: ${props =>
props.iconWidth
Expand All @@ -226,6 +231,11 @@ export const StyledButton = styled.button.attrs(
animation: ntd-draw 1s linear infinite;
stroke: ${props => props.colors.color(props)};
width: 24px;

@media (prefers-reduced-motion: reduce) {
animation: none;
stroke-dashoffset: 0;
}
}

.path {
Expand Down
5 changes: 5 additions & 0 deletions src/components/icon/components/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const StyledSvg = styled.svg`
stroke: ${getColor("bright")};
}

@media (prefers-reduced-motion: reduce) {
animation: none;
stroke-dashoffset: 0;
}

@keyframes ntd-draw {
to {
stroke-dashoffset: 0;
Expand Down
19 changes: 19 additions & 0 deletions src/components/icon/components/loader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @jest-environment jsdom
*/
import React from "react"
import { renderWithProviders } from "testUtilities"
import { LoaderIcon } from "./loader"

describe("LoaderIcon", () => {
it("stops animating when reduced motion is requested", () => {
const { container } = renderWithProviders(<LoaderIcon />)
const svg = container.firstChild
expect(svg).toHaveStyleRule("animation", "none", {
media: "(prefers-reduced-motion:reduce)",
})
expect(svg).toHaveStyleRule("stroke-dashoffset", "0", {
media: "(prefers-reduced-motion:reduce)",
})
})
})
Loading