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

Use Link component instead of anchor tag in Code Docs #45010

Merged
merged 4 commits into from
Feb 25, 2022

Conversation

bethanyaconnor
Copy link
Contributor

Switching to using the Link component from dsco instead of anchor tags in code docs.

This did cause a bit of a style change, but I assume that's intended.

Before:
Screen Shot 2022-02-23 at 3 38 38 PM

After:
Screen Shot 2022-02-23 at 3 37 39 PM

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@bethanyaconnor bethanyaconnor requested a review from a team February 23, 2022 23:46
Copy link
Contributor

@maddiedierker maddiedierker left a comment

Choose a reason for hiding this comment

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

re: the styling difference -- the color change is definitely intentional, and i think the weight change you made here is appropriate (i.e., the programming expression names used to be a higher weight and are just "regular" now). there doesn't seem to be a good design reason to have all the expression names be medium/bold

@@ -12,7 +13,9 @@ export default function CodeDocLink({programmingExpression}) {
);
} else {
return (
<a href={programmingExpression.link}>{programmingExpression.name}</a>
<Link href={programmingExpression.link} weight="regular">
Copy link
Contributor

Choose a reason for hiding this comment

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

"regular" is the default for the weight prop, so you can remove it unless you want to make sure the weight is never affected

@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import EmbeddedBlock from '@cdo/apps/templates/codeDocs/EmbeddedBlock';
import {Link} from '@dsco_/link';
Copy link
Contributor

Choose a reason for hiding this comment

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

this is more a question for feedback than anything, but is there a reason you used Link instead of TextLink in both places? in this case, there's no difference since you aren't using an icon with your link, but i'm interested if there is (or will be) a usage preference. the difference would basically be:

// what you have here
<Link href={programmingExpression.link} weight="regular">
  {programmingExpression.name}
</Link>

// alternative with TextLink
<TextLink
  href={programmingExpression.link}
  text={programmingExpression.name}
  weight="regular"
/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahhh I didn't realize the difference and got a bit distracted by the icon functionality. I think TextLink is better so I'll use that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also helped clarify that I can use Link for my non-text link. So I updated this PR to do that too. Not really much gained afaict but I'm already here

@@ -23,13 +24,13 @@ export default function EmbeddedBlock({blockName, link}) {

return (
<div>
<a href={link}>
<Link href={link}>
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm going to try to sneak in some small accessibility wins with this 😄 right now, screenreaders will read this element as "[not] visited, link, [whatever-href-is]", but if you add an "aria-label" to the child (since the child isn't a text node), the screenreader output will be more digestible: "[not] visited, link, [aria-label]"

an example is probably easier:

// screenreader: "visited, link, Go to Code Studio"
// anything that can resolve to a text node doesn't need an aria-label
<Link href="https://studio.code.org">Go to Code Studio</Link>

// screenreader: "visited, link, https://studio.code.org"
// what we have here
<Link href="https://studio.code.org">
  <div />
</Link>

// screenreader: "visited, link, Go to Code Studio"
<Link href="https://studio.code.org">
  <div aria-label="Go to Code Studio" />
</Link>

in this case, maybe the label should be blockName?

we may want to enforce this in <Link> at some point, but it's kind of a gray area because aria-label isn't always required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good thought! thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went a bit farther and added a prop to pass in the name of the expression, which is a bit more human readable

Copy link
Contributor

@maddiedierker maddiedierker left a comment

Choose a reason for hiding this comment

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

left an accessibility suggestion for the EmbeddedBlock link, but this looks great, bethany! thank you for migrating these components!

@bethanyaconnor bethanyaconnor merged commit a9d475c into staging Feb 25, 2022
@bethanyaconnor bethanyaconnor deleted the use-dsco-link-in-codedoclink branch February 25, 2022 14:31
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.

None yet

2 participants