-
Notifications
You must be signed in to change notification settings - Fork 36
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
DOP-4028: Fix margin for links with svgs #911
Conversation
src/components/Link.js
Outdated
<ArrowRightStyling> | ||
{' '} | ||
<ArrowRightIcon role="presentation" size={12} />{' '} | ||
</ArrowRightStyling> |
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's not typical to use a css
variable as an element. Did you mean to use a styled
component?
As-is, I also don't see the left margin being applied (due to the use of the css
variable). I'm curious if this means that we don't even need the css and some whitespace is all we need?
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.
implemented these changes
arrowAppearance={showLinkArrow ? 'persist' : 'none'} | ||
target={target} | ||
{...other} | ||
> | ||
{children} | ||
{decoration} |
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 it possible to leave the arrowAppearance
prop as-is? I think it might be preferable to use LG's built-in prop for this instance
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 agree it would have been preferable, but I think the issue could become both arrows rendering or some rendering conflict in general.
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.
That might be the trade-off or I wonder if we could leverage the custom className
and apply the className
value in the ProductItem.js file
<StyledArticle>
<SectionHeader customStyles={customStyleHeader}>
{argument.map((child, i) => (
<ComponentFactory nodeData={child} key={i} />
))}
</SectionHeader>
{children.map((child, i) => (
<ComponentFactory nodeData={child} key={i} showLinkArrow={true} className='some-custom-className' />
))}
</StyledArticle>
Then we apply the style using that custom class name. This way it doesn't have an effect on the other links.
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.
For more clarity.
ProductItem
const customStylesForArrows = css` // choose a better name
> svg {
margin-left: 3px;
}
`;
// then pass it down as a prop
{children.map((child, i) => (
<ComponentFactory nodeData={child} key={i} showLinkArrow={true} className={cx(customStylesForArrows)} />
))}
Then in RefRole
we can pass that down to the Link in question
const stylingClass = cardRef ? cardRefStyling : '';
if (url) {
return (
<Link className={cx(stylingClass, className)} to={url} showLinkArrow={showLinkArrow}>
{children.map((node, i) => (
<ComponentFactory key={i} nodeData={node} />
))}
</Link>
);
}
This should only allow the style to be applied from the ProductItem component as the style class is defined there.
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.
@rayangler thoughts? ☝️
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 both this and Anabella's current solution are reasonable.
Ideally, we would just use the prop from LG's Link component, but unfortunately, since we use both LG Link and Gatsby Link, it makes things a little annoying and/or inconsistent. The benefit of the current solution is that it enforces consistency in both styling (even if the difference is subtle) and implementation while keeping the styling all within the component (big win in terms of readability and traceability).
Since the intention of this change is to prevent a cascading shift in styling for unintended elements (like the side nav items), I think the current solution is fine for now. In the future, we should revisit if it's possible and/or desirable to render a Gatsby Link as a LG Link so that we can much more cleanly use the same shared prop.
Can you also please update the staging link @anabellabuckvar ? I think the previous changes (incorrect link) are still present. |
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 left some suggestions.
arrowAppearance={showLinkArrow ? 'persist' : 'none'} | ||
target={target} | ||
{...other} | ||
> | ||
{children} | ||
{decoration} |
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 agree it would have been preferable, but I think the issue could become both arrows rendering or some rendering conflict in general.
arrowAppearance={showLinkArrow ? 'persist' : 'none'} | ||
target={target} | ||
{...other} | ||
> | ||
{children} | ||
{decoration} |
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.
That might be the trade-off or I wonder if we could leverage the custom className
and apply the className
value in the ProductItem.js file
<StyledArticle>
<SectionHeader customStyles={customStyleHeader}>
{argument.map((child, i) => (
<ComponentFactory nodeData={child} key={i} />
))}
</SectionHeader>
{children.map((child, i) => (
<ComponentFactory nodeData={child} key={i} showLinkArrow={true} className='some-custom-className' />
))}
</StyledArticle>
Then we apply the style using that custom class name. This way it doesn't have an effect on the other links.
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.
LGTM, as long as the console.log
is removed
src/components/RefRole.js
Outdated
@@ -32,6 +32,7 @@ const stopPropagation = function (e) { | |||
const RefRole = ({ nodeData: { children, domain, fileid, name, url }, slug, cardRef, showLinkArrow }) => { | |||
// Render intersphinx target links | |||
const stylingClass = cardRef ? cardRefStyling : ''; | |||
console.log(url); |
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 remove this?
@anabellabuckvar outside of our convo, if it doesn't work this solution is okay as well. I will mark approved to not block or hold you up. |
Another option could be adding the style changes in the |
Stories/Links:
DOP-4028
Current Behavior:
The spacing for the caret dropdown icons on the side nav is slightly out of line
[staging] (https://preview-mongodbrayanglerstg.gatsbyjs.io/cloud-docs/gc-test-img/)
Staging Links:
Docs-landing
Notes:
As part of DOP-3989, some css was added to add a margin for svgs nested in links. It seems that it was necessary for correct spacing because the last link in the products list didn't space the arrow correctly due to how the link was being generated. However, the margin fix ended up caused the spacing to change slightly for the caret dropdown icons on the side nav.
In fixing this, I noticed that the method of displaying arrows in
Links.js
was different for LGLinks, which used a LG prop, than for GatsbyLinks, which usedArrowRightIcon
. This was rendering them with slightly different types of arrows as well as margins between link text and the arrows. For consistency, I changed both to useArrowRightIcon
instead