Skip to content

Commit

Permalink
refactor: using :user-*valid from now on (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzke authored Aug 22, 2024
1 parent cf81ce4 commit d9dc1c1
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 17 deletions.
14 changes: 6 additions & 8 deletions source/_patterns/01-elements/_form-elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/_patterns/01-elements/input/_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion source/_patterns/01-elements/radio/_radio.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion source/_patterns/01-elements/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/_patterns/01-elements/select/_select.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion source/_patterns/01-elements/textarea/_textarea.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion source/_patterns/02-components/form/_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://mars.dequecloud.com/demo/form-alert3.htm>

Please find some more informations on the following pages:
Expand Down

0 comments on commit d9dc1c1

Please sign in to comment.