mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(site): add interactive getting started guide (#280)
Co-authored-by: Darius Cepulis <dcepulis@mux.com>
This commit is contained in:
co-authored by
Darius Cepulis
parent
0c530765d5
commit
8ed455c20a
@@ -0,0 +1,40 @@
|
||||
import { useStore } from '@nanostores/react';
|
||||
import ClientCode from '@/components/Code/ClientCode';
|
||||
import { Tab, TabsList, TabsPanel, TabsRoot } from '@/components/Tabs';
|
||||
import type { Renderer } from '@/stores/installation';
|
||||
import { muxPlaybackId, renderer } from '@/stores/installation';
|
||||
|
||||
function generateUsageCode(renderer: Renderer, playbackId: string | null): string {
|
||||
const isMuxWithPlaybackId = renderer === 'mux' && playbackId;
|
||||
const playerProp = isMuxWithPlaybackId ? `playbackId="${playbackId}"` : 'src="https://example.com/video.mp4"';
|
||||
|
||||
return `// HomePage.tsx
|
||||
import { MyPlayer } from '../components/player';
|
||||
|
||||
export const HomePage = () => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Welcome to My App</h1>
|
||||
<MyPlayer ${playerProp} />
|
||||
</div>
|
||||
);
|
||||
};`;
|
||||
}
|
||||
|
||||
export default function ReactUsageCodeBlock() {
|
||||
const $renderer = useStore(renderer);
|
||||
const $muxPlaybackId = useStore(muxPlaybackId);
|
||||
|
||||
return (
|
||||
<TabsRoot maxWidth={false}>
|
||||
<TabsList label="React usage">
|
||||
<Tab value="react" initial>
|
||||
React
|
||||
</Tab>
|
||||
</TabsList>
|
||||
<TabsPanel value="react" initial>
|
||||
<ClientCode code={generateUsageCode($renderer, $muxPlaybackId)} lang="tsx" />
|
||||
</TabsPanel>
|
||||
</TabsRoot>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user