From af9911f4d65ed3dc863083cb5974a5f73040e974 Mon Sep 17 00:00:00 2001 From: Andrew Steele Date: Mon, 16 Dec 2024 13:24:27 -0500 Subject: [PATCH 01/11] A11y improvements to va-radio-option --- .../test/va-radio-option.e2e.ts | 11 ++- .../va-radio-option/va-radio-option.scss | 72 +++++++++++++------ .../va-radio-option/va-radio-option.tsx | 18 ++--- .../components/va-radio/test/va-radio.e2e.ts | 5 +- 4 files changed, 66 insertions(+), 40 deletions(-) diff --git a/packages/web-components/src/components/va-radio-option/test/va-radio-option.e2e.ts b/packages/web-components/src/components/va-radio-option/test/va-radio-option.e2e.ts index c3ececbbc..63d92131b 100644 --- a/packages/web-components/src/components/va-radio-option/test/va-radio-option.e2e.ts +++ b/packages/web-components/src/components/va-radio-option/test/va-radio-option.e2e.ts @@ -17,8 +17,8 @@ describe('va-radio-option', () => { expect(element).toEqualHtml(`
- -
@@ -73,4 +73,11 @@ describe('va-radio-option', () => { expect(description.getAttribute('data-dd-action-name')).toEqual('description'); }); + it('institutes the tile class if the tile prop is provided', async () => { + const page = await newE2EPage(); + await page.setContent(''); + + const element = await page.find('va-radio-option .usa-radio'); + expect(element).toHaveClass('va-radio-option__container--tile'); + }); }); diff --git a/packages/web-components/src/components/va-radio-option/va-radio-option.scss b/packages/web-components/src/components/va-radio-option/va-radio-option.scss index 9af13f13e..65705140f 100644 --- a/packages/web-components/src/components/va-radio-option/va-radio-option.scss +++ b/packages/web-components/src/components/va-radio-option/va-radio-option.scss @@ -3,43 +3,73 @@ @use 'uswds-core/src/styles/mixins/helpers/checkbox-and-radio-colors'; @use 'usa-radio/src/styles/usa-radio'; -va-radio-option label { - max-width: 480px; - box-sizing: border-box; -} - .usa-radio { background: transparent; + display: flex; + margin: 0.5rem 0; } -va-radio-option { +.va-radio-option__container--tile { + border-radius: 0.25rem; + background-color: white; + border: 2px solid #c9c9c9; + color: #1b1b1b; + padding: 0.75rem 0 0.75rem 0.5rem; +} + +:host { display: block; margin-top: 12px; } -input[type=radio].usa-radio__input { - margin-left: unset; +input[type="radio"].va-radio-option__input { + height: 20px; + width: 20px; + min-width: 20px; + border: 2px solid #1b1b1b; + border-radius: 50%; + appearance: none; + -webkit-appearance: none; + margin: 0.064rem 0.5rem 0 0; opacity: unset; - right: auto; - left: -999em; + position: initial; } -va-radio-option input:focus { +input[type="radio"].va-radio-option__input:checked { + background: #005ea2; + border: none; + box-shadow: 0 0 0 2px #005ea2, inset 0 0 0 2px white; +} + +.usa-radio__label { + display: flex; + flex-direction: column; + margin: 0; + max-width: 480px; + padding-left: 0; + box-sizing: border-box; +} + +:host input:focus { outline: none !important; } -// Formation override -va-radio-option label.usa-radio__label::before { - box-shadow: rgb(27, 27, 27) 0px 0px 0px 2px; - height: 20px; - width: 20px; - margin-left: 2px; +// Formation overrides +input[type=radio] + label { + margin-bottom: 0; } -va-radio-option .usa-radio__input:focus + [class*='__label']::before { - outline: 2px solid var(--vads-color-action-focus-on-light); +input[type=radio] + label:before { + border-radius: 0; + box-shadow: none; + height: 0; + line-height: 0; + margin-left: 0; + margin-right: 0; + width: 0; } -va-radio-option input[disabled='true']:focus + label.usa-radio__label::before { +input[type=radio]:checked + label:before { outline: none; -} \ No newline at end of file + box-shadow: none; +} diff --git a/packages/web-components/src/components/va-radio-option/va-radio-option.tsx b/packages/web-components/src/components/va-radio-option/va-radio-option.tsx index 7e6f88863..fc6f94b4f 100644 --- a/packages/web-components/src/components/va-radio-option/va-radio-option.tsx +++ b/packages/web-components/src/components/va-radio-option/va-radio-option.tsx @@ -72,30 +72,22 @@ export class VaRadioOption { render() { const { checked, name, value, label, disabled, tile, description } = this; const id = this.el.id || name + value; - const ariaChecked = checked ? 'true' : 'false'; - const inputClass = classnames({ - 'usa-radio__input': true, - 'usa-radio__input--tile': tile, + const containerClass = classnames('usa-radio', { + 'va-radio-option__container--tile': tile, }); return ( -
+
this.handleChange()}> this.handleChange()} id={id + 'input'} /> -