diff --git a/docs/Playground.module.css b/docs/Playground.module.css new file mode 100644 index 0000000..d2590c8 --- /dev/null +++ b/docs/Playground.module.css @@ -0,0 +1,27 @@ +.playground { + display: flex; + flex-direction: column; + border: 1px solid grey; + border-radius: 10px; + justify-content: center; + padding: 0.25rem; +} + +.subheading { + border-bottom: 1px solid grey; + padding: 0.25rem; + margin: auto 10px; + display: flex; + justify-content: space-between; +} + +.tabButton { + padding: 0.375rem 0.75rem; + border-radius: 0.375rem; + background-color: transparent; +} + +.selectedTabButton { + background-color: rgba(218, 200, 200, 0.3); + color: white; +} diff --git a/docs/Playground.tsx b/docs/Playground.tsx index ad492d3..86ab252 100644 --- a/docs/Playground.tsx +++ b/docs/Playground.tsx @@ -1,22 +1,31 @@ 'use server'; +import { clsx } from 'clsx'; +import { CodeXml, Smartphone, Tablet, TvMinimal } from 'lucide-react'; import { useMemo, useState } from 'react'; import { type Component } from '../emails/jsx.js'; import { render } from '../emails/render.js'; import { jsx } from '../emails/runtime.js'; +import styles from './Playground.module.css'; +import { DisplayRawFile } from './RawFunction.js'; export type PlaygroundProps = { component: Component<{}>; + label: string; + rawFunction: string; }; export function Playground(props: PlaygroundProps) { - const { component } = props; + const { component, label, rawFunction } = props; const [dimension, setDimension] = useState({ - height: '480', - width: '320', + height: '100%', + width: '40%', }); + const [selectedTab, setSelectedTab] = useState< + 'phone' | 'tablet' | 'desktop' | 'code' + >('phone'); // This needs to be executed server-side due to // `render` being a server-side function. @@ -25,69 +34,90 @@ export function Playground(props: PlaygroundProps) { }, [component]); return ( -
-
- - - + + + +
+ + {selectedTab === 'code' && ( + + )} + {selectedTab !== 'code' && ( +