Skip to content

Commit 9f2f8b2

Browse files
committed
fix: ensure nested link is properly styled when idle
1 parent 6b9b19a commit 9f2f8b2

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/button/button.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
/* variant="tertiary" (only has fill when hovered) */
3434
--reactist-actionable-tertiary-idle-tint: #006f85;
35+
--reactist-actionable-tertiary-idle-fill: transparent;
3536
--reactist-actionable-tertiary-hover-tint: #006f85;
3637
--reactist-actionable-tertiary-hover-fill: #f2f6f7;
3738
--reactist-actionable-tertiary-disabled-tint: #99c5ce;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
:root {
22
--reactist-text-link-idle-tint: var(--reactist-actionable-tertiary-idle-tint);
33
--reactist-text-link-hover-tint: var(--reactist-actionable-tertiary-hover-tint);
4-
--reactist-text-link-idle-decoration: underline;
5-
--reactist-text-link-hover-decoration: underline;
4+
--reactist-text-link-idle-decoration: underline var(--reactist-actionable-tertiary-idle-fill);
5+
--reactist-text-link-hover-decoration: underline var(--reactist-text-link-hover-tint);
66
}
77

88
.container {
@@ -14,6 +14,11 @@
1414
cursor: pointer;
1515
}
1616

17+
.container > * {
18+
text-decoration: var(--reactist-text-link-idle-decoration);
19+
color: var(--reactist-text-link-idle-tint);
20+
}
21+
1722
/**
1823
* We need to target the child elements to ensure that styles are
1924
* applied to the text independently of the DOM elements hierarchy.

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)