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

fix: add well contrasting focus-ring to buttons on themed notifications #7488

Merged
merged 5 commits into from
Jul 1, 2024
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
6 changes: 2 additions & 4 deletions packages/button/theme/lumo/vaadin-button-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const button = css`
--_button-size: var(--vaadin-button-height, var(--lumo-button-size));
--_focus-ring-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
--_focus-ring-width: var(--vaadin-focus-ring-width, 2px);
--_focus-ring-gap-on: 0;
--_focus-ring-gap-color: var(--lumo-base-color);
/* Used by notification */
--_lumo-button-background: var(--vaadin-button-background, var(--lumo-contrast-5pct));
--_lumo-button-text-color: var(--vaadin-button-text-color, var(--lumo-primary-text-color));
Expand Down Expand Up @@ -103,8 +101,8 @@ const button = css`
/* Keyboard focus */

:host([focus-ring]) {
box-shadow: 0 0 0 calc(1px * var(--_focus-ring-gap-on)) var(--_focus-ring-gap-color),
0 0 0 calc(var(--_focus-ring-width) + 1px * var(--_focus-ring-gap-on)) var(--_focus-ring-color);
box-shadow: 0 0 0 calc(1px * var(--_focus-ring-gap-on, 0)) var(--_focus-ring-gap-color, var(--lumo-base-color)),
0 0 0 calc(var(--_focus-ring-width) + 1px * var(--_focus-ring-gap-on, 0)) var(--_focus-ring-color);
}

:host([theme~='primary'][focus-ring]) {
Expand Down
27 changes: 27 additions & 0 deletions packages/notification/test/visual/lumo/notification.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fixtureSync, nextRender } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import { visualDiff } from '@web/test-runner-visual-regression';
import '../../not-animated-styles.js';
import '../../../theme/lumo/vaadin-notification.js';
import '../../../../button/theme/lumo/vaadin-button.js';

describe('notification', () => {
let element;
Expand Down Expand Up @@ -36,3 +38,28 @@ describe('notification', () => {
});
});
});
describe('themes', () => {
let element;

beforeEach(() => {
element = fixtureSync('<vaadin-notification duration="0"></vaadin-notification>');
element.renderer = (root) => {
root.innerHTML = '<vaadin-button>Button</vaadin-button>';
};
element.opened = true;
});

afterEach(() => {
element.opened = false;
});

['primary', 'warning', 'success', 'error'].forEach((variant) => {
it(variant, async () => {
element.setAttribute('theme', variant);
const notification = document.querySelector('vaadin-notification-card');

await sendKeys({ press: 'Tab' });
await visualDiff(notification, `notification-${variant}-focus-ring-contrast`);
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions packages/notification/theme/lumo/vaadin-notification-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ registerStyles(
animation: lumo-notification-exit-slide-down 300ms;
}

:host([theme='success']) {
--_focus-ring-gap-color: var(--lumo-success-color);
--vaadin-focus-ring-color: var(--lumo-success-contrast-color);
}

:host([theme='warning']) {
--_focus-ring-gap-color: var(--lumo-warning-color);
--vaadin-focus-ring-color: var(--lumo-warning-contrast-color);
}

:host([theme='error']) {
--_focus-ring-gap-color: var(--lumo-error-color);
--vaadin-focus-ring-color: var(--lumo-error-contrast-color);
}

:host([theme='primary']) {
--_focus-ring-gap-color: var(--lumo-primary-color);
--vaadin-focus-ring-color: var(--lumo-primary-contrast-color);
}

:host([theme~='primary']) [part='overlay'] {
background: var(--lumo-primary-color);
color: var(--lumo-primary-contrast-color);
Expand Down
Loading