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

feat(link): introduce inline variant #3859

Merged
merged 17 commits into from
Sep 12, 2019

Conversation

asudoh
Copy link
Contributor

@asudoh asudoh commented Aug 29, 2019

Fixes #3228.

Changelog

New

  • Inline link variant.

Testing / Reviewing

Testing can be done by looking at the inline link, open Chrome DevTools, go to Elements tab, select the <a>, and click on :hov button and change :active, etc. states.

@netlify
Copy link

netlify bot commented Aug 29, 2019

Deploy preview for carbon-components-react failed.

Built with commit a23b1dd

https://app.netlify.com/sites/carbon-components-react/deploys/5d7a299af2693100085c6fe9

@netlify
Copy link

netlify bot commented Aug 29, 2019

Deploy preview for the-carbon-components ready!

Built with commit a23b1dd

https://deploy-preview-3859--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Aug 29, 2019

Deploy preview for carbon-elements ready!

Built with commit a23b1dd

https://deploy-preview-3859--carbon-elements.netlify.com

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

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

looks good to me pending design review

image

Copy link
Collaborator

@tw15egan tw15egan left a comment

Choose a reason for hiding this comment

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

I'm seeing hover styles applied when the disabled class is active.

Screen Shot 2019-08-29 at 11 14 33 AM

Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

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

Two comments:

Disabled link has hover state (both vanilla & react):

Aug-29-2019 15-47-51

Focus state should not have underline

I noticed this is a current focus state on default link too. If this needs to be a separate issue that's okay too.

Current:
image

Should be:
image

Copy link
Contributor

@vpicone vpicone left a comment

Choose a reason for hiding this comment

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

@shixiedesign Is it intentional that disabled and visited have no underline?

Just like the only marker of a link being blue is insufficient, the same holds true for light grey and purple.

It is still a link even though it's been visited or disabled. For a11y purposes, there should be a second indicator of it being a link other than just the color.

.#{$prefix}--link--inline {
text-decoration: underline;

&:hover {
Copy link
Contributor

Choose a reason for hiding this comment

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

The hover color is incorrect in the normal link component above (link-01 as opposed to hover-primary-text) src. We should fix it there rather than having it only be correct for the inline style.

Copy link
Contributor

Choose a reason for hiding this comment

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

Per our style page, the default link component should also have a visited style that's being added here. It should instead be added to the regular link component unless that distinction is intentional @shixiedesign

@shixiedesign
Copy link
Contributor

shixiedesign commented Aug 30, 2019

@vpicone I think you might be right. We want to keep the "variant" styling consistent between default & visited states so they are recognizable as the same component. So @asudoh if you don't mind, I updated the spec for inline link. From what I see at the moment, inline link's visited state currently have an underline, so we are all good there. Only need to add underline to disabled state.

image

Another bug I noticed: our default link currently don't have visited state. It should gain the purple color, but no underline, to stay consistent with its default state.

image

Thanks for fixing the underline on focus!

@asudoh
Copy link
Contributor Author

asudoh commented Sep 2, 2019

Thanks the team for the input and especially @shixiedesign for taking time for updating the spec. Incorporated the spec update.

Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

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

I see the earlier comments are all addressed! Thank you! Just noticed 1 last thing:

  • visited link should still get a color state color change, like the default state. The purple link on hover should turn dark blue.

Sep-03-2019 10-08-58

Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Seems great 👍 should we add tests too for this behavior, or should it be good enough as-is?

vpicone
vpicone previously requested changes Sep 4, 2019
text-decoration: none;
}

&:visited {
Copy link
Contributor

@vpicone vpicone Sep 4, 2019

Choose a reason for hiding this comment

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

Do we need to define this behavior a second time? since it's covered by the regular link class now? Having it match two rules means unintended specificity.

Copy link
Contributor Author

@asudoh asudoh Sep 4, 2019

Choose a reason for hiding this comment

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

Good catch, thanks.

}

&:visited {
text-decoration: none;
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate pseudo selector

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks.

<p class="{{@root.prefix}}--link--disabled">Disabled Link</p>
<a href="#" class="{{@root.prefix}}--link{{#if inline}} {{@root.prefix}}--link--inline{{/if}}">Link</a>
<a class="{{@root.prefix}}--link{{#if inline}} {{@root.prefix}}--link--inline{{/if}}" aria-disabled="true">Placeholder link</a>
<p class="{{@root.prefix}}--link--disabled{{#if inline}} {{@root.prefix}}--link--inline{{/if}}">Disabled Link</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason this is a p element here? In the React component, the element remains an a element, and has both bx--link and bx--link--disabled added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It came from #1802, seems that it was for achieving styling requirements. @emyarod Do you have a details? I thought we had a discussion somewhere, but where it was completely slipped my mind (my apologies). My quick searches and following links from #1802 didn't reveal any, but I may be missing something.

Copy link
Member

Choose a reason for hiding this comment

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

I think it was to emphasize that simply adding the disabled link class would not be enough to actually disable an anchor. I think an anchor without an href could replace the p example here

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't find the conversation but we've talked about the disabled links before. For a11y the demo should be:

<span role="link" aria-disabled="true" class="{{@root.prefix}}--link--disabled{{#if inline}} {{@root.prefix}}--link--inline{{/if}}">Disabled Link</span>

It's not a paragraph so it shouldn't be using a p tag. The role tells screen reader users that the intention is that it's a link and the aria-disabled informs them that it's disabled

const classNames = classnames(`${prefix}--link`, className, {
[`${prefix}--link--disabled`]: disabled,
[`${prefix}--link--inline`]: inline,
});
return (
<a href={other.disabled ? null : href} className={classNames} {...other}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should just be disabled, since we now pull disabled out

@tw15egan
Copy link
Collaborator

tw15egan commented Sep 4, 2019

I'm still seeing inconsistent styling between the Vanilla and React implementations. Vanilla looks fine, but it is using a p instead of an a.

In React, I am still setting styles applied when disabled is set.

Seems like these styles may need to be updated, like removing pointer-events: none (so that
not-allowed cursor shows in React

@tw15egan
Copy link
Collaborator

tw15egan commented Sep 4, 2019

cc @shixiedesign, should the link color be $interactive-01 or $link-01? Website states $interactive-01. Should that be fixed on the website, or should the color be changed here?

Ref: #3902

@shixiedesign
Copy link
Contributor

shixiedesign commented Sep 4, 2019

Ooh good catch. @tw15egan Website's wrong in this case! We created $link-01 for....links. I will make a PR to correct that.

@asudoh
Copy link
Contributor Author

asudoh commented Sep 5, 2019

@tw15egan Good point on vanilla/React parity. I made a change to align React to vanilla for now (in addition to other.disabled vs. disabled change), but pointer-events approach may be valid (I recall I was personally inclined to that at some point). Will wait for feedback from @emyarod.

@tw15egan
Copy link
Collaborator

tw15egan commented Sep 5, 2019

@asudoh pointer-events disables is fine with me, just want to make sure we have parity between React and Vanilla. I guess it is more of a design question.

Thanks for the quick updates!

@emyarod
Copy link
Member

emyarod commented Sep 6, 2019

it's worth noting that the spec has undergone several major changes since #1802, and currently it seems that setting pointer-events is not needed

@asudoh
Copy link
Contributor Author

asudoh commented Sep 6, 2019

Thanks @emyarod for the input. Currently pointer-events is used only at https://github.com/carbon-design-system/carbon/blob/v10.6.0/packages/components/src/components/link/_link.scss#L50. Do you think we should remove it, too, and if it's the case, does it mean we should no longer do "non-clickable unless href exists" feature?

I guess what we have as-is (adding this PR) sounds good, but just double-checking. Thanks!

@emyarod
Copy link
Member

emyarod commented Sep 9, 2019

@asudoh I think it's fine to leave that one as is since I believe we want to keep it nonclickable unless href exists

@asudoh
Copy link
Contributor Author

asudoh commented Sep 10, 2019

Resetting the review status given all comments have been addressed. Feel free to jump in if anybody has further thoughts - Thanks everybody for your input!

@asudoh asudoh dismissed stale reviews from vpicone and tw15egan September 10, 2019 06:15

All review comments has been addressed.

@shixiedesign
Copy link
Contributor

Hi @asudoh!

  • Looks like link lost the active color in React? On mouse down it should take on $text-01
    Sep-10-2019 10-38-10

@asudoh
Copy link
Contributor Author

asudoh commented Sep 11, 2019

@shixiedesign Thank you for your review! I see it turns to #171717 ($text-01) when I mouse-down on the link. I could also see that when I forced the active state by selecting the <a> in DevTools, selecting :hov icon and selecting :active. That said, wondering what happens if you force active state.

Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

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

Hmm now the active state is working for me. Thanks! Great work. 🎉

@asudoh
Copy link
Contributor Author

asudoh commented Sep 12, 2019

Thanks @shixiedesign for reviewing! 🙇

@asudoh asudoh merged commit f167fd6 into carbon-design-system:master Sep 12, 2019
@asudoh asudoh deleted the link-inline branch September 12, 2019 11:30
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.

[Link] Add inline link variant
7 participants