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 TextLink from @dsco_/link in SmallChevronLink #44759

Merged
merged 12 commits into from
Feb 14, 2022
Merged

Conversation

maddiedierker
Copy link
Contributor

@maddiedierker maddiedierker commented Feb 10, 2022

This is the first integration of our component library into Code.org! 🎉

Adds the TextLink component from @dsco_/link. The existing SmallChevronLink component is a specific type of TextLink that always has a chevron icon, so it seemed like a great initial consumer.

The main visual/UX changes are:

  • The link text is underlined on hover. This should become standard since it's defined in our design system.
  • RTL improvements (shown below)
  • Accessibility improvements (general to the TextLink component): The icon is hidden from screenreaders when paired with text (source). If the link is icon-only, the consumer should provide an aria-label for the screenreader to use as an identifier (doesn't apply to this use-case, but I provided it anyways to show best practice -- it will likely be required when the component library provides an Icon component).

Storybook

(I'm hovering over the first link in the image below)

Screen Shot 2022-02-10 at 9 27 20 AM

Consumers

There were only 2 consumers of SmallChevronLink, so I'm outlining the before/after for both here.

/teacher_dashboard/sections/:section_id - "View all sections" link

LTR - no visual change

Screen Shot 2022-02-10 at 10 00 41 AM

RTL

Before
Screen Shot 2022-02-10 at 10 02 29 AM

After
Screen Shot 2022-02-10 at 10 02 03 AM

/s/:script_name - "Add New Section" link

LTR - no visual change

Screen Shot 2022-02-10 at 10 07 05 AM

RTL

Before
Screen Shot 2022-02-10 at 10 08 56 AM

After
Screen Shot 2022-02-10 at 10 08 42 AM

Links

Testing story

Adds/updates storybook entries.

]);
storybook
.storiesOf('TeacherSectionSelector', module)
.withReduxStore()
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 the only actual change in this file -- i hooked these stories up to redux now that <SmallChevronLink> uses redux

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder at some point we want to stop using redux for isRtl. Would it be possible to just use the html dir instead?

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! although it would require some refactoring to our React styles that respond to isRtl. i don't know how doable this is with radium, though -- i think we could check the HTML dir with <Style>, but that would require refactoring and introducing a new feature of radium that we don't currently use, and i'm not sure how much we want to invest in radium since it's deprecated and we should be moving away from it.

on the storybook side, i think we would just have to add the storybook-addon-rtl addon

import LargeChevronLink from './LargeChevronLink';
import i18n from '@cdo/locale';

export default storybook => {
return storybook
.storiesOf('ChevronLinks', module)
.storiesOf('LargeChevronLink', module)
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 separated the SmallChevronLink and LargeChevronLink stories into separate files since the components are in separate files -- each component/file should have its own storybook file

@dmcavoy
Copy link
Contributor

dmcavoy commented Feb 10, 2022

@madelynkasula should the link at the top of the script overview page that links back to the course overview page use this component? https://studio.code.org/s/csd3-202
Screen Shot 2022-02-10 at 4 00 07 PM
1

@maddiedierker
Copy link
Contributor Author

should the link at the top of the script overview page that links back to the course overview page use this component?

@dmcavoy it should! but there are a couple of reasons i don't think it should be part of this change:

  1. this is the first migration, so i want to keep any negative impact as small as possible
  2. the link you pointed to is purple, so there is a product/design decision to make here -- are we okay with links being purple, or do we want to begin to enforce the color of links? TextLink accepts a className prop, so changing the color is doable, but part of adopting the design system will be:
    a. making decisions about where we should and shouldn't stray from the core component design, and
    b. deciding when a variant like this should be part of the design system (and updating the component library to support this variant). cc @moneppo on this as well

in general, after this migration has shipped successfully, we should definitely begin adopting TextLink (or SmallChevronLink -- i was surprised to see that we don't use it more because we use this pattern across the site) anytime we need a link with text and/or an icon

Copy link
Contributor

@maureensturgeon maureensturgeon left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

nice work @madelynkasula , it is awesome to see this come together!

@maddiedierker
Copy link
Contributor Author

maddiedierker commented Feb 10, 2022

note to reviewers: i'm going to bump the version for @dsco_/link (just a patch version) and incorporate it here to pull in the change in this PR (edit: and this follow-up PR)

there's no functional change, just a change in the way i was polyfilling CSS for old browsers

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

Successfully merging this pull request may close these issues.

None yet

5 participants