Skip to content

Commit 9fab28f

Browse files
fix(heading): improve heading style (#7628)
* fix(ui): missing style * fix: theme * fix typo in comment Co-authored-by: Copilot <[email protected]> Signed-off-by: Augustin Mauroy <[email protected]> * revert theme change --------- Signed-off-by: Augustin Mauroy <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 3ad42c6 commit 9fab28f

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

packages/ui-components/.stylelintrc.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ export default {
4545
'import-notation': 'string',
4646
// Allow the `@apply` at rule as its part of Tailwind
4747
'at-rule-no-deprecated': [true, { ignoreAtRules: CUSTOM_AT_RULES }],
48+
// We need complex `:not()` for headings with anchor
49+
'selector-not-notation': null,
4850
},
4951
};

packages/ui-components/__design__/text.stories.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export const InlineCode: StoryObj = {
2727
<p>
2828
This is an example of <code>inline code block</code>
2929
</p>
30+
<p>
31+
This is an example of{' '}
32+
<a href="https://nodejs.org/">
33+
<code>inline code block inside link</code>
34+
</a>
35+
</p>
3036
</main>
3137
),
3238
};
@@ -44,4 +50,31 @@ export const Headings: StoryObj = {
4450
),
4551
};
4652

53+
// Create the behavior of the headings with links
54+
// on nodejs.org, this is happening due to `rehype-autolink-headings`
55+
export const HeadingsWithLinks: StoryObj = {
56+
render: () => (
57+
<main>
58+
<h1 id="heading-1">
59+
<a href="#heading-1">HTML Section Heading 1</a>
60+
</h1>
61+
<h2 id="heading-2">
62+
<a href="#heading-2">HTML Section Heading 2</a>
63+
</h2>
64+
<h3 id="heading-3">
65+
<a href="#heading-3">HTML Section Heading 3</a>
66+
</h3>
67+
<h4 id="heading-4">
68+
<a href="#heading-4">HTML Section Heading 4</a>
69+
</h4>
70+
<h5 id="heading-5">
71+
<a href="#heading-5">HTML Section Heading 5</a>
72+
</h5>
73+
<h6 id="heading-6">
74+
<a href="#heading-6">HTML Section Heading 6</a>
75+
</h6>
76+
</main>
77+
),
78+
};
79+
4780
export default { title: 'Design System' } as MetaObj;

packages/ui-components/styles/markdown.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ main {
7575
dark:text-white;
7676
}
7777

78-
a,
78+
/* link that isn't inside a heading */
79+
a:not(h1 > a):not(h2 > a):not(h3 > a):not(h4 > a):not(h5 > a):not(h6 > a),
7980
.anchor {
8081
@apply max-xs:font-semibold
8182
text-green-600
@@ -93,6 +94,10 @@ main {
9394
&:has(code) {
9495
@apply max-xs:decoration-neutral-800
9596
dark:max-xs:decoration-neutral-200;
97+
98+
code {
99+
@apply text-inherit;
100+
}
96101
}
97102
}
98103

packages/ui-components/styles/theme.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
--color-white: #fff;
7777
--color-transparent: 'transparent';
7878
--color-shadow: #101828;
79-
--inherit: 'inherit';
8079
--shadow-xs: 0px 1px 2px 0px --alpha(var(--color-shadow, #101828) / 5%);
8180
--shadow-lg:
8281
0px 4px 6px -2px --alpha(var(--color-shadow, #101828) / 3%),
@@ -170,3 +169,7 @@
170169
var(--tw-gradient-to)
171170
);
172171
}
172+
173+
@utility text-inherit {
174+
color: inherit;
175+
}

0 commit comments

Comments
 (0)