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 hover style of filled buttons that are anchors #1879

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cloudrac3r
Copy link

@cloudrac3r cloudrac3r commented Feb 3, 2025

This partially reverts a change in 4db47a6. Here is an example reproduction:

<a href="" class="s-btn s-btn__filled">Example</a>

Since 2.5.5, hover styles on that example have not worked correctly. This is because 2.5.5 changed a selector to .s-button..&:hover..&:visited:not(:active):not(:focus). This style applies to hovered and visited buttons. When it is applied, it sets the background colour to var(--_bu-filled-bg);, which is the standard background colour. Separately, the button hover selector has also matched this button and set the background colour to var(--_bu-filled-bg-hover);, but this selector is further up the file, so it has less priority. The hover style is being overwritten by this visited style.

I've fixed hovered visited link-buttons by undoing that change, since it doesn't seem to be related to the rest of 4db47a6.

I've confirmed that this change fixes the example, and I haven't seen any negative side-effects in my use case. 😊

Copy link

netlify bot commented Feb 3, 2025

👷 Deploy request for stacks pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b480838

@dancormier
Copy link
Contributor

Thanks for your contribution @cloudrac3r!

If you look at line 432, you'll see that the modification you made to exclude styling with :not(:hover)… is within a block specifically applying styles to :hover:

        &:hover {
            &.s-btn__filled {
                background-color: var(--_bu-filled-bg-hover);
                border-color: var(--_bu-filled-bc-hover);
                color: var(--_bu-filled-fc-hover);
            }

            &:not(.s-btn__outlined):not(.s-btn__filled) {
                border-color: var(--_bu-bc-hover);
            }

-            &:visited:not(:active):not(:focus) {
+            &:visited:not(:hover):not(:focus) {
                &.s-btn__filled {
                    background-color: var(--_bu-filled-bg);
                    border-color: var(--_bu-filled-bc);
                    color: var(--_bu-filled-fc);
                }

                &:not(.s-btn__outlined) {
                    background-color: var(--_bu-bg);
                    border-color: var(--_bu-bc);
                    color: var(--_bu-fc);
                }
            }
…

I believe the issue has to do with the styles from :not(.s-btn__outlined) overriding the styles applied to .s-btn__filled. It will require some investigation to resolve confidently, but for now, I've created a PR as a starting point and hope to get a fix merge in soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants