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

Support link underline preference #3848

Closed
wants to merge 2 commits into from

Conversation

joshblack
Copy link
Member

@joshblack joshblack commented Oct 20, 2023

This is a follow-up to #3720 after it was reverted for the latest release. Original description included below.


This was initiated by our need for underlined links in blocks of text, and supports dotcom's new user setting to render links with underlines. The link underline setting is currently being tested on dotcom behind a feature flag.

A new setting has been added to the Storybook toolbar that allows us to preview what a component would look like when the user has specified that they prefer link underlines.

Closes https://github.com/github/primer/issues/2536

Screenshots

User who turned link underlines on in their GitHub settings

The navigation for a pull request page that now includes underlines for links that point to the branch, author, and commit

Additional context about link underline settings

Issue: https://github.com/github/releases/issues/3340
Dotcom PR: https://github.com/github/github/pull/278701

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

* adds Prose component and stories

* adds tests and makes some minor changes

* Create happy-rivers-attend.md

* handle link underline preferences

* adds visual regression testing

* fixes storybook ID in Prose docs data

* updates changeset with changed components data

* rm Prose component

* test(vrt): update snapshots

* test(e2e): separate storybook global args by semicolon instead of ampersand

* test(vrt): update snapshots

* update snapshots

---------

Co-authored-by: joshblack <joshblack@users.noreply.github.com>
@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2023

🦋 Changeset detected

Latest commit: 08f8153

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@joshblack joshblack changed the title Support link underline preference (#3720) Support link underline preference Oct 20, 2023
@github-actions
Copy link
Contributor

Uh oh! @joshblack, the image you shared is missing helpful alt text. Check your pull request body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

1 similar comment
@github-actions
Copy link
Contributor

Uh oh! @joshblack, the image you shared is missing helpful alt text. Check your pull request body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@joshblack
Copy link
Member Author

joshblack commented Oct 20, 2023

Quick rollout plan notes from @mperrotti:

  1. make sure BaseStyles is being imported or that --prefers-link-underlines is being set
  2. merge fix(Link): update underline={false} to disable underline #3838 that updates how underline works and cut a PRC release with those changes
  3. upgrade PRC in dotcom and request a review lab deployment to test things out

The postmortem for this incident was created over at: https://github.com/github/primer/discussions/2788

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 104.77 KB (+0.15% 🔺)
dist/browser.umd.js 105.36 KB (+0.15% 🔺)

@@ -26,6 +26,13 @@ const GlobalStyle = createGlobalStyle<{colorScheme?: 'light' | 'dark'}>`
details-dialog:focus:not(:focus-visible):not(.focus-visible) {
outline: none;
}

/* Used to fake conditional styles using a technique by Lea Verou: https://lea.verou.me/blog/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/ */
Copy link
Contributor

Choose a reason for hiding this comment

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

omg so clever!

/* We have to use a zero-width space character (\u200B) as the value instead of a regular whitespace character because styled-components strips out properties that just have a whitespace value. */
:root {--prefers-link-underlines: \u200B;}
[data-a11y-link-underlines='true'] {
--prefers-link-underlines: initial;
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think of using the off/on variables like Lea suggested in her blogpost for a clearer understanding of this variable assignment?

@@ -22,9 +22,9 @@ const hoverColor = system({

const StyledLink = styled.a<StyledLinkProps>`
color: ${props => (props.muted ? get('colors.fg.muted')(props) : get('colors.accent.fg')(props))};
text-decoration: ${props => (props.underline ? 'underline' : 'none')};
text-decoration: ${props => (props.underline ? 'underline' : 'var(--prefers-link-underlines, underline)')};
Copy link
Member

Choose a reason for hiding this comment

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

Assuming BaseStyles is an optional wrapper... (correct me if it's not!)

Instead of changing the default, should we keep that default and let folks change the default by switching-on --prefers-link-underlines?

text-decoration: props.underline ? 'underline' : 'var(--prefers-link-underlines, none)'

If --prefers-link-underlines is not defined, for example when BaseStyles is not imported, the fallback would be none

Copy link
Member

Choose a reason for hiding this comment

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

@joshblack @pksjce Does this sound right or am I missing the goal here?


/* Used to fake conditional styles using a technique by Lea Verou: https://lea.verou.me/blog/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/ */
/* We have to use a zero-width space character (\u200B) as the value instead of a regular whitespace character because styled-components strips out properties that just have a whitespace value. */
:root {--prefers-link-underlines: \u200B;}
Copy link
Member

Choose a reason for hiding this comment

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

Very cool hack! But we're only using this for one property: text-decoration so I'm not sure if we should prefer the explicit none here?

@joshblack
Copy link
Member Author

Superseded by: #3946

@joshblack joshblack closed this Nov 30, 2023
@joshblack joshblack deleted the feat/add-link-underline-preference-setting branch November 30, 2023 22:19
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.

4 participants