Skip to content

Commit 91f0de2

Browse files
authored
docs: Improve code editor UI (#1015)
1 parent 1506606 commit 91f0de2

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

Diff for: apps/typegpu-docs/src/components/CodeEditor.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const createCodeEditorComponent =
9292
return (
9393
<div
9494
className={
95-
shown ? 'h-[calc(100%-6rem)] md:h-[calc(100%-2rem)]' : 'hidden'
95+
shown ? 'h-[calc(100%-7rem)] md:h-[calc(100%-3rem)]' : 'hidden'
9696
}
9797
>
9898
<Editor
@@ -106,7 +106,6 @@ const createCodeEditorComponent =
106106
},
107107
readOnly: true,
108108
}}
109-
className="rounded-tl-none"
110109
/>
111110
</div>
112111
);

Diff for: apps/typegpu-docs/src/components/ExampleView.tsx

+33-23
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function ExampleView({ example }: Props) {
100100
<div
101101
className={cs(
102102
'flex-1 grid gap-4',
103-
codeEditorShowing ? 'md:grid-rows-2' : '',
103+
codeEditorShowing ? 'md:grid-rows-[2fr_3fr]' : '',
104104
)}
105105
>
106106
{isGPUSupported ? (
@@ -133,29 +133,39 @@ export function ExampleView({ example }: Props) {
133133
'absolute bg-tameplum-50 z-20 md:relative h-[calc(100%-2rem)] w-[calc(100%-2rem)] md:w-full md:h-full',
134134
)}
135135
>
136-
<div className="absolute inset-1">
137-
<div className="flex overflow-auto border-gray-300 pt-16 md:pt-0">
138-
{editorTabsList.map((fileName) => (
139-
<button
140-
key={fileName}
141-
type="button"
142-
onClick={() => setCurrentFile(fileName)}
143-
className={cs(
144-
'px-4 py-2',
145-
currentFile === fileName
146-
? 'rounded-t-lg rounded-bl-none rounded-br-none bg-gradient-to-br from-gradient-purple to-gradient-blue text-white hover:from-gradient-purple-dark hover:to-gradient-blue-dark'
147-
: 'rounded-t-lg rounded-bl-none rounded-br-none bg-white border-tameplum-100 border-2 hover:bg-tameplum-20',
148-
)}
149-
>
150-
{fileName}
151-
</button>
152-
))}
136+
<div className="absolute inset-0 flex flex-col justify-between">
137+
<div className="h-12 pt-16 md:pt-0">
138+
<div className="flex overflow-x-auto border-gray-300 h-full">
139+
{editorTabsList.map((fileName) => (
140+
<button
141+
key={fileName}
142+
type="button"
143+
onClick={() => setCurrentFile(fileName)}
144+
className={cs(
145+
'px-4 rounded-t-lg rounded-b-none text-nowrap',
146+
currentFile === fileName
147+
? 'bg-gradient-to-br from-gradient-purple to-gradient-blue text-white hover:from-gradient-purple-dark hover:to-gradient-blue-dark'
148+
: 'bg-white border-tameplum-100 border-2 hover:bg-tameplum-20',
149+
)}
150+
>
151+
{fileName}
152+
</button>
153+
))}
154+
</div>
153155
</div>
154-
{currentFile === 'index.html' ? (
155-
<HtmlCodeEditor shown code={htmlCode} />
156-
) : (
157-
<TsCodeEditor shown code={tsCodes[currentFile]} />
158-
)}
156+
157+
<HtmlCodeEditor
158+
shown={currentFile === 'index.html'}
159+
code={htmlCode}
160+
/>
161+
162+
{Object.entries(tsCodes).map(([key, value]) => (
163+
<TsCodeEditor
164+
shown={key === currentFile}
165+
code={value}
166+
key={key}
167+
/>
168+
))}
159169
</div>
160170
</div>
161171
) : null}

Diff for: apps/typegpu-docs/src/layouts/PageLayout.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import '../tailwind.css';
32
import '../fonts/font-face.css';
3+
import '../tailwind.css';
44
const { title, theme = 'light' } = Astro.props;
55
---
66

@@ -22,7 +22,7 @@ const { title, theme = 'light' } = Astro.props;
2222

2323
.monaco-editor,
2424
.overflow-guard {
25-
border-radius: 0.5rem;
25+
border-radius: 0 0.5rem 0.5rem 0.5rem;
2626
}
2727

2828
h1 {

0 commit comments

Comments
 (0)