-
Notifications
You must be signed in to change notification settings - Fork 23
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
Link Component #5502
base: main
Are you sure you want to change the base?
Link Component #5502
Conversation
🦋 Changeset detectedLatest commit: 2bd25f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
return ( | ||
<FrontendServices {...config}> | ||
{/* application code */} | ||
<RacRouterProvider navigate={(href, opts) => router.push(href, undefined, opts)}> |
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.
can we make this provider part of next-services so it works for the consuming teams out of the box and without extra config?
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.
Hey @jakubriedl did you mean before this release goes out?
I certainly think that makes sense as a future / subsequent goal, but don't think it should block this specific release since the component is agnostic to the routing solution and standard hrefs will work out of the box.
Potentially a good opportunity for @Zystix once this is done (noting we only have him till the end of Feb), but will also raise with the team to see when we can prioritize the work
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.
yeah totally agree this shouldn't be blocker. But I'd add it there at the same time as it's just small change and write the documentation in the expects it to be there. It'll save you a lot of explaining to teams what they have to do, just say in the docs "have up-to-date next-services" and you can skip this whole section. Easier for you, and for the consumer as well
packages/components/src/Link/_docs/Link--api-usage-guidelines.mdx
Outdated
Show resolved
Hide resolved
--text-icon-gap: var(--spacing-2); | ||
} | ||
|
||
[class^='small'] .isInline > *, |
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.
What's the reason for the attribute selector use here? Can it just be .small
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.
Because of the hashing of classes it can't "see" the .small class of the component its wrapped in when inline. It does feel like a cable ties solution though
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 css module will apply the correct hash as part of the postcss plugin so you can just reference it as a normal class
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.
Didn't appear to work when we tried it? Does it look for the hash for link.module.css file?
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.
Another note is that the .[size] .isInline > *
selector is never applied due to your condition of not applying the styles when isInline is false.
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 is the desired functionality, this is how we're achieving grabbing the parent Text's size class when the Link isInline
. Is there anything you'd change 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.
Yeah for all the selectors there you can drop the comma separated class e.g.
[class*='extra-small'] .isInline > *,
.extra-small <-- don't need this
Just do
[class*='extra-small'] .isInline > * {
...
}
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'll also add that the class^='small'
will never actually match (at least not in storybook) as the class begins with a _
so it never finds a class starting with small
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 feel like this is a bit of code smell relying on a parent component class to make changes, can we do this within code and know the size being passed down?
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 can inherit the text size, the issue I think lies more in the icon sizing and spacing between the text and icon. We initially thought we might be able to leverage em
to calculate a ratio based on the size but map to a cleanly between each font size.
Or were you thinking more like JS to look at the parent node and get the computed style to determine a size based off that?
packages/components/src/Link/_docs/Link.stickersheet.stories.tsx
Outdated
Show resolved
Hide resolved
className={mergeClassNames( | ||
styles.link, | ||
isDisabled && styles.isDisabled, | ||
!isInline && styles[size], |
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 is the condition I'm referring to, your class selector is never applied due to the fact that the size classes aren't added when the component has isInline set to true
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 this is the desired functionality, we still allow the size to be passed cos we couldn't get the discriminated union to behave. Would be good to get that sorted though
Something else to consider (I don't know if both a relevant anymore) but you might want to look at seeing if adding Seems having https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener |
packages/components/src/Link/_docs/Link--api-usage-guidelines.mdx
Outdated
Show resolved
Hide resolved
packages/components/src/Link/_docs/Link--api-usage-guidelines.mdx
Outdated
Show resolved
Hide resolved
|
||
export const LinkOpensInNewTab: Story = { | ||
render: (props) => ( | ||
<Link {...props} target="_blank" icon={<ExternalLinkIcon role="presentation" />} /> |
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'd also recommend we use the end
icon position with this one
@@ -0,0 +1,184 @@ | |||
import React from 'react' | |||
import { type Meta, type StoryObj } from '@storybook/react' | |||
import { ExternalLinkIcon, FlagOffIcon } from '~components/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.
We need to replace with these usages with the RC icon Icon component - this is why the external link icons look larger than they should be
--link-font-size: var(--typography-paragraph-extra-small-font-size); | ||
--link-line-height: var(--typography-paragraph-extra-small-line-height); | ||
--icon-font-size: 0.875rem; | ||
--text-icon-gap: var(--spacing-2); |
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.
In fact all of these variables do not have any effect as they are scoped to this selector and the variables are used up the selector scope
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.
Ah, doesn't work when isInline
, I'm pretty sure it used to so I might have broken something when cleaning up.
export const WithText: Story = { | ||
render: (props) => ( | ||
<> | ||
<Text variant="extra-small"> |
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.
|
||
### Icons and positioning | ||
|
||
The `icon` property abstracts the need to handle positioning and sizing of icons within the `Link` component. The `iconPosition` prop allows for the icon to be positioned to the left or right 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.
Since this is a JSX element, it might be worth calling out that the intended component to be used here is the new Icon component and link out the API specification for it :)
--text-icon-gap: var(--spacing-2); | ||
} | ||
|
||
[class^='small'] .isInline > *, |
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 can inherit the text size, the issue I think lies more in the icon sizing and spacing between the text and icon. We initially thought we might be able to leverage em
to calculate a ratio based on the size but map to a cleanly between each font size.
Or were you thinking more like JS to look at the parent node and get the computed style to determine a size based off that?
Why
Creating a new Link component.
https://cultureamp.atlassian.net/browse/KZN-2593
What
Adds the Link component, storybook tests, sticker sheets, API spec and usage guidelines.