Skip to content

feat: change color of label on hovered and active state #4077

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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.
51 changes: 51 additions & 0 deletions packages/components/src/styles/internal/_form-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,21 @@ $input-valid-types:
}
}

@mixin get-validity-color-check-label-color($state, $key: "valid") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we merge this with get-validity-color-check? There is a similar selector. Maybe we should change the complete @mixin set-default-check-element to use the $selector instead of &:has(input:not([role="switch"])).

There is another hover & pressed function for the input and for the disabled state. By rewriting the complete set-default-check-element we could save a lot of complexity. Just use hover pressed if not $selector=switch or radio:checked or input:disabled

$variant: successful;

@if ($key != "valid") {
$variant: critical;
}

&:has(input:not([role="switch"])) {
&:is(label),
> label {
color: var(--db-#{$variant}-on-bg-basic-emphasis-100-#{$state});
}
}
}

// CHECKBOX & RADIO

@mixin get-validity-color-check($key: "valid") {
Expand Down Expand Up @@ -495,6 +510,42 @@ $input-valid-types:
@include get-validity-color-check("invalid");
}

@include helpers.hover {
color: colors.$db-adaptive-on-bg-basic-emphasis-100-hovered;

@include get-validity($selector, "valid") {
@include get-validity-color-check-label-color(hovered, "valid");
}

@include get-validity($selector, "invalid") {
@include get-validity-color-check-label-color(hovered, "invalid");
}

@if ($selector == radio) {
input {
/* stylelint-disable-next-line db-ux/use-border-width */
border: #{$check-border-size}
solid
var(
--db-check-element-border-color,
#{colors.$db-adaptive-on-bg-basic-emphasis-100-default}
);
}
}
}

@include helpers.active {
color: colors.$db-adaptive-on-bg-basic-emphasis-100-pressed;

@include get-validity($selector, "valid") {
@include get-validity-color-check-label-color(pressed, "valid");
}

@include get-validity($selector, "invalid") {
@include get-validity-color-check-label-color(pressed, "invalid");
}
}

&:has(input:disabled) {
opacity: component.$default-disabled;
}
Expand Down
Loading