Skip to content

Commit d88d12e

Browse files
authored
Use css variables and tailwind styles in custom components (#804)
1 parent d502b6e commit d88d12e

File tree

10 files changed

+75
-270
lines changed

10 files changed

+75
-270
lines changed

scripts/generate-cli-docs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ async function createCommandPage(
268268
}
269269

270270
if (command.usage) {
271-
props.push(formatJsxProp("usage", command.usage));
271+
// Wrap long usage commands for better readability
272+
props.push(formatJsxProp("usage", wrapCliCommand(command.usage)));
272273
}
273274

274275
// Get custom content from partial files

src/components.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ export const mdxComponents = {
6161
<Framed size={props.size}>
6262
<Image
6363
{...props}
64-
className="border border-[#eaecef] overflow-hidden rounded-sm"
64+
className="border border-border overflow-hidden rounded-sm"
6565
/>
6666
</Framed>
6767
);
6868
}
6969
return (
7070
<Image
7171
{...props}
72-
className="border border-[#eaecef] overflow-hidden rounded-sm"
72+
className="border border-border overflow-hidden rounded-sm"
7373
/>
7474
);
7575
},
7676
Framed,
7777
CodeType: (props: PropsWithChildren) => (
78-
<code className="text-green-600">&lt;{props.children}&gt;</code>
78+
<code className="text-primary">&lt;{props.children}&gt;</code>
7979
),
8080
DocusaurusDocsLicense,
8181
GithubButton,

src/components/BrowserScreenshot.tsx

Lines changed: 21 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import type { CSSProperties, PropsWithChildren, ReactElement } from "react";
1+
import type { PropsWithChildren, ReactElement } from "react";
22

33
interface BrowserScreenshotProps {
44
url?: string;
5-
browserTheme?: "light" | "dark";
6-
browserShadow?: string;
7-
borderRadius?: number;
8-
className?: string;
9-
style?: CSSProperties;
105
size?: "sm" | "md" | "lg";
116
}
127

@@ -19,162 +14,51 @@ const marginClasses = {
1914
export function BrowserScreenshot({
2015
children,
2116
url = "https://example.com",
22-
browserTheme = "light",
23-
browserShadow = "0 10px 40px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04)",
24-
borderRadius = 8,
25-
className = "",
26-
style,
2717
size,
2818
}: PropsWithChildren<BrowserScreenshotProps>): ReactElement {
29-
const isDark = browserTheme === "dark";
30-
31-
const browserWindowStyle: CSSProperties = {
32-
borderRadius: `${borderRadius}px`,
33-
overflow: "hidden",
34-
boxShadow: browserShadow,
35-
backgroundColor: isDark ? "#1a1a1a" : "#fafafa",
36-
border: `1px solid ${isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)"}`,
37-
margin: "0 auto",
38-
maxWidth: "90%",
39-
...style,
40-
};
41-
42-
const browserBarStyle: CSSProperties = {
43-
height: "40px",
44-
backgroundColor: isDark ? "#262626" : "#f6f6f6",
45-
display: "flex",
46-
alignItems: "center",
47-
padding: "0 16px",
48-
gap: "16px",
49-
position: "relative" as const,
50-
};
51-
52-
const trafficLightStyle: CSSProperties = {
53-
display: "flex",
54-
gap: "8px",
55-
alignItems: "center",
56-
};
57-
58-
const dotStyle: CSSProperties = {
59-
width: "12px",
60-
height: "12px",
61-
borderRadius: "50%",
62-
};
63-
64-
const navigationStyle: CSSProperties = {
65-
display: "flex",
66-
gap: "16px",
67-
alignItems: "center",
68-
};
69-
70-
const navButtonStyle: CSSProperties = {
71-
width: "14px",
72-
height: "14px",
73-
display: "flex",
74-
alignItems: "center",
75-
justifyContent: "center",
76-
cursor: "pointer",
77-
opacity: 0.6,
78-
};
79-
80-
const urlBarStyle: CSSProperties = {
81-
flex: 1,
82-
maxWidth: "320px",
83-
height: "28px",
84-
backgroundColor: isDark ? "#1a1a1a" : "#fafafa",
85-
border: `1px solid ${isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)"}`,
86-
borderRadius: "20px",
87-
padding: "0 12px",
88-
display: "flex",
89-
alignItems: "center",
90-
justifyContent: "center",
91-
fontSize: "13px",
92-
color: isDark ? "#888888" : "#666666",
93-
fontFamily:
94-
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
95-
};
96-
97-
const contentStyle: CSSProperties = {
98-
backgroundColor: "#ffffff",
99-
display: "block",
100-
};
101-
102-
const marginClass = size
103-
? marginClasses[size]
104-
? marginClasses[size]
105-
: "mx-auto"
106-
: "mx-auto";
19+
const marginClass = size ? (marginClasses[size] ?? "mx-auto") : "mx-auto";
10720

10821
return (
10922
<div
11023
className={`[&>p]:m-0 [&>p]:p-0 [&>p>img]:m-0 [&>p>img]:p-0 my-8 ${marginClass}`}
11124
>
112-
<div
113-
className={`browser-screenshot-wrapper ${className}`}
114-
style={browserWindowStyle}
115-
>
116-
<style
117-
dangerouslySetInnerHTML={{
118-
__html: `
119-
.browser-screenshot-wrapper img {
120-
border: 0 !important;
121-
border-radius: 0 !important;
122-
padding: 0 !important;
123-
margin: 0 !important;
124-
display: block !important;
125-
max-width: 100% !important;
126-
height: auto !important;
127-
}
128-
.browser-screenshot-wrapper p {
129-
margin: 0 !important;
130-
padding: 0 !important;
131-
line-height: 0 !important;
132-
}
133-
`,
134-
}}
135-
/>
136-
<div style={browserBarStyle}>
137-
<div style={trafficLightStyle}>
25+
<div className="overflow-hidden mx-auto max-w-[90%] rounded-lg shadow-lg border border-border bg-card [&_img]:!border-0 [&_img]:!rounded-none [&_img]:!p-0 [&_img]:!m-0 [&_img]:!block [&_img]:!max-w-full [&_img]:!h-auto [&_p]:!m-0 [&_p]:!p-0 [&_p]:!leading-[0]">
26+
<div className="h-10 flex items-center px-4 gap-4 relative bg-gray-100 dark:bg-gray-900">
27+
<div className="flex gap-2 items-center">
13828
<div
139-
style={{
140-
...dotStyle,
141-
backgroundColor: "#FE5F57",
142-
}}
29+
className="w-3 h-3 rounded-full"
30+
style={{ backgroundColor: "#FE5F57" }}
14331
/>
14432
<div
145-
style={{
146-
...dotStyle,
147-
backgroundColor: "#FEBB2E",
148-
}}
33+
className="w-3 h-3 rounded-full"
34+
style={{ backgroundColor: "#FEBB2E" }}
14935
/>
15036
<div
151-
style={{
152-
...dotStyle,
153-
backgroundColor: "#26C941",
154-
}}
37+
className="w-3 h-3 rounded-full"
38+
style={{ backgroundColor: "#26C941" }}
15539
/>
15640
</div>
157-
<div style={navigationStyle}>
158-
<div style={navButtonStyle}>
159-
<svg viewBox="0 0 16 16" fill={isDark ? "#888888" : "#666666"}>
41+
<div className="flex gap-4 items-center">
42+
<div className="w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400">
43+
<svg viewBox="0 0 16 16" fill="currentColor">
16044
<path
16145
fillRule="evenodd"
16246
clipRule="evenodd"
16347
d="M6.46966 13.7803L6.99999 14.3107L8.06065 13.25L7.53032 12.7197L3.56065 8.75001H14.25H15V7.25001H14.25H3.56065L7.53032 3.28034L8.06065 2.75001L6.99999 1.68935L6.46966 2.21968L1.39644 7.2929C1.00592 7.68342 1.00592 8.31659 1.39644 8.70711L6.46966 13.7803Z"
16448
/>
16549
</svg>
16650
</div>
167-
<div style={navButtonStyle}>
168-
<svg viewBox="0 0 16 16" fill={isDark ? "#888888" : "#666666"}>
51+
<div className="w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400">
52+
<svg viewBox="0 0 16 16" fill="currentColor">
16953
<path
17054
fillRule="evenodd"
17155
clipRule="evenodd"
17256
d="M9.53033 2.21968L9 1.68935L7.93934 2.75001L8.46967 3.28034L12.4393 7.25001H1.75H1V8.75001H1.75H12.4393L8.46967 12.7197L7.93934 13.25L9 14.3107L9.53033 13.7803L14.6036 8.70711C14.9941 8.31659 14.9941 7.68342 14.6036 7.2929L9.53033 2.21968Z"
17357
/>
17458
</svg>
17559
</div>
176-
<div style={navButtonStyle}>
177-
<svg viewBox="0 0 16 16" fill={isDark ? "#888888" : "#666666"}>
60+
<div className="w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400">
61+
<svg viewBox="0 0 16 16" fill="currentColor">
17862
<path
17963
fillRule="evenodd"
18064
clipRule="evenodd"
@@ -183,20 +67,13 @@ export function BrowserScreenshot({
18367
</svg>
18468
</div>
18569
</div>
186-
<div style={urlBarStyle}>
187-
<span
188-
style={{
189-
fontSize: "13px",
190-
whiteSpace: "nowrap",
191-
overflow: "hidden",
192-
textOverflow: "ellipsis",
193-
}}
194-
>
70+
<div className="flex-1 max-w-xs h-7 rounded-full px-3 flex items-center justify-center text-[13px] font-sans bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 text-gray-600 dark:text-gray-400">
71+
<span className="text-[13px] whitespace-nowrap overflow-hidden text-ellipsis">
19572
{url}
19673
</span>
19774
</div>
19875
</div>
199-
<div style={contentStyle}>{children}</div>
76+
<div className="bg-card block">{children}</div>
20077
</div>
20178
</div>
20279
);

src/components/BundlesTable.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ export const BundlesTable = () => {
2929

3030
return (
3131
<table className="w-full border-collapse text-sm">
32-
<tr className="bg-gray-50 border-b">
33-
<th className="px-3 py-2 text-left font-medium text-gray-600">
32+
<tr className="bg-secondary border-b">
33+
<th className="px-3 py-2 text-left font-medium text-muted-foreground">
3434
Module
3535
</th>
36-
<th className="px-3 py-2 text-left font-medium text-gray-600">
36+
<th className="px-3 py-2 text-left font-medium text-muted-foreground">
3737
Status
3838
</th>
39-
<th className="px-3 py-2 text-left font-medium text-gray-600">
39+
<th className="px-3 py-2 text-left font-medium text-muted-foreground">
4040
Version
4141
</th>{" "}
42-
<th className="px-3 py-2 text-left font-medium text-gray-600">Notes</th>
42+
<th className="px-3 py-2 text-left font-medium text-muted-foreground">
43+
Notes
44+
</th>
4345
</tr>
4446
{data?.bundles
4547
.filter((bundle) => bundle.isPublic)
@@ -52,16 +54,17 @@ export const BundlesTable = () => {
5254
let status = issue?.status ?? "Unknown";
5355

5456
const statusClass = {
55-
Unknown: "bg-gray-200 text-gray-700",
56-
Issues: "bg-red-100 text-red-800",
57-
Working: "bg-green-200 text-green-800",
57+
Unknown: "bg-secondary text-foreground",
58+
Issues: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",
59+
Working:
60+
"bg-green-200 text-green-800 dark:bg-green-900 dark:text-green-200",
5861
};
5962

6063
return (
61-
<tr className="border-b hover:bg-gray-50" key={i}>
64+
<tr className="border-b hover:bg-accent" key={i}>
6265
<td className="px-3 py-2 align-top">
6366
<a
64-
className="text-blue-600 hover:underline font-medium"
67+
className="text-primary hover:underline font-medium"
6568
href={
6669
bundle.url ?? `https://www.npmjs.com/package/${bundle.name}`
6770
}
@@ -80,7 +83,7 @@ export const BundlesTable = () => {
8083
{bundle.version}
8184
</td>
8285

83-
<td className="px-3 py-2 align-top text-gray-700 text-xs">
86+
<td className="px-3 py-2 align-top text-foreground text-xs">
8487
{notes}
8588
</td>
8689
</tr>

src/components/CliCommand.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const CliCommand: React.FC<CliCommandProps> = ({
165165
<h2 className="text-2xl font-bold mb-6">Examples</h2>
166166
{examples.map(([cmd, desc], index) => (
167167
<div key={index} className="mb-6">
168-
<p className="mb-2 text-gray-700">{desc}</p>
168+
<p className="mb-2 text-foreground">{desc}</p>
169169
<SyntaxHighlight language="bash">
170170
{cmd.replace(/\$0/g, "zuplo")}
171171
</SyntaxHighlight>
@@ -184,53 +184,51 @@ export const CliCommand: React.FC<CliCommandProps> = ({
184184
<code>--{option.name}</code>
185185
</h3>
186186
{option.description && (
187-
<p className="mb-3 text-gray-700">{option.description}</p>
187+
<p className="mb-3 text-foreground">{option.description}</p>
188188
)}
189-
<div className="text-sm text-gray-600">
189+
<div className="text-sm text-muted-foreground">
190190
{option.type && (
191191
<span className="mr-3">
192192
Type:{" "}
193-
<code className="bg-gray-100 px-1 rounded">
194-
{option.type}
195-
</code>
193+
<code className="bg-muted px-1 rounded">{option.type}</code>
196194
</span>
197195
)}
198196
{option.default !== undefined && (
199197
<span className="mr-3">
200198
Default:{" "}
201-
<code className="bg-gray-100 px-1 rounded">
199+
<code className="bg-muted px-1 rounded">
202200
{JSON.stringify(option.default)}
203201
</code>
204202
</span>
205203
)}
206204
{option.choices && option.choices.length > 0 && (
207205
<span className="mr-3">
208206
Choices:{" "}
209-
<code className="bg-gray-100 px-1 rounded">
207+
<code className="bg-muted px-1 rounded">
210208
{option.choices.join(", ")}
211209
</code>
212210
</span>
213211
)}
214212
{option.alias && option.alias.length > 0 && (
215213
<span className="mr-3">
216214
Alias:{" "}
217-
<code className="bg-gray-100 px-1 rounded">
215+
<code className="bg-muted px-1 rounded">
218216
-{option.alias.join(", -")}
219217
</code>
220218
</span>
221219
)}
222220
{option.envVar && (
223221
<span className="mr-3">
224222
Env:{" "}
225-
<code className="bg-gray-100 px-1 rounded">
223+
<code className="bg-muted px-1 rounded">
226224
{option.envVar}
227225
</code>
228226
</span>
229227
)}
230228
{option.conflicts && option.conflicts.length > 0 && (
231229
<span className="mr-3">
232230
Conflicts:{" "}
233-
<code className="bg-gray-100 px-1 rounded">
231+
<code className="bg-muted px-1 rounded">
234232
--{option.conflicts.join(", --")}
235233
</code>
236234
</span>

0 commit comments

Comments
 (0)