-
Notifications
You must be signed in to change notification settings - Fork 305
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: Added external link icon #4757
Conversation
|
import { classNames } from '@aws-amplify/ui'; | ||
import { ComponentClassName } from '@aws-amplify/ui'; |
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 only be a single import line
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.
Unresolved, there are two import lines for the same package still. In the future, please refrain from resolving a conversation until the feedback has been addressed
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.
Looks like there are two import lines for the same package across multiple primitives, I'll make sure to make it one line when done with other updates on this PR.
@@ -25,6 +24,7 @@ const LinkPrimitive: Primitive<LinkProps, 'a'> = ( | |||
{...rest} | |||
> | |||
{children} | |||
{isExternal && <IconBoxArrowUpRight />} |
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.
Few things here:
- Prefer ternary returning
null
ifisExternal
is falsy to prevent this expression from evaluating tofalse
- How do i hide the icon?
- How do i position the icon to the left of the
children
?
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.
- Updated to use a ternary operator
- You can hide the icon when
isExternal
prop is set tofalse
(default) - It's important to start with a word that indicates the action that results if customers click the link. Putting an icon at the beginning of the link disrupts the readability of the link quite massively, therefore it is a common convention to put icons after the actual link text
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.
You can hide the icon when isExternal prop is set to false (default)
Sure, but what if the link is external and i don't want the icon?
It's important to start with a word that indicates the action that results if customers click the link. Putting an icon at the beginning of the link disrupts the readability of the link quite massively, therefore it is a common convention to put icons after the actual link text
- What abt RTL languages?
- This response is an opinion on the usage of the
Link
component but does not address the actual question
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 call on RTL languages. I'll work on adding a position prop, so devs can control the icon position
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.
@lavr001 The above question is still unanswered:
You can hide the icon when isExternal prop is set to false (default)
Sure, but what if the link is external and i don't want the icon?
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.
@calebpollman Are you suggesting having a new prop called hasIcon
that would be visible only when the link is external, so users can control if they want the icon or not?
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.
@calebpollman Added new prop hideIcon
, so now if the Link is external you have an option to show/hide the icon. Also added a new prop linkIconPosition
, so you can position the icon left or right to the Link
…fy/amplify-ui into add-external-link-icon
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.
Where did this icon come from and why is it not centered like the other icons?
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.
Since we don't typically use icons from the external libraries, I just looked online for a SVG path that forms the icon. I've added align-items: center
to make the icon vertically aligned, but I can take another look to see what else could be done to make it more vertically centered
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.
We are using a specific icon set from material, so we should be consistent and use the same one for this too. @dbanksdesign Do you remember which version we were using?
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 checked SVG icons from material and they didn't really have a specific external link icon, so I grabbed another SVG
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.
Where is this SVG taken from and what was the reasoning used in choosing it?
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 simply googled svg path for external icon, since we don't usually pull in icons from an external source. Not sure what do you mean by reasoning. Are you suggesting some other approaches 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.
Concerned overall with the approach taken here.
Rendering an icon by default for any Link
components that have an external link could break customers layouts that have added an icon themselves, nor are we providing a means to override the icon or hide it. Blocking this until all feedback is addressed and the PR no longer contains breaking changes
import { classNames } from '@aws-amplify/ui'; | ||
import { ComponentClassName } from '@aws-amplify/ui'; |
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.
Unresolved, there are two import lines for the same package still. In the future, please refrain from resolving a conversation until the feedback has been addressed
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.
Where is this SVG taken from and what was the reasoning used in choosing it?
@@ -25,6 +24,7 @@ const LinkPrimitive: Primitive<LinkProps, 'a'> = ( | |||
{...rest} | |||
> | |||
{children} | |||
{isExternal && <IconBoxArrowUpRight />} |
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.
@lavr001 The above question is still unanswered:
You can hide the icon when isExternal prop is set to false (default)
Sure, but what if the link is external and i don't want the icon?
Description of changes
Added external link icon when
isExternal
prop is trueBefore:
After:
Issue #4515 , if available
Description of how you validated changes
Checklist
yarn test
passes and tests are updated/addedsideEffects
field updatedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.