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

Enable triggering hover state on Checkbox and Radio externally #2516

Open
domidomi opened this issue Aug 19, 2022 · 0 comments
Open

Enable triggering hover state on Checkbox and Radio externally #2516

domidomi opened this issue Aug 19, 2022 · 0 comments

Comments

@domidomi
Copy link
Contributor

We need to be able to trigger hover state on the Checkbox and Radio with external component.

There is a way of doing that without js. We could use CSS classes and apply hover state styles whenever element with particular class gets hovered. These hover state styles are already defined in Radio and Checkbox - hover state is detected on the &__wrapper and style changes are being applied on the .sg-radio__circle/.sg-checkbox__icon. So it looks like this:

&__wrapper {
  &:hover {
    .sg-radio__circle {
      ...
    }
  }
}

We could use @at-root sass mechanism that allows prepending selectors, which will enable reusing the same styles, just in different context. So prepending that &__wrapper selector with @at-root .sg-hover-group:

@at-root .sg-hover-group,
&__wrapper {
  &:hover {
    .sg-radio__circle {
      ...
    }
  }
}

will result in creating such selectors:

.sg-hover-group:hover .sg-radio__circle,
.sg-radio__wrapper:hover .sg-radio__circle {
  ...
}

Then, if we want to trigger Checkbox/Radio hover state on some component mouseover, we can just add .sg-hover-group class to it.

@domidomi domidomi self-assigned this Aug 19, 2022
@domidomi domidomi changed the title Enable triggering hover state on Checkbox and Radio with externally Enable triggering hover state on Checkbox and Radio externally Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant