Skip to content

Commit f48d0ce

Browse files
committed
Remove all uses of getColor
1 parent b99d276 commit f48d0ce

27 files changed

+274
-761
lines changed

packages/mdx/src/index.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@
3636
margin: 0.1em -0.05em;
3737
border-radius: 0.25em;
3838
font-size: 0.9rem;
39+
color: var(--ch-l-foreground);
40+
background: var(--ch-l-lighter-inlineBackground);
41+
}
42+
43+
.ch-inline-code .ch-section-link,
44+
.ch-inline-code .ch-section-link * {
45+
text-decoration-color: var(--ch-l-foreground);
3946
}
4047

4148
.ch-section-link,
4249
.ch-section-link * {
4350
text-decoration: underline;
4451
text-decoration-style: dotted;
4552
text-decoration-thickness: 1px;
46-
text-decoration-color: var(
47-
--ch-code-foreground,
48-
currentColor
49-
);
53+
text-decoration-color: currentColor;
5054
}
5155
.ch-section-link[data-active="true"] {
5256
background-color: #bae6fd66;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function InnerCode({
8080
className={`ch-codeblock not-prose ${
8181
className || ""
8282
}`}
83+
data-ch-theme={props.codeConfig?.themeName}
8384
style={style}
8485
>
8586
<CodeSpring
@@ -99,6 +100,7 @@ export function InnerCode({
99100
className={`ch-codegroup not-prose ${
100101
className || ""
101102
}`}
103+
data-ch-theme={props.codeConfig?.themeName}
102104
style={style}
103105
>
104106
<EditorSpring

packages/mdx/src/mdx-client/inline-code.tsx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import React from "react"
2-
import {
3-
EditorTheme,
4-
getColor,
5-
transparent,
6-
ColorName,
7-
Code,
8-
} from "../utils"
2+
import { Code } from "../utils"
93

104
export function InlineCode({
115
className,
@@ -17,33 +11,21 @@ export function InlineCode({
1711
className: string
1812
code: Code
1913
children?: React.ReactNode
20-
codeConfig: { theme: EditorTheme }
14+
codeConfig: { themeName: string }
2115
}) {
22-
const { theme } = codeConfig
2316
const { lines } = code
2417
const allTokens = lines.flatMap(line => line.tokens)
25-
const foreground = getColor(
26-
theme,
27-
ColorName.CodeForeground
28-
)
18+
2919
return (
3020
<span
21+
data-ch-theme={codeConfig.themeName}
3122
className={
3223
"ch-inline-code not-prose" +
3324
(className ? " " + className : "")
3425
}
3526
{...rest}
3627
>
37-
<code
38-
style={{
39-
["--ch-code-foreground" as any]: foreground,
40-
background: transparent(
41-
getColor(theme, ColorName.CodeBackground),
42-
0.9
43-
),
44-
color: foreground,
45-
}}
46-
>
28+
<code>
4729
{allTokens.map((token, j) => (
4830
<span key={j} {...token.props}>
4931
{token.content}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ function StaticScrollycoding({
4242
const { stepsChildren, previewChildren } =
4343
extractPreviewSteps(children, hasPreviewSteps)
4444
return (
45-
<section className={`ch-scrollycoding-static`}>
45+
<section
46+
className="ch-scrollycoding-static"
47+
data-ch-theme={rest?.codeConfig?.themeName}
48+
>
4649
{stepsChildren.map((children, i) => (
4750
<StaticSection
4851
key={i}
@@ -172,6 +175,7 @@ function DynamicScrollycoding({
172175
withPreview ? "ch-scrollycoding-with-preview" : ""
173176
} ${className || ""}`}
174177
style={style}
178+
data-ch-theme={codeConfig?.themeName}
175179
>
176180
<div className="ch-scrollycoding-content">
177181
<Scroller

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function Spotlight({
5454
withPreview ? "ch-spotlight-with-preview" : ""
5555
} ${className || ""}`}
5656
style={style}
57+
data-ch-theme={codeConfig.themeName}
5758
>
5859
<div className="ch-spotlight-tabs">
5960
{headerElement?.props?.children ? (

packages/mdx/src/mini-browser/buttons.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,12 @@ function Refresh() {
4949
)
5050
}
5151

52-
function Open({
53-
href,
54-
style,
55-
}: {
56-
href: string
57-
style?: React.CSSProperties
58-
}) {
59-
const c = useClasser("ch-browser")
52+
function Open({ href }: { href: string }) {
6053
return (
6154
<a
62-
className={c("button", "open-button")}
55+
className="ch-browser-button ch-browser-open-button"
6356
title="Open in new tab"
6457
href={href}
65-
style={style}
6658
target="_blank"
6759
rel="noopener noreferrer"
6860
>
@@ -73,7 +65,7 @@ function Open({
7365
viewBox="3 3 18 18"
7466
height="1em"
7567
width="1em"
76-
className={c("open-icon")}
68+
className="ch-browser-open-icon"
7769
xmlns="http://www.w3.org/2000/svg"
7870
>
7971
<path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path>

packages/mdx/src/mini-browser/index.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
height: 1.4em;
1717
font-size: 1em;
1818
border-radius: 0.5em;
19-
border: none;
2019
box-shadow: none;
2120
flex: 1;
2221
padding: 0 10px;
2322
color: #544;
2423
min-width: 5px;
2524
width: 5px;
25+
background: var(--ch-l-input-background);
26+
color: var(--ch-l-input-foreground);
27+
border: 1px solid var(--ch-l-input-border);
2628
}
2729

2830
.ch-browser-button {
@@ -39,8 +41,9 @@
3941
}
4042

4143
.ch-browser-open-button {
42-
color: inherit;
44+
color: var(--ch-l-icon-foreground);
4345
}
46+
4447
.ch-browser-open-icon {
4548
display: block;
4649
}

packages/mdx/src/mini-browser/mini-browser-hike.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ function MiniBrowserWithRef(
5050
...transitionStyle({ progress, transition }),
5151
...props.style,
5252
}}
53-
classes={classes}
5453
titleBar={
55-
<TitleBar
56-
url={displayUrl!}
57-
linkUrl={loadUrl!}
58-
theme={theme}
59-
/>
54+
<TitleBar url={displayUrl!} linkUrl={loadUrl!} />
6055
}
6156
theme={theme}
6257
>
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
11
import React from "react"
22
import { Back, Forward, Open } from "./buttons"
33
import { FrameButtons } from "../mini-frame"
4-
import { EditorTheme, getColor, ColorName } from "../utils"
54

6-
export { TitleBar }
7-
8-
function TitleBar({
5+
export function TitleBar({
96
url,
107
linkUrl,
11-
theme,
128
}: {
139
url: string
1410
linkUrl: string
15-
theme: EditorTheme
1611
}) {
17-
const inputBorder = getColor(theme, ColorName.InputBorder)
1812
return (
1913
<>
2014
<FrameButtons />
2115
<Back />
2216
<Forward />
2317
{/* <Refresh /> */}
24-
<input
25-
value={url || ""}
26-
readOnly
27-
style={{
28-
background: getColor(
29-
theme,
30-
ColorName.InputBackground
31-
),
32-
color: getColor(theme, ColorName.InputForeground),
33-
border: inputBorder
34-
? `1px solid ${inputBorder}`
35-
: undefined,
36-
}}
37-
/>
38-
<Open
39-
href={linkUrl}
40-
style={{
41-
color: getColor(
42-
theme,
43-
ColorName.EditorForeground
44-
),
45-
}}
46-
/>
18+
<input value={url || ""} readOnly />
19+
<Open href={linkUrl} />
4720
</>
4821
)
4922
}

packages/mdx/src/mini-editor/code-browser.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "../utils/mixins.scss";
22

33
.ch-code-browser {
4+
color: var(--ch-l-editor-foreground);
45
display: flex;
56
height: 100%;
67
font-family: Ubuntu, Droid Sans, -apple-system,
@@ -12,6 +13,9 @@
1213
min-width: 100px;
1314
padding: 1em 0;
1415
font-size: 0.95rem;
16+
border-color: var(--ch-l-sideBar-border);
17+
background: var(--ch-l-sideBar-background);
18+
color: var(--ch-l-sideBar-foreground);
1519
}
1620

1721
.ch-code-browser-content {
@@ -25,10 +29,13 @@
2529
line-height: 1.2rem;
2630
letter-spacing: 0px;
2731
position: relative;
32+
background: var(--ch-l-background);
33+
color: var(--ch-l-foreground);
34+
color-scheme: var(--ch-l-colorScheme);
2835
}
2936

3037
.ch-code-browser-content ::selection {
31-
background-color: var(--ch-selection-background);
38+
background-color: var(--ch-l-editor-selectionBackground);
3239
color: inherit;
3340
}
3441

@@ -41,9 +48,14 @@
4148
cursor: pointer;
4249
}
4350

51+
.ch-code-browser-sidebar-file[data-selected="true"] {
52+
background: var(--ch-l-list-activeSelectionBackground);
53+
color: var(--ch-l-list-activeSelectionForeground);
54+
}
55+
4456
.ch-code-browser-sidebar-file:hover {
45-
background-color: var(--ch-hover-background);
46-
color: var(--ch-hover-foreground);
57+
background-color: var(--ch-l-list-hoverBackground);
58+
color: var(--ch-l-list-hoverForeground);
4759
}
4860

4961
.ch-code-browser-button {

0 commit comments

Comments
 (0)