Skip to content

Commit bece5aa

Browse files
bteaCopilotovflowd
authored
fix: correct the code style in the hover status (#9142)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Claudio Wunder <cwunder@gnome.org> Signed-off-by: btea <2356281422@qq.com>
1 parent 6e3644b commit bece5aa

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

‎.changeset/crisp-socks-call.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@node-core/ui-components': patch
3+
---
4+
5+
In the light theme, the background color of items in the history change component that contain code elements is incorrect when hovering.

‎packages/ui-components/.storybook/preview.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const preview: Preview = {
1616

1717
decorators: [
1818
withThemeByDataAttribute<ReactRenderer>({
19-
themes: { light: '', dark: 'dark' },
19+
themes: { light: 'light', dark: 'dark' },
2020
defaultTheme: 'light',
2121
attributeName: 'data-theme',
2222
}),

‎packages/ui-components/src/Common/ChangeHistory/index.module.css‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
@apply bg-brand-600
6969
text-white!;
7070
}
71+
72+
/* Keep inline `code` readable in light theme, where hover/focus turns text white */
73+
:where([data-theme='light'], [data-theme='light'] *)
74+
&:is(:hover, :focus-visible)
75+
code {
76+
@apply text-brand-900;
77+
}
7178
}
7279

7380
.dropdownLabel {

‎packages/ui-components/src/Common/ChangeHistory/index.stories.tsx‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ const SAMPLE_CHANGES = [
1414
{
1515
versions: ['v15.0.0', 'v14.17.0'],
1616
label: 'Added in v15.0.0, v14.17.0',
17+
content: (
18+
<>
19+
Added in: <code>v15.0.0</code>, <code>v14.17.0</code>
20+
</>
21+
),
1722
url: 'https://github.com/nodejs/node/pull/67890',
1823
},
1924
{
@@ -107,9 +112,13 @@ const LARGE_SAMPLE_CHANGES = [
107112

108113
export const Default: Story = {
109114
render: args => (
110-
<div className="right-0 flex justify-end">
111-
<ChangeHistory {...args} />
112-
</div>
115+
// `main` reproduces the docs page context: markdown.css scopes inline
116+
// `code` styles under `main`, which is what the hover fix interacts with /ui-components/src/styles/markdown.css
117+
<main>
118+
<div className="flex justify-end">
119+
<ChangeHistory {...args} />
120+
</div>
121+
</main>
113122
),
114123
args: {
115124
changes: SAMPLE_CHANGES,
@@ -118,9 +127,11 @@ export const Default: Story = {
118127

119128
export const LargeHistory: Story = {
120129
render: args => (
121-
<div className="right-0 flex justify-end">
122-
<ChangeHistory {...args} />
123-
</div>
130+
<main>
131+
<div className="flex justify-end">
132+
<ChangeHistory {...args} />
133+
</div>
134+
</main>
124135
),
125136
args: {
126137
changes: LARGE_SAMPLE_CHANGES,

0 commit comments

Comments
 (0)