Skip to content

Commit 1f5eb2f

Browse files
committed
fix: ensure TextLink styles are applied to nested elements
1 parent 41f2310 commit 1f5eb2f

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

src/badge/badge.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
background-color: var(--reactist-badge-fill);
3030
line-height: calc(var(--reactist-badge-font-size) + 3px);
3131
white-space: nowrap;
32+
text-decoration: none;
33+
}
34+
35+
.badge:hover {
36+
color: var(--reactist-badge-tint);
37+
text-decoration: none;
3238
}
3339

3440
.badge-info {

src/text-link/text-link.module.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@
1414
cursor: pointer;
1515
}
1616

17-
.container:hover {
17+
.container > * {
18+
text-decoration: var(--reactist-text-link-idle-decoration);
19+
color: var(--reactist-text-link-idle-tint);
20+
}
21+
22+
/**
23+
* We need to target the child elements to ensure that styles are
24+
* applied to the text independently of the DOM elements hierarchy.
25+
*/
26+
.container:hover,
27+
.container:hover > * {
1828
text-decoration: var(--reactist-text-link-hover-decoration);
1929
color: var(--reactist-text-link-hover-tint);
2030
}

src/text-link/text-link.stories.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,36 @@ A component used to create text-based hyperlinks.
4141
## Props
4242

4343
<ArgsTable of={TextLink} />
44+
45+
## Nested elements
46+
47+
When using nested elements inside a `TextLink`, hover styles are properly applied to all children.
48+
49+
<Canvas>
50+
<Story
51+
name="Nested elements"
52+
parameters={{
53+
docs: { source: { type: 'code' } },
54+
chromatic: { disableSnapshot: false },
55+
}}
56+
>
57+
<Stack space="medium" align="start">
58+
<TextLink href="https://www.doist.com/">
59+
<span>Link with nested span</span>
60+
</TextLink>
61+
<TextLink href="https://www.doist.com/">
62+
<div>Link with nested div</div>
63+
</TextLink>
64+
<TextLink href="https://www.doist.com/">
65+
Text with <strong>bold</strong> section
66+
</TextLink>
67+
<TextLink href="https://www.doist.com/">
68+
Text with{' '}
69+
<a href="https://www.doist.com" target="_blank">
70+
link
71+
</a>{' '}
72+
section
73+
</TextLink>
74+
</Stack>
75+
</Story>
76+
</Canvas>

0 commit comments

Comments
 (0)