-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
Deploy preview for carbon-components-react failed. Built with commit a23b1dd https://app.netlify.com/sites/carbon-components-react/deploys/5d7a299af2693100085c6fe9 |
Deploy preview for the-carbon-components ready! Built with commit a23b1dd https://deploy-preview-3859--the-carbon-components.netlify.com |
Deploy preview for carbon-elements ready! Built with commit a23b1dd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@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 Another bug I noticed: our default link currently don't have Thanks for fixing the underline on focus! |
Thanks the team for the input and especially @shixiedesign for taking time for updating the spec. Incorporated the spec update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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?
text-decoration: none; | ||
} | ||
|
||
&:visited { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate pseudo selector
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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
I'm still seeing inconsistent styling between the Vanilla and React implementations. Vanilla looks fine, but it is using a In React, I am still setting styles applied when disabled is set. Seems like these styles may need to be updated, like removing
|
cc @shixiedesign, should the link color be Ref: #3902 |
Ooh good catch. @tw15egan Website's wrong in this case! We created |
@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! |
it's worth noting that the spec has undergone several major changes since #1802, and currently it seems that setting |
Thanks @emyarod for the input. Currently I guess what we have as-is (adding this PR) sounds good, but just double-checking. Thanks! |
@asudoh I think it's fine to leave that one as is since I believe we want to keep it nonclickable unless |
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! |
All review comments has been addressed.
Hi @asudoh! |
@shixiedesign Thank you for your review! I see it turns to |
There was a problem hiding this 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. 🎉
Thanks @shixiedesign for reviewing! 🙇 |
Fixes #3228.
Changelog
New
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.