Skip to content

Commit 19dcf16

Browse files
committed
Merge branch 'release' into docs/wgsl-resolve-example
2 parents fab7925 + 729a5d8 commit 19dcf16

File tree

20 files changed

+675
-76
lines changed

20 files changed

+675
-76
lines changed
1.34 MB
Loading

apps/typegpu-docs/src/components/ControlPanel.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { useAtom, useAtomValue } from 'jotai';
33
import { useSetAtom } from 'jotai';
44
import { useId, useState } from 'react';
55
import { codeEditorShownAtom } from '../utils/examples/codeEditorShownAtom.ts';
6-
import { currentExampleAtom } from '../utils/examples/currentExampleAtom.ts';
76
import { runWithCatchAtom } from '../utils/examples/currentSnackbarAtom.ts';
8-
import { examples } from '../utils/examples/exampleContent.ts';
97
import {
108
type ExampleControlParam,
119
exampleControlsAtom,
@@ -19,7 +17,6 @@ import { Slider } from './design/Slider.tsx';
1917
import { TextArea } from './design/TextArea.tsx';
2018
import { Toggle } from './design/Toggle.tsx';
2119
import { VectorSlider } from './design/VectorSlider.tsx';
22-
import { openInStackBlitz } from './stackblitz/openInStackBlitz.ts';
2320

2421
function ToggleRow({
2522
label,
@@ -306,7 +303,6 @@ export function ControlPanel() {
306303
const [codeEditorShowing, setCodeEditorShowing] = useAtom(
307304
codeEditorShownAtom,
308305
);
309-
const currentExample = useAtomValue(currentExampleAtom);
310306
const exampleControlParams = useAtomValue(exampleControlsAtom);
311307

312308
const showLeftMenuId = useId();
@@ -345,14 +341,6 @@ export function ControlPanel() {
345341
/>
346342
</label>
347343

348-
{currentExample && currentExample in examples
349-
? (
350-
<Button onClick={() => openInStackBlitz(examples[currentExample])}>
351-
Edit on StackBlitz
352-
</Button>
353-
)
354-
: null}
355-
356344
<hr className='my-0 box-border w-full border-tameplum-100 border-t' />
357345
</div>
358346

apps/typegpu-docs/src/components/ExampleLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import cs from 'classnames';
22
import { useAtom, useAtomValue } from 'jotai';
33
import { useId, useRef, useState } from 'react';
4+
import CrossSvg from '../assets/cross.svg';
45
import DiscordIconSvg from '../assets/discord-icon.svg';
56
import GithubIconSvg from '../assets/github-icon.svg';
67
import HamburgerSvg from '../assets/hamburger.svg';
7-
import CrossSvg from '../assets/cross.svg';
88
import { codeEditorShownMobileAtom } from '../utils/examples/codeEditorShownAtom.ts';
99
import {
1010
menuShownAtom,
1111
menuShownMobileAtom,
1212
} from '../utils/examples/menuShownAtom.ts';
13-
import { SearchableExampleList } from './SearchableExampleList.tsx';
1413
import ExamplePage from './ExamplePage.tsx';
14+
import { SearchableExampleList } from './SearchableExampleList.tsx';
1515
import { Button } from './design/Button.tsx';
1616
import { Toggle } from './design/Toggle.tsx';
1717

@@ -24,12 +24,12 @@ export function ExampleLayout() {
2424

2525
return (
2626
<>
27-
<div className='absolute top-4 left-4 z-50 flex gap-4 text-sm md:hidden'>
27+
<div className='absolute top-4 left-4 z-50 flex gap-2 text-sm md:hidden'>
2828
{menuShownMobile
2929
? null
3030
: (
3131
<Button onClick={() => setMenuShownMobile(true)}>
32-
<img src={HamburgerSvg.src} alt='menu' className='h-6 w-6' />
32+
<img src={HamburgerSvg.src} alt='menu' className='-m-2 h-6 w-6' />
3333
</Button>
3434
)}
3535

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import { useSetAtom } from 'jotai';
2-
import type { MouseEvent } from 'react';
32
import { currentExampleAtom } from '../utils/examples/currentExampleAtom.ts';
43
import useEvent from '../utils/useEvent.ts';
4+
import { Button } from './design/Button.tsx';
55

66
export function ExampleNotFound() {
77
const setCurrentExample = useSetAtom(currentExampleAtom);
88

9-
const handleGoHome = useEvent((e: MouseEvent) => {
10-
e.preventDefault();
11-
setCurrentExample(undefined);
12-
});
13-
149
return (
15-
<div className='flex flex-1 flex-col items-center justify-center'>
16-
<h1 className='font-bold text-4xl'>404 Example Not Found</h1>
17-
<button
18-
type='button'
19-
className='mt-4 text-lg text-slate-600 underline'
20-
onClick={handleGoHome}
10+
<div className='flex h-full flex-1 flex-col items-center justify-center gap-4'>
11+
<h1 className='font-bold text-3xl'>
12+
Example Not Found
13+
</h1>
14+
<Button
15+
accent
16+
onClick={useEvent(() => {
17+
setCurrentExample(undefined);
18+
})}
2119
>
22-
Go back home
23-
</button>
20+
Show default example
21+
</Button>
2422
</div>
2523
);
2624
}

apps/typegpu-docs/src/components/ExampleView.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import type { Example } from '../utils/examples/types.ts';
1414
import { isGPUSupported } from '../utils/isGPUSupported.ts';
1515
import { HtmlCodeEditor, TsCodeEditor } from './CodeEditor.tsx';
1616
import { ControlPanel } from './ControlPanel.tsx';
17+
import { Button } from './design/Button.tsx';
1718
import { Snackbar } from './design/Snackbar.tsx';
19+
import { openInStackBlitz } from './stackblitz/openInStackBlitz.ts';
1820

1921
type Props = {
2022
example: Example;
@@ -98,7 +100,7 @@ export function ExampleView({ example }: Props) {
98100
<div className='flex h-full flex-col gap-4 md:grid md:grid-cols-[1fr_18.75rem]'>
99101
<div
100102
className={cs(
101-
'grid flex-1 gap-4',
103+
'grid flex-1 gap-4 overflow-auto',
102104
codeEditorShowing ? 'md:grid-rows-[2fr_3fr]' : '',
103105
)}
104106
>
@@ -109,13 +111,13 @@ export function ExampleView({ example }: Props) {
109111
scrollbarGutter: 'stable both-edges',
110112
}}
111113
className={cs(
112-
'relative box-border flex h-full flex-col flex-wrap items-center justify-evenly md:flex-row md:gap-4',
114+
'relative box-border flex h-full flex-col flex-wrap items-center justify-evenly gap-4 overflow-auto md:flex-row',
113115
codeEditorShowing
114116
? 'md:max-h-[calc(40vh-1.25rem)] md:overflow-auto'
115117
: '',
116118
)}
117119
>
118-
<div ref={exampleHtmlRef} className='contents h-full w-full' />
120+
<div ref={exampleHtmlRef} className='contents' />
119121
</div>
120122
)
121123
: <GPUUnsupportedPanel />}
@@ -167,6 +169,19 @@ export function ExampleView({ example }: Props) {
167169
/>
168170
))}
169171
</div>
172+
173+
<div className='absolute right-0 z-5 md:top-15 md:right-8'>
174+
<Button
175+
onClick={() => openInStackBlitz(example)}
176+
>
177+
<span className='font-bold'>Edit on</span>
178+
<img
179+
src='https://developer.stackblitz.com/img/logo/stackblitz-logo-black_blue.svg'
180+
alt='stackblitz logo'
181+
className='h-4'
182+
/>
183+
</Button>
184+
</div>
170185
</div>
171186
)
172187
: null}

apps/typegpu-docs/src/components/design/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Button = forwardRef<HTMLButtonElement, Props>((props, ref) => {
1313
return (
1414
<button
1515
className={cs(
16-
'box-border inline-flex items-center justify-center rounded-[6.25rem] px-5 py-2.5 text-sm focus:ring-2 focus:ring-gradient-blue',
16+
'box-border inline-flex items-center justify-center gap-2 rounded-[6.25rem] px-5 py-2.5 text-sm focus:ring-2 focus:ring-gradient-blue',
1717
accent
1818
? 'bg-gradient-to-br from-gradient-purple to-gradient-blue text-white hover:from-gradient-purple-dark hover:to-gradient-blue-dark'
1919
: 'border-2 border-tameplum-100 bg-white hover:bg-tameplum-20',

apps/typegpu-docs/src/content/examples/image-processing/blur/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function render() {
295295
device.queue.submit([encoder.finish()]);
296296
}
297297

298-
render();
298+
setTimeout(() => render(), 100);
299299

300300
// #region Example controls & Cleanup
301301

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<canvas></canvas>

0 commit comments

Comments
 (0)