From d9dc1c1ddf6005b9dc48c3f731043ba66ada880d Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:53:51 +0200 Subject: [PATCH] refactor: using :user-*valid from now on (#936) --- source/_patterns/01-elements/_form-elements.scss | 14 ++++++-------- source/_patterns/01-elements/input/_input.md | 2 +- .../01-elements/input/input~invalid-attribute.md | 2 +- source/_patterns/01-elements/radio/_radio.md | 2 +- source/_patterns/01-elements/radio/radio.scss | 2 +- source/_patterns/01-elements/select/_select.md | 2 +- .../01-elements/select/select~invalid-attribute.md | 2 +- source/_patterns/01-elements/textarea/_textarea.md | 2 +- .../textarea/textarea~invalid-attribute.md | 2 +- source/_patterns/02-components/form/_form.md | 2 +- 10 files changed, 15 insertions(+), 17 deletions(-) diff --git a/source/_patterns/01-elements/_form-elements.scss b/source/_patterns/01-elements/_form-elements.scss index aa92e70e0f..0d0525dd0f 100644 --- a/source/_patterns/01-elements/_form-elements.scss +++ b/source/_patterns/01-elements/_form-elements.scss @@ -94,14 +94,12 @@ // TODO: maybe we could totally restructure this, work with a :not(select) instead, differentiate in between user-invalid and provide a fallback (https://github.com/db-ui/mono/pull/893), etc. %form-element-validation { &:not([aria-invalid]) { - &:not(:placeholder-shown) { - &:valid { - --formElement---borderColor: #{$db-color-green-600}; - } - - &:invalid { - --formElement---borderColor: #{$db-color-red-500}; - } + &:user-valid { + --formElement---borderColor: #{$db-color-green-600}; + } + + &:user-invalid { + --formElement---borderColor: #{$db-color-red-500}; } } } diff --git a/source/_patterns/01-elements/input/_input.md b/source/_patterns/01-elements/input/_input.md index 28ac1120e9..24a61f8ab4 100644 --- a/source/_patterns/01-elements/input/_input.md +++ b/source/_patterns/01-elements/input/_input.md @@ -24,7 +24,7 @@ The attribute doesn't even only take boolean values, but even also a list of spe Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. ## Accessibility support diff --git a/source/_patterns/01-elements/input/input~invalid-attribute.md b/source/_patterns/01-elements/input/input~invalid-attribute.md index 48f38867c0..f870d3fe54 100644 --- a/source/_patterns/01-elements/input/input~invalid-attribute.md +++ b/source/_patterns/01-elements/input/input~invalid-attribute.md @@ -8,4 +8,4 @@ order: 7 Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. diff --git a/source/_patterns/01-elements/radio/_radio.md b/source/_patterns/01-elements/radio/_radio.md index c402e8ae58..a98656dbd5 100644 --- a/source/_patterns/01-elements/radio/_radio.md +++ b/source/_patterns/01-elements/radio/_radio.md @@ -7,6 +7,6 @@ state: complete Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. [inspirational sources for this page]: # "https://www.uiguideline.com/components/radio" diff --git a/source/_patterns/01-elements/radio/radio.scss b/source/_patterns/01-elements/radio/radio.scss index 3caa4d0524..66f1fe9fd9 100644 --- a/source/_patterns/01-elements/radio/radio.scss +++ b/source/_patterns/01-elements/radio/radio.scss @@ -47,7 +47,7 @@ &:checked { border-width: to-em($pxValue: 6); } - // * the invalid style using the :invalid pseudo class (and [aria-invalid="true"] equivalent, see #136 and #141) + // * the invalid style using the :user-invalid pseudo class (and [aria-invalid="true"] equivalent, see #136 and #141) &:is(:user-invalid), &[aria-invalid="true"] { border-color: #c13e34; diff --git a/source/_patterns/01-elements/select/_select.md b/source/_patterns/01-elements/select/_select.md index 8dbbcf73a2..4183268592 100644 --- a/source/_patterns/01-elements/select/_select.md +++ b/source/_patterns/01-elements/select/_select.md @@ -13,6 +13,6 @@ If you would like to even also match those visual requirements, you would need t Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. [inspirational sources for this page]: # "https://www.uiguideline.com/components/select-dropdown" diff --git a/source/_patterns/01-elements/select/select~invalid-attribute.md b/source/_patterns/01-elements/select/select~invalid-attribute.md index 12091860c2..a98c06b582 100644 --- a/source/_patterns/01-elements/select/select~invalid-attribute.md +++ b/source/_patterns/01-elements/select/select~invalid-attribute.md @@ -8,4 +8,4 @@ order: 7 Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. diff --git a/source/_patterns/01-elements/textarea/_textarea.md b/source/_patterns/01-elements/textarea/_textarea.md index 75f04e57da..2d43334fc2 100644 --- a/source/_patterns/01-elements/textarea/_textarea.md +++ b/source/_patterns/01-elements/textarea/_textarea.md @@ -7,6 +7,6 @@ state: complete Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. [inspirational sources for this page]: # "https://www.uiguideline.com/components/textarea" diff --git a/source/_patterns/01-elements/textarea/textarea~invalid-attribute.md b/source/_patterns/01-elements/textarea/textarea~invalid-attribute.md index 0d3cf75632..dedc240237 100644 --- a/source/_patterns/01-elements/textarea/textarea~invalid-attribute.md +++ b/source/_patterns/01-elements/textarea/textarea~invalid-attribute.md @@ -8,4 +8,4 @@ order: 7 Please have a look especially at the section for form validation within the overall [components/forms](../components-form/index.html) page. -Additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. +Additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) as well. diff --git a/source/_patterns/02-components/form/_form.md b/source/_patterns/02-components/form/_form.md index 17c7365d5c..e781569f07 100644 --- a/source/_patterns/02-components/form/_form.md +++ b/source/_patterns/02-components/form/_form.md @@ -24,7 +24,7 @@ It's best to use the built-in and standard form validation, as these are standar Additionally this way you're following the principles of Progressive Enhancement - and in other words, any JavaScript only solution doesn't provide a graceful degradation and puts that whole functionality to the weakest layer in the stack even only. -Nevertheless additionally to the browser built-in pseudo-selector `:invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) on the elements `input`, `radio`, `select` and `textarea`. +Nevertheless additionally to the browser built-in pseudo-selector `:user-invalid` we're providing styling for the [`aria-invalid="true"` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute) on the elements `input`, `radio`, `select` and `textarea`. We can't toggle any given/static attribute in the DB UI Core product itself, as we don't want to use JavaScript in this basic product. As you'd also need to add individual error messages, please find some inspiration on the necessary HTML code implementation e.g. on Please find some more informations on the following pages: