facebookincubator / infima

A UI framework that provides websites with the minimal CSS and JS needed to get started with building a modern responsive beautiful website
https://infima.dev
MIT License
408 stars 55 forks source link

fix: breadcrumb links without `href` should not have hover styles #266

Closed srmagura closed 2 years ago

srmagura commented 2 years ago

Breadcrumb items do not necessarily have an href, but they always change color when the user hovers over them. The hover styles give the impression that the breadcrumb item is a clickable link even if this is not the case.

This can be seen in the Redux documentation — neither "Tutorials" nor "Redux Essentials" are links, yet they have hover styles.

This PR uses the :link pseudoselector to fix this.

Edit: Signed the CLA.

facebook-github-bot commented 2 years ago

Hi @srmagura!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

netlify[bot] commented 2 years ago

Deploy Preview for infima ready!

Built without sensitive environment variables

Name Link
Latest commit b29d28949bf24d2b0d58c9f1286c7aed9d2d945a
Latest deploy log https://app.netlify.com/sites/infima/deploys/62c43b2fdd602700083545b9
Deploy Preview https://deploy-preview-266--infima.netlify.app/demo
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

facebook-github-bot commented 2 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

srmagura commented 2 years ago

Thanks for the feedback. I switched to :any-link and added an example.

breadcrumb items might be simple instead of when we don't have a link

True, but I assume you would not want hover styles if the breadcrumb item is a <span>, correct?

Josh-Cena commented 2 years ago
diff --git a/packages/core/dist/css/default/default.css b/packages/core/dist-branch/css/default/default.css
index 95fc6e3..f258e29 100644
--- a/packages/core/dist/css/default/default.css
+++ b/packages/core/dist-branch/css/default/default.css
@@ -1233,[7](https://github.com/facebookincubator/infima/runs/7197269101?check_suite_focus=true#step:4:7) +1233,25 @@ a {
   transition: color var(--ifm-transition-fast) var(--ifm-transition-timing-default);
 }

-a:hover {
+a:link:hover, a:visited:hover {
+    color: var(--ifm-link-hover-color);
+    /* autoprefixer: ignore next */
+    text-decoration: var(--ifm-link-hover-decoration);
+  }
+
+a:-webkit-any-link:hover {
+    color: var(--ifm-link-hover-color);
+    /* autoprefixer: ignore next */
+    text-decoration: var(--ifm-link-hover-decoration);
+  }
+
+a:-moz-any-link:hover {
+    color: var(--ifm-link-hover-color);
+    /* autoprefixer: ignore next */
+    text-decoration: var(--ifm-link-hover-decoration);
+  }
+
+a:any-link:hover {
     color: var(--ifm-link-hover-color);
     /* autoprefixer: ignore next */
     text-decoration: var(--ifm-link-hover-decoration);
@@ -172[8](https://github.com/facebookincubator/infima/runs/7197269101?check_suite_focus=true#step:4:8),7 +1746,22 @@ hr {
     transition-timing-function: var(--ifm-transition-timing-default);
   }

-.breadcrumbs__link:hover {
+.breadcrumbs__link:link:hover, .breadcrumbs__link:visited:hover, area.breadcrumbs__link[href]:hover {
+      background: var(--ifm-breadcrumb-item-background-active);
+      text-decoration: none;
+    }
+
+.breadcrumbs__link:-webkit-any-link:hover {
+      background: var(--ifm-breadcrumb-item-background-active);
+      text-decoration: none;
+    }
+
+.breadcrumbs__link:-moz-any-link:hover {
+      background: var(--ifm-breadcrumb-item-background-active);
+      text-decoration: none;
+    }
+
+.breadcrumbs__link:any-link:hover {
       background: var(--ifm-breadcrumb-item-background-active);
       text-decoration: none;
     }
srmagura commented 2 years ago

@Josh-Cena Why are those changes necessary? I tested in Chrome, Safari, and Firefox and the vendor prefixes were not necessary.

Josh-Cena commented 2 years ago

Ah, no, that's the "post diff comment" workflow's result 😄 It can't be posted on PRs created from forks, so I manually post it so we know how the distributed CSS has changed. See https://github.com/facebookincubator/infima/pull/255#issuecomment-1120486531 for example.

srmagura commented 2 years ago

Ooooohhhhh, OK. Do I need to do anything to get that workflow to pass?

Josh-Cena commented 2 years ago

No, it's a problem with our workflow plus some permission quirks. It's mostly okay this way.

slorber commented 2 years ago

LGTM thanks 👍