feat: add json props export per template
Made-with: Cursor
This commit is contained in:
parent
e5e7550c8c
commit
5d9b985bc3
32
src/App.tsx
32
src/App.tsx
|
|
@ -8,7 +8,7 @@ import { renderToStaticMarkup } from 'react-dom/server'
|
||||||
type TemplateEntry = (typeof templates)[number]
|
type TemplateEntry = (typeof templates)[number]
|
||||||
|
|
||||||
type DeviceMode = 'desktop' | 'mobile'
|
type DeviceMode = 'desktop' | 'mobile'
|
||||||
type ContentMode = 'preview' | 'html'
|
type ContentMode = 'preview' | 'html' | 'json'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [selectedId, setSelectedId] = useState<TemplateId>('invitation')
|
const [selectedId, setSelectedId] = useState<TemplateId>('invitation')
|
||||||
|
|
@ -37,6 +37,11 @@ function App() {
|
||||||
</html>`
|
</html>`
|
||||||
}, [SelectedComponent, selected])
|
}, [SelectedComponent, selected])
|
||||||
|
|
||||||
|
const json = useMemo(
|
||||||
|
() => JSON.stringify(selected.props, null, 2),
|
||||||
|
[selected],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<aside className="app-panel app-sidebar">
|
<aside className="app-panel app-sidebar">
|
||||||
|
|
@ -143,9 +148,18 @@ function App() {
|
||||||
>
|
>
|
||||||
HTML
|
HTML
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={
|
||||||
|
'chip' + (contentMode === 'json' ? ' chip--active' : '')
|
||||||
|
}
|
||||||
|
onClick={() => setContentMode('json')}
|
||||||
|
>
|
||||||
|
JSON
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{contentMode === 'preview' ? (
|
{contentMode === 'preview' && (
|
||||||
<div className="preview-frame">
|
<div className="preview-frame">
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
|
|
@ -161,13 +175,15 @@ function App() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
)}
|
||||||
|
{contentMode === 'html' && (
|
||||||
<div className="preview-frame">
|
<div className="preview-frame">
|
||||||
<textarea
|
<textarea className="html-output" readOnly value={html} />
|
||||||
className="html-output"
|
</div>
|
||||||
readOnly
|
)}
|
||||||
value={html}
|
{contentMode === 'json' && (
|
||||||
/>
|
<div className="preview-frame">
|
||||||
|
<textarea className="html-output" readOnly value={json} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user