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

Tech story [M3-6795]: Consolidate Link & ExternalLink #9411

Merged
merged 22 commits into from
Jul 23, 2023

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Jul 17, 2023

Description 📝

One component to rule them all! 💍

This PR refactors the Link component so it can be used for all three use cases:

  • a relative URL, which will render a Link component from React Router.
  • an absolute, same domain/subdomain URL (ex: linode.com, akamai.com) that will render an a tag with target="_blank".
  • an absolute URL with the external prop, which will render an a tag with target="_blank" and an external link icon.

Preview 📷

Visual changes should only pertain to the presence (or not) of some external links. Remember that links opening in a new tab but directing a user to an Akamai or Linode domain/subdomain should not feature an external link icon

How to test 🧪

I can ask for reviewers to verify every link modified by this PR, however the areas to look for visual regressions or bad links should be:

  1. Empty state landing pages
  2. Docs Links on create pages (next to create buttons) (note - they are closer to the button now, which is intentional)
  3. Help & Support area pages
  4. Profile area
  5. Storybook Link stories

@abailly-akamai abailly-akamai self-assigned this Jul 18, 2023
Opens an external site in a new window
</span>
</div>
<GoTo open={goToOpen} onClose={() => setGoToOpen(false)} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of this PR we do not need these IDs to refer our markup to for external links. This was not the cleanest way ^

target="_blank"
>
:)
</a>
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 don't want to crush any attempt at humor in our codebase, but this seems over the top 🤣

Copy link
Contributor

Choose a reason for hiding this comment

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

Humor crumbler! 🍪 No, agreed, this little easter egg has had it's run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modifying the DocsLink to use comply to our new API - also cleaned it up and replaced its .mdx story

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting this to not use yet another abstraction - this is for empty landing pages and we're making use of the new Link API now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

External Link shouldn't really be a stand alone now

onClick={onEdit}
>
Edit
</LinkButton>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Small style adjustment I noticed was needed - unrelated to this refactor

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch on the abnormally large 'Edit'.

Copy link
Member

Choose a reason for hiding this comment

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

The large edit button was in the mockups when we built the phone verification feature, but I'm cool with making it more normal. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to this PR. pretty sure this will go away as well eventually, but for now it is being used and I converted it to use the right component VS spreading styles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Goodbye ExternalLink, it's been a slice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored the empty state landing pages to use the new API - we don't need yet another abstraction!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored DocsLink to use the new API. No need to abstract that much. Also moved its story under component/Link since they are very much related

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DocsLink has been refactored to use the new Link API instead of a previous button. Those should be links!

@abailly-akamai abailly-akamai marked this pull request as ready for review July 19, 2023 18:32
@abailly-akamai abailly-akamai force-pushed the tech-story-M3-6795 branch 3 times, most recently from a080f9a to 622373a Compare July 20, 2023 18:11
<span id="external-site-new-window">
Opens an external site in a new window
</span>
</div>
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 is lo longer needed since we changed the API to no refer to those IDs

Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

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

Every link I could find looked good! Nice job on this... so much cleaner 🧼

@bnussman-akamai bnussman-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Jul 20, 2023
Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Thank you for all the work on this! It's exciting to have standardized our linking. I did a pretty thorough look at the diff and clicking around the areas you called out in the testing section. Approving, since I found no major issues - called out minor ones in comments.

I tried to keep an eye out for links that are currently external links and were previously ExternalLinks with hideIcon as a prop, because there's likely a UI reason we weren't displaying the icon and some styling is needed to make it better. I only caught a couple places where this was the place in OBJ (commented below); hopefully we don't come across others that I missed.

One other thing I found:

On http://localhost:3000/support/search/?query=test, there are links that are the wrong color in dark mode... and they're not actually links at all, but ListItems within the DocumentationResults component. These should really be Links. Mentioning it here, but it could be a follow up ticket if we want to stick with the current scope.

Screenshot 2023-07-20 at 2 59 45 PM

target="_blank"
>
:)
</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Humor crumbler! 🍪 No, agreed, this little easter egg has had it's run.

</a>
{props.isReply ? 'reply' : 'question'}. For more examples see this{' '}
<Link external to="http://demo.showdownjs.com/">
markdown cheatsheet
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should still be capitalized since it's the name of a language

Suggested change
markdown cheatsheet
Markdown cheatsheet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL a Hively component exists!

onClick={onEdit}
>
Edit
</LinkButton>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch on the abnormally large 'Edit'.

Comment on lines 142 to 144
<Link to={currentProvider.href}>
{`${currentProvider.displayName}` + ` website`}
</Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Link to={currentProvider.href}>
{`${currentProvider.displayName}` + ` website`}
</Link>
<Link external to={currentProvider.href}>
{`${currentProvider.displayName}` + ` website`}
</Link>

Shouldn't this be considered an external link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

Comment on lines +82 to +84
<Link external to={`https://${hostname}`}>
{truncateMiddle(hostname, 50)}
</Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

If we show the external link icon here, I think we need some padding.

Screenshot 2023-07-20 at 2 35 35 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

Comment on lines +76 to +78
<Link external to={url}>
{truncateMiddle(url, 50)}
</Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue as BucketDetailsDrawer, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

</div>
</>
);
expect(flattenChildrenIntoAriaLabel(children)).toBe('First Second Third');
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for these tests. I was looking to understand if this function was doing what I thought.

Copy link
Contributor

Choose a reason for hiding this comment

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

Empty state landing looks better with white icons (in dark mode) and the docs arrow icon spacing change!

* This story is deprecated and will be removed in a future release.
* Please use the `ExternalLink` component when you need to render an external link.
* An instance of Link component given an absolute URL, rendering an `a` tag with `target="_blank"`.
* This version provides an `external` prop, usually belonging to the same domain or a subdomain.<br />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* This version provides an `external` prop, usually belonging to the same domain or a subdomain.<br />
* This version provides an `external` prop, to be used when the site does not belong to the same domain or a subdomain.<br />

Is this what we mean here? Otherwise, I'm a little confused.

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! you're right, fixed!

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jul 20, 2023
@abailly-akamai
Copy link
Contributor Author

@bnussman-akamai @mjac0bs thanks so much for the reviews!

I addressed all feedback and also fixed the wrong markup on the search result page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants