Skip to content

Commit c373646

Browse files
authored
Chore docs fixes (#196)
* update install docs * migrates to playcanvas Grid * spacing * Code editor layout fixes * type fixes * more type issue fixes
1 parent 85229d7 commit c373646

File tree

10 files changed

+77
-18
lines changed

10 files changed

+77
-18
lines changed

.changeset/easy-cars-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@playcanvas/blocks": patch
3+
---
4+
5+
Type fixes

packages/blocks/src/splat-viewer/progress-indicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function Progress({ variant = "top", className, style }: ProgressProps) {
1414
const { subscribe } = useAssetViewer();
1515
const ref = useRef<HTMLDivElement>(null);
1616
const [visible, setVisible] = useState(true);
17-
const timeoutRef = useRef<number>(null);
17+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
1818

1919
useEffect(() => {
2020
const unsubscribe = subscribe((progress) => {

packages/blocks/src/splat-viewer/smart-camera.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function SmartCamera({
7575
const entityRef = useRef<PcEntity>(null);
7676
const { subscribe, isPlaying } = useTimeline();
7777
const { mode, subscribeCameraReset } = useAssetViewer();
78-
const timeoutRef = useRef(0);
78+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
7979
const [shouldUseRenderOnCameraChange, setShouldUseRenderOnCameraChange] = useState(false);
8080
const app = useApp();
8181
const initialPoseRef = useRef<PoseType | null>(null);
@@ -85,7 +85,7 @@ export function SmartCamera({
8585
setShouldUseRenderOnCameraChange(true);
8686
app.renderNextFrame = true;
8787
}, 200);
88-
return () => clearTimeout(timeoutRef.current);
88+
return () => clearTimeout(timeoutRef.current!);
8989
});
9090

9191
useRenderOnCameraChange(shouldUseRenderOnCameraChange ? entityRef.current : null);

packages/docs/app/[[...mdxPath]]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default async function Page(props) {
5656

5757
return (
5858
<div className='absolute top-0 left-0 w-screen h-screen pointer-events-none'>
59-
<Playground name={`./${params.mdxPath}.tsx`} code={source} path={metadata.filePath}/>
59+
<Playground name={`./${params.mdxPath.join('/')}.tsx`} code={source} path={metadata.filePath}/>
6060
</div>
6161
)
6262
}

packages/docs/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
5555
</Head>
5656
<body>
5757
<Layout
58-
banner={<Banner storageKey="0.4.2-release"><a href="https://github.com/playcanvas/react/releases/tag/v0.4.2" target="_blank" rel="noreferrer">
58+
banner={<Banner storageKey="0.5.0-release"><a href="https://github.com/playcanvas/react/releases/tag/v0.4.2" target="_blank" rel="noreferrer">
5959
🎉 <b>@playcanvas/react 0.4.2</b> is here! ✨
6060
</a></Banner>}
6161
navbar={navbar}

packages/docs/components/Grid.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
"use client";
2+
3+
import { Entity } from "@playcanvas/react";
14
import { Script } from "@playcanvas/react/components";
2-
import { Grid as GridScript } from "@playcanvas/react/scripts";
5+
import { Grid as GridScript } from "playcanvas/scripts/esm/grid.mjs";
36
import { FC } from "react";
47

58
const Grid: FC = ({ ...props }) => {
6-
return <Script script={GridScript} {...props} />
9+
return <Entity scale={[1000, 1000, 1000]}>
10+
<Script script={GridScript} {...props} />
11+
</Entity>
712
}
813

914
export default Grid;

packages/docs/content/docs/index.mdx

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,51 @@ const App = () => (
116116

117117
## Getting started
118118

119-
**⚡ The quickest way to get started is to use our [playcanvas-react.app/new](https://playcanvas-react.vercel.app/new) starter template.**
119+
The quickest way to get started is to run the following
120+
121+
<Tabs items={['pnpm', 'npm', 'yarn']}>
122+
<Tabs.Tab>
123+
```bash copy
124+
pnpm create playcanvas -t react-ts
125+
```
126+
</Tabs.Tab>
127+
<Tabs.Tab>
128+
```bash copy
129+
npm create playcanvas@latest -t react-ts
130+
```
131+
</Tabs.Tab>
132+
<Tabs.Tab>
133+
```bash copy
134+
yarn create playcanvas -t react-ts
135+
```
136+
</Tabs.Tab>
137+
</Tabs>
120138

121-
For a local npm setup run the following and follow the [Getting Started Guide](/docs/guide/getting-started).
139+
This will spin up a new project and dev environment and get you up and running in seconds.
122140

123-
```bash copy
124-
npm install @playcanvas/react playcanvas
125-
```
141+
Alternatively try the [playcanvas-react.app/new](https://playcanvas-react.vercel.app/new) Stackblitz starter template.
126142

127-
You can also clone the following starter template.
143+
### Installing manually
128144

129-
```bash copy
130-
git clone https://github.com/marklundin/playcanvas-react-template.git
131-
```
145+
If you already have a project setup you can install the library via npm.
146+
147+
<Tabs items={['pnpm', 'npm', 'yarn']}>
148+
<Tabs.Tab>
149+
```bash copy
150+
pnpm add @playcanvas/react
151+
```
152+
</Tabs.Tab>
153+
<Tabs.Tab>
154+
```bash copy
155+
npm install @playcanvas/react
156+
```
157+
</Tabs.Tab>
158+
<Tabs.Tab>
159+
```bash copy
160+
npm install @playcanvas/react
161+
```
162+
</Tabs.Tab>
163+
</Tabs>
132164

133165
## Ready to build?
134166

@@ -160,4 +192,5 @@ To get your IDE up to speed, run the following from the root of your project to
160192
Developers and studios are already using **@playcanvas/react** in production
161193

162194
-[Snap AI](https://ai.snapchat.com) uses **@playcanvas/react** to build real-time 3D interfaces inside their next-gen tools.
195+
- [GSplat Share](https://gsplat.org/) – Share your splats with optional time-limited and password-protected links.
163196
- ✨ Your project here? [Submit a PR](https://github.com/playcanvas/react/compare) and we’ll feature it below.

packages/docs/docs-components/Playground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ const PlayGround: FC<PlaygroundProps> = ({
7676
</div>
7777
{ showCodeEditor && <Suspense>
7878
<div
79-
className='absolute p-0 lg:p-12 pointer-events-auto top-[calc(var(--nextra-navbar-height)+var(--nextra-banner-height))] h-[calc(100vh-var(--nextra-navbar-height)-var(--nextra-banner-height))] flex mx-auto max-w-[90rem] xl:p-8'
79+
className='absolute p-0 pointer-events-auto box-border inset-0 flex mx-auto max-w-[90rem] max-h-[calc(100%-var(--nextra-banner-height))] xl:p-8'
8080
onMouseMove={e => e.stopPropagation() }
8181
>
82-
<div className='w-screen lg:w-lg overflow-hidden rounded-xl shadow-lg opacity-100 hover:opacity-90 focused:opacity-90 transition-opacity duration-300'>
82+
<div className='lg:w-lg m-8 max-h-[calc(100%-8rem)] box-border overflow-hidden rounded-xl shadow-lg opacity-100 hover:opacity-90 focused:opacity-90 transition-opacity duration-300'>
8383
<div id='code-editor-header' className='flex justify-between items-center p-2 bg-zinc-800 px-4'>
8484
<div id='code-editor-title' className='flex text-xs items-center justify-between font-mono opacity-80 w-full'>
8585
<TerminalIcon className='w-4 h-4' />

packages/lib/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,8 @@
106106
"eslint-plugin-require-extensions": "0.1.3",
107107
"jsdom": "26.1.0",
108108
"vitest": "3.2.4"
109+
},
110+
"dependencies": {
111+
"dedent": "^1.6.0"
109112
}
110113
}

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)