Skip to content

Commit 4497438

Browse files
authored
Added SplatViewer TSDocs (#151)
* using vercel url for VO button * removed redundant blocks dependency as it's already implied * Fix url issue * Refactor SplatViewer documentation to use updated import paths for Viewer components * Update documentation: Rename 'Introduction' to 'Home', add 'Installation' page, and improve installation instructions for PlayCanvas Blocks. * better V0 layout
1 parent da630ea commit 4497438

File tree

5 files changed

+70
-45
lines changed

5 files changed

+70
-45
lines changed

packages/docs/content/blocks/index.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Introduction
2+
title: Home
33
description: Clean, modern building blocks. Copy and paste into your apps. Works with all React frameworks. Open Source. Free forever.
44
openGraph:
55
title: playcanvas/react docs - Blocks
@@ -29,7 +29,7 @@ export const splatVersion = registry.items.find(item => item.name === 'splat-vie
2929
PlayCanvas Blocks are high-level component primitives for React. Clean, simple, and beautiful by default, they're designed to drop into your project and get to work. Built around **@playcanvas/react** and **@shadcn/ui** they're composable, themeable and ready to use out of the box.
3030

3131
<div className='flex flex-row gap-2 mt-4 items-center'>
32-
<a className="flex items-center -ml-2 flex-row gap-2 bg-muted rounded-full p-2 px-4 max-w-fit" href="blocks/getting-started">
32+
<a className="flex items-center -ml-2 flex-row gap-2 bg-muted rounded-full p-2 px-4 max-w-fit" href="blocks/installation">
3333
<Box size={14} className="text-muted-foreground" />
3434
<div className="text-xs font-medium text-muted-foreground hover:text-foreground transition-colors duration-200">Get Started</div>
3535
<ArrowRight size={14} className="text-muted-foreground" />
@@ -42,12 +42,12 @@ PlayCanvas Blocks are high-level component primitives for React. Clean, simple,
4242
</div>
4343

4444
<div className='relative mb-4 lg:mb-12'>
45-
<Viewer.Splat src={splatUrl} className="aspect-4:1 lg:my-8 -mx-6 bg-gray-200 rounded-lg shadow-xl cursor-grab active:cursor-grabbing pointer-events-none" />
46-
<div className='lg:absolute bottom-0 right-0 w-full py-2 lg:py-8 lg:text-background text-xs italic text-center'>
47-
Rendered with the <code>Viewer.Splat</code> component — a React block for Gaussian splats.
48-
<a className="hover:underline pointer-events-auto" href="/blocks/splat-viewer">
49-
Learn more →
50-
</a>
45+
<Viewer.Splat src={splatUrl} className="aspect-4:1 mt-8 lg:my-8 -mx-4 lg:-mx-6 bg-gray-200 lg:rounded-lg shadow-xl cursor-grab active:cursor-grabbing" />
46+
<div className='lg:absolute bottom-0 right-0 w-full py-2 lg:py-8 lg:text-background text-xs italic text-center pointer-events-none'>
47+
<span className="pointer-events-auto">
48+
Rendered with the <code>Viewer.Splat</code> component — a React block for Gaussian splats.{" "}
49+
<a className="underline text-bold" href="/blocks/splat-viewer">Learn more →</a>
50+
</span>
5151
</div>
5252
</div>
5353

packages/docs/content/blocks/getting-started.mdx renamed to packages/docs/content/blocks/installation.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Installation
3+
description: Installation instructions for PlayCanvas Blocks
4+
---
5+
16
import { Tabs, Card, Code, Bleed, Steps } from 'nextra/components'
27
import { ArrowRight, Hexagon, Box } from 'lucide-react'
38
import { Button } from '@components/ui/button'
@@ -16,7 +21,7 @@ The recommended way to install Blocks is using Shadcn's CLI. Each Block can be i
1621
npx shadcn@latest add https://playcanvas-react.vercel.app/r/splat-viewer.json
1722
```
1823

19-
## Package Manager
24+
## Manual Installation
2025

2126
Alternatively, you can simply install the package from npm, yarn, pnpm or bun and import the components you need.
2227

packages/docs/content/blocks/splat-viewer.mdx

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tabs, Card, Code, Bleed, Steps } from 'nextra/components'
1+
import { Tabs, Card, Code, Pre, Bleed, Steps } from 'nextra/components'
22
import { ArrowRight, Hexagon, Box } from 'lucide-react'
33
import registry from '../../registry.json'
44

@@ -15,7 +15,7 @@ Supports large assets with lazy loading and automatic framing. Use it in modals,
1515
Supports compressed gaussian splats.
1616

1717
<div className="lg:outline lg:p-28 -mx-4 lg:-mx-6 mt-12 mb-0 rounded-t-lg bg-linear-to-br from-indigo-500 to-purple-600 relative">
18-
{/* <OpenInV0Button url="https://v0.dev/chat/api/open?url=https://playcanvas-react.vercel.app/r/splat-viewer.json" className="absolute top-4 right-4" /> */}
18+
<OpenInV0Button url={`https://${process.env.VERCEL_URL}/r/splat-viewer.json`} className="absolute top-4 right-4" />
1919
<Viewer.Splat src={splatUrl} className="aspect-2.39:1 bg-purple-200 rounded-t-lg lg:rounded-lg shadow-xl cursor-grab active:cursor-grabbing" >
2020
<Viewer.Controls autoHide >
2121
<div className="flex gap-1 flex-grow">
@@ -101,17 +101,36 @@ Supports compressed gaussian splats.
101101

102102
### Installation
103103

104-
Install the component from your command line.
104+
<Tabs items={['Manual', 'Shadcn']} className="!mt-0" tabClassName="!mt-2">
105+
<Tabs.Tab title='Manual' className="!mt-0 !rounded-t-none !rounded-b-xl">
106+
Follow the instructions on the [Blocks page](/blocks/installation) to install the component.
105107

106-
```bash copy
107-
npx shadcn@latest add https://playcanvas-react.vercel.app/r/splat-viewer.json
108-
```
108+
```bash copy
109+
npm install @playcanvas/blocks
110+
```
109111

110-
Ensure the block is processed by Tailwind by adding the following to your `index.css`.
112+
Install Tailwind and add the following to your `index.css`.
113+
114+
```css
115+
@import "@playcanvas/blocks";
116+
@source "../node_modules/@playcanvas/blocks";
117+
```
118+
</Tabs.Tab>
119+
<Tabs.Tab title='Shadcn' className="!mt-0 !rounded-t-none !rounded-b-xl">
120+
Install the component from your command line.
121+
122+
```bash copy
123+
npx shadcn@latest add https://playcanvas-react.vercel.app/r/splat-viewer.json
124+
```
125+
126+
Ensure the block is processed by Tailwind by adding the following to your `index.css`.
127+
128+
```css
129+
@source "../node_modules/@playcanvas/blocks";
130+
```
131+
</Tabs.Tab>
132+
</Tabs>
111133

112-
```css
113-
@source "../node_modules/@playcanvas/blocks";
114-
```
115134

116135
### Anatomy
117136

@@ -134,26 +153,26 @@ export default () => (
134153

135154
### API Reference
136155

137-
#### SplatViewer
156+
#### Splat
138157

139158
A responsive and composable component for displaying **Gaussian splats**.
140159

141-
{/* <TSDoc
160+
<TSDoc
142161
code={`
143162
import { Viewer } from '@playcanvas/blocks';
144-
type $ = React.ComponentProps<typeof Splat.Viewer>;
163+
type $ = React.ComponentProps<typeof Viewer.Splat>;
145164
export default $;
146165
`}
147-
/> */}
166+
/>
148167

149168
#### Controls
150169

151170
A simple container for UI controls that creates a sensible layout and optionally auto hides when the user is interacting.
152171

153-
{/* <TSDoc
172+
<TSDoc
154173
code={`
155-
import * as Splat from '@registry/splat-viewer/';
156-
type $ = React.ComponentProps<typeof Splat.Controls>;
174+
import { Viewer } from '@playcanvas/blocks';
175+
type $ = React.ComponentProps<typeof Viewer.Controls>;
157176
export default $;
158177
`}
159178
/>
@@ -164,8 +183,8 @@ A button for entering and exiting full screen mode.
164183

165184
<TSDoc
166185
code={`
167-
import * as Splat from '@registry/splat-viewer/';
168-
type $ = React.ComponentProps<typeof Splat.FullScreenButton>;
186+
import { Viewer } from '@playcanvas/blocks';
187+
type $ = React.ComponentProps<typeof Viewer.FullScreenButton>;
169188
export default $;
170189
`}
171190
/>
@@ -176,8 +195,8 @@ A button for downloading the current scene.
176195

177196
<TSDoc
178197
code={`
179-
import * as Splat from '@registry/splat-viewer/';
180-
type $ = React.ComponentProps<typeof Splat.DownloadButton>;
198+
import { Viewer } from '@playcanvas/blocks';
199+
type $ = React.ComponentProps<typeof Viewer.DownloadButton>;
181200
export default $;
182201
`}
183-
/> */}
202+
/>

packages/docs/registry.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"version": "0.1.0.beta.1"
3838
},
3939
"dependencies": [
40-
"@playcanvas/blocks",
4140
"@playcanvas/react",
4241
"playcanvas"
4342
],

packages/docs/registry/splat-viewer.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ const splatUrl = "https://d28zzqy0iyovbz.cloudfront.net/30b943d5/scene.compresse
44

55
export function SplatViewer() {
66
return (
7-
<Viewer.Splat src={splatUrl} className="rounded-lg shadow-xl cursor-grab active:cursor-grabbing" >
8-
<Viewer.Controls >
9-
<div className="flex gap-1 pointer-events-auto flex-grow">
10-
<Viewer.FullScreenButton />
11-
<Viewer.DownloadButton />
12-
</div>
13-
<div className="flex gap-1 pointer-events-auto">
14-
<Viewer.CameraModeToggle />
15-
<Viewer.HelpButton />
16-
<Viewer.MenuButton />
17-
</div>
18-
</Viewer.Controls>
19-
</Viewer.Splat>
7+
<div className="flex flex-col items-center justify-center min-h-screen gap-4">
8+
<Viewer.Splat src={splatUrl} className="rounded-lg shadow-xl cursor-grab active:cursor-grabbing" >
9+
<Viewer.Controls >
10+
<div className="flex gap-1 pointer-events-auto flex-grow">
11+
<Viewer.FullScreenButton />
12+
<Viewer.DownloadButton />
13+
</div>
14+
<div className="flex gap-1 pointer-events-auto">
15+
<Viewer.CameraModeToggle />
16+
<Viewer.HelpButton />
17+
<Viewer.MenuButton />
18+
</div>
19+
</Viewer.Controls>
20+
</Viewer.Splat>
21+
</div>
2022
)
2123
}

0 commit comments

Comments
 (0)