Skip to content

Commit a18de24

Browse files
committed
Change multiline mark colors
1 parent 18eafc4 commit a18de24

File tree

3 files changed

+69
-27
lines changed

3 files changed

+69
-27
lines changed

packages/mdx/src/index.scss

+13
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@
5353
.ch-section-link[data-active="true"] * {
5454
text-decoration-thickness: 1.5px;
5555
}
56+
57+
.ch-code-inline-mark {
58+
border-radius: 0.25rem;
59+
padding: 0.2rem 0.15rem 0.1rem;
60+
margin: 0 -0.15rem;
61+
}
62+
63+
.ch-code-multiline-mark-border {
64+
width: 3px;
65+
height: 100%;
66+
position: absolute;
67+
left: 0;
68+
}

packages/mdx/src/mdx-client/annotations.tsx

+12-27
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function Mark(props: any) {
2525
return <MultilineMark {...props} />
2626
}
2727
}
28-
2928
function MultilineMark({
3029
children,
3130
data,
@@ -39,29 +38,20 @@ function MultilineMark({
3938
}) {
4039
const bg =
4140
data ||
42-
(((theme as any).colors[
43-
"editor.lineHighlightBackground"
44-
] ||
45-
(theme as any).colors[
46-
"editor.selectionHighlightBackground"
47-
]) as string)
41+
getColor(theme, ColorName.RangeHighlightBackground)
42+
const border = getColor(
43+
theme,
44+
ColorName.EditorInfoForeground
45+
)
46+
4847
return (
4948
<div
50-
style={{
51-
...style,
52-
background: bg,
53-
}}
54-
className="ch-code-bg-annotation"
49+
style={{ ...style, background: bg }}
50+
className="ch-code-multiline-mark"
5551
>
5652
<span
57-
className="ch-code-bg-annotation-border"
58-
style={{
59-
background: "#00a2d3",
60-
width: "3px",
61-
height: "100%",
62-
position: "absolute",
63-
left: 0,
64-
}}
53+
className="ch-code-multiline-mark-border"
54+
style={{ background: border }}
6555
/>
6656
{children}
6757
</div>
@@ -88,13 +78,8 @@ function InlineMark({
8878

8979
return (
9080
<span
91-
className="ch-code-mark-annotation"
92-
style={{
93-
background: bg,
94-
borderRadius: "0.25rem",
95-
padding: "0.2rem 0.15rem 0.1rem",
96-
margin: "0 -0.15rem",
97-
}}
81+
className="ch-code-inline-mark"
82+
style={{ background: bg }}
9883
>
9984
{children}
10085
</span>

packages/mdx/src/utils/theme.ts

+44
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export enum ColorName {
3232
CodeBackground,
3333
EditorForeground,
3434
EditorBackground,
35+
FocusBorder,
3536
ActiveTabBackground,
3637
ActiveTabForeground,
3738
InactiveTabBackground,
@@ -53,6 +54,12 @@ export enum ColorName {
5354
SideBarBackground,
5455
SideBarForeground,
5556
SideBarBorder,
57+
// Background color for the highlight of line at the cursor position
58+
LineHighlightBackground,
59+
// Background color of highlighted ranges, like by quick open and find features
60+
RangeHighlightBackground,
61+
// Foreground color of info squigglies in the editor
62+
EditorInfoForeground,
5663
}
5764

5865
type Color = string | undefined
@@ -97,6 +104,15 @@ export function getColor(
97104
hc: "#fffffe",
98105
})
99106
)
107+
case ColorName.FocusBorder:
108+
return (
109+
colors["focusBorder"] ||
110+
getDefault(theme, {
111+
light: "#0090F1",
112+
dark: "#007FD4",
113+
hc: contrastBorder,
114+
})
115+
)
100116
case ColorName.ActiveTabBackground:
101117
return (
102118
colors["tab.activeBackground"] ||
@@ -267,6 +283,34 @@ export function getColor(
267283
)
268284
case ColorName.ListHoverForeground:
269285
return colors["list.hoverForeground"] || undefined
286+
case ColorName.LineHighlightBackground:
287+
return (
288+
colors["editor.lineHighlightBackground"] ||
289+
getDefault(theme, {
290+
dark: undefined,
291+
light: undefined,
292+
hc: undefined,
293+
})
294+
)
295+
case ColorName.RangeHighlightBackground:
296+
return (
297+
colors["editor.rangeHighlightBackground"] ||
298+
getDefault(theme, {
299+
dark: "#ffffff0b",
300+
light: "#fdff0033",
301+
hc: undefined,
302+
})
303+
)
304+
305+
case ColorName.EditorInfoForeground:
306+
return (
307+
colors["editor.infoForeground"] ||
308+
getDefault(theme, {
309+
dark: "#3794FF",
310+
light: "#1a85ff",
311+
hc: "#3794FF",
312+
})
313+
)
270314

271315
default:
272316
return "#f00"

0 commit comments

Comments
 (0)