Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/badge/badge.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
background-color: var(--reactist-badge-fill);
line-height: calc(var(--reactist-badge-font-size) + 3px);
white-space: nowrap;
text-decoration: none;
}

.badge:hover {
color: var(--reactist-badge-tint);
text-decoration: none;
}

.badge-info {
Expand Down
12 changes: 11 additions & 1 deletion src/text-link/text-link.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
cursor: pointer;
}

.container:hover {
.container > * {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not applying here other rules such as font-weight so they are preserved for nested elements

text-decoration: var(--reactist-text-link-idle-decoration);
color: var(--reactist-text-link-idle-tint);
}

/**
* We need to target the child elements to ensure that styles are
* applied to the text independently of the DOM elements hierarchy.
*/
.container:hover,
.container:hover > * {
text-decoration: var(--reactist-text-link-hover-decoration);
color: var(--reactist-text-link-hover-tint);
}
Expand Down
33 changes: 33 additions & 0 deletions src/text-link/text-link.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,36 @@ A component used to create text-based hyperlinks.
## Props

<ArgsTable of={TextLink} />

## Nested elements

When using nested elements inside a `TextLink`, hover styles are properly applied to all children.

<Canvas>
<Story
name="Nested elements"
parameters={{
docs: { source: { type: 'code' } },
chromatic: { disableSnapshot: false },
}}
>
<Stack space="medium" align="start">
<TextLink href="https://www.doist.com/">
<span>Link with nested span</span>
</TextLink>
<TextLink href="https://www.doist.com/">
<div>Link with nested div</div>
</TextLink>
<TextLink href="https://www.doist.com/">
Text with <strong>bold</strong> section
</TextLink>
<TextLink href="https://www.doist.com/">
Text with{' '}
<a href="https://www.doist.com" target="_blank">
link
</a>{' '}
section
</TextLink>
</Stack>
</Story>
</Canvas>
Loading