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

Image link should not render the external link icon by default #160

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

nikomakela
Copy link
Contributor

@nikomakela nikomakela commented Jan 25, 2024

HCRC-112.

If there is an image included in the Link children, the external link icon should not be rendered by default for the external links. It can be forced with showExternalIcon prop.

image

Also fixed the styles of the secondary link.

In a secondary link, an anchor element had span for text and another for the link icon. Both the subelements were displayed as flex, which made them to fill the whole row and rendering the icon in another row compared to the text.

HCRC-112.

In a secondary link, an anchor element had span for 
text and another for the link icon. Both the sublements
were displayed as flex, which made them to fill the whole row
and rendering the icon in another row compared to the text.
@karisal-anders
Copy link
Contributor

For comparison:

Current main:

old

This PR's branch:

new

HCRC-112.

If there is an image included in the Link children,
the external link icon should not be rendered by default 
for the external links. It can be forced with `showExternalIcon` prop.
Copy link
Contributor

@karisal-anders karisal-anders left a comment

Choose a reason for hiding this comment

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

It would good to document the recursiveMap function as although the code is not long it still has nuances, e.g. there are non-mapped parts (i.e. stuff not being run through fn) and mapped parts (i.e. stuff being run through fn), why the difference? What does the function really do as it skips mapping on some elements and not on others? Adding clear documentation for this would certainly help understand the code's intention.

@nikomakela nikomakela force-pushed the HCRC-112-fix-image-link branch from 35213d5 to 5d4edac Compare January 26, 2024 14:17
HCRC-112.

Add a recursively map utility, that can be used to recursively map the React children.

Add a findAllElementsOfType utility, that takes advantage of the `recursiveMap` and `getChildrenByType` utilities.

Add tests to each utility.

Finally, the Link should use the new findAllElementsOfType utility to search for images inside an anchor.
@nikomakela nikomakela force-pushed the HCRC-112-fix-image-link branch from 5d4edac to 4de2ede Compare January 26, 2024 14:23
@nikomakela nikomakela merged commit ef0ced7 into main Jan 26, 2024
2 checks passed
@nikomakela nikomakela deleted the HCRC-112-fix-image-link branch January 26, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants