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: checkbox button semantic #5654

Merged
merged 8 commits into from
Nov 28, 2023
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
16 changes: 16 additions & 0 deletions packages/components/src/components/a11y.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@
font-size: inherit;
}
}

/**
* Sometimes we need the semantic element for accessibility reasons,
* but we don't want to show it.
*
* - https://www.a11yproject.com/posts/how-to-hide-content/
*/
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
9 changes: 3 additions & 6 deletions packages/components/src/components/input-checkbox/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
grid-template-columns: var(--a11y-min-size) auto;
grid-template-areas: 'error error' 'input label' 'hint hint';
}

.button[tabindex]:focus {
.button:focus-within {
/* override global `[tabindex]:focus` style */
cursor: inherit;
}

.button input {
display: none;
outline-color: black;
outline-style: solid;
}

.button > .error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class KolInputCheckbox implements API {
}}
data-role={this.state._variant === 'button' ? 'button' : undefined}
onKeyPress={this.state._variant === 'button' ? this.onChange : undefined}
tabIndex={this.state._variant === 'button' && !this.state._disabled ? 0 : undefined}
_accessKey={this.state._accessKey}
_alert={this.state._alert}
_disabled={this.state._disabled}
Expand Down Expand Up @@ -97,6 +96,7 @@ export class KolInputCheckbox implements API {
_label=""
/>
<input
class={this.state._variant === 'button' ? 'visually-hidden' : undefined}
ref={this.catchRef}
title=""
accessKey={this.state._accessKey} // by checkbox?!
Expand Down
7 changes: 7 additions & 0 deletions packages/themes/bmf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,13 @@ export const BMF = KoliBri.createTheme('bmf', {
:host kol-input.button .icon {
height: auto;
}
.button:focus-within {
border-radius: var(--a11y-min-size);
outline-color: var(--color-ocean);
outline-offset: 2px;
outline-style: solid;
outline-width: 3px;
}
`,
'KOL-INPUT-RADIO': css`
/* INPUT */
Expand Down
4 changes: 4 additions & 0 deletions packages/themes/bzst-v2/src/components/input-checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,8 @@
.disabled {
opacity: 0.33;
}

.button:focus-within {
outline: var(--color-focus) solid 2px;
}
}
4 changes: 4 additions & 0 deletions packages/themes/bzst/src/components/input-checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ input[type='checkbox']:checked {
.disabled {
opacity: 0.33;
}
.button:focus-within {
outline: var(--focusOutline);
outline-offset: 2px;
}
7 changes: 7 additions & 0 deletions packages/themes/default/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,13 @@ export const DEFAULT = KoliBri.createTheme('default', {
:host .disabled {
opacity: 0.33;
}
.button:focus-within {
border-radius: var(--border-radius);
outline-color: var(--color-primary-variant);
outline-offset: 2px;
outline-style: solid;
outline-width: calc(var(--border-width) * 2);
}
`,
'KOL-INPUT-RADIO': css`
label {
Expand Down
6 changes: 6 additions & 0 deletions packages/themes/ecl/src/ecl-ec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,12 @@ export const ECL_EC = KoliBri.createTheme('ecl-ec', {
.hint {
font-size: 0.875rem;
}
.button:focus-within {
outline-color: var(--color-blue);
outline-offset: 2px;
outline-style: solid;
outline-width: 2px;
}
`,
'KOL-INPUT-COLOR': css`
kol-input {
Expand Down
5 changes: 5 additions & 0 deletions packages/themes/ecl/src/ecl-eu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ export const ECL_EU = KoliBri.createTheme('ecl-eu', {
.hint {
font-size: 0.875rem;
}
.button:focus-within {
outline-color: var(--color-blue-130);
outline-style: solid;
outline-width: 2px;
}
`,
'KOL-INPUT-COLOR': css`
kol-input {
Expand Down
7 changes: 7 additions & 0 deletions packages/themes/itzbund/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,13 @@ export const ITZBund = KoliBri.createTheme('itzbund', {
order: 3;
padding: 0 var(--spacing);
}
.button:focus-within {
border-radius: 2rem;
outline-color: var(--color-achat) !important;
outline-offset: 2px;
outline-style: solid;
outline-width: 3px;
}
`,
'KOL-INPUT-RADIO': `/* INPUT */
:host input:focus {
Expand Down
10 changes: 9 additions & 1 deletion packages/themes/mfm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,15 @@ export const MFM = KoliBri.createTheme('mfm', {
}
:host .disabled {
opacity: 0.33;
}`,
}
.button:focus-within {
border-radius: 0.25rem;
outline-color: var(--color-ocean);
outline-offset: 2px;
outline-style: solid;
outline-width: 3px;
}
`,
'KOL-INPUT-RADIO': `/* INPUT */
kol-input {
display: grid;
Expand Down
7 changes: 7 additions & 0 deletions packages/themes/zoll/src/mapz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,13 @@ export const MAPZ = KoliBri.createTheme('mapz', {
.disabled {
opacity: 0.33;
}
.button:focus-within {
border-radius: var(--kolibri-border-radius);
outline-color: var(--kolibri-color-outline);
outline-offset: 2px;
outline-style: solid;
outline-width: 3px;
}
`,
'KOL-INPUT-RADIO': css`
label {
Expand Down
5 changes: 5 additions & 0 deletions packages/themes/zoll/src/v3/components/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,9 @@ export default css`
kol-input.button {
grid-template-areas: 'input label' 'error error' 'hint hint';
}

.button:focus-within {
outline: 0.125rem solid var(--color-blau);
outline-offset: 0.125rem;
}
`;
7 changes: 7 additions & 0 deletions packages/themes/zoll/src/zoll-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,13 @@ export const ZOLLv2 = KoliBri.createTheme('zoll-v2', {
.disabled {
opacity: 0.33;
}
.button:focus-within {
border-radius: var(--border-radius);
outline-color: var(--color-blau-dark);
outline-offset: 0.125rem;
outline-style: solid;
outline-width: 0.125rem;
}
`,
'KOL-INPUT-RADIO': css`
/* ALL INPUT, SELECT, TEXTAREA */
Expand Down
Loading