diff --git a/app/components/ascii-art-generator.tsx b/app/components/ascii-art-generator.tsx
index 43ab023..72f38e9 100644
--- a/app/components/ascii-art-generator.tsx
+++ b/app/components/ascii-art-generator.tsx
@@ -681,20 +681,6 @@ export function AsciiArtGenerator() {
[processFile],
)
- const handleExampleScriptClick = useCallback(() => {
- // Open code sidebar and load the clock example
- setShowCodeSidebar(true)
- const template = TEMPLATES.sin
- setPendingCode(template.source.code)
- updateSettings('source', template.source)
- updateSettings('output', template.output)
- updateSettings('export', template.export)
- updateSettings('preprocessing', template.preprocessing)
- updateSettings('meta', template.meta)
- updateSettings('source', template.source)
- updateSettings('animation', template.animation)
- }, [updateSettings])
-
const handleTemplateChange = (template: TemplateType) => {
if (template !== 'custom' && TEMPLATES[template]) {
loadTemplate(template)
@@ -811,18 +797,8 @@ export function AsciiArtGenerator() {
disabled={!program}
exportSettings={settings.export}
/>
-
- {/* Project Management */}
-
-
+ {/* Project Management */}
+
@@ -890,7 +875,7 @@ export function AsciiArtGenerator() {
animationController={animationController}
setAnimationController={setAnimationController}
isExporting={isExporting}
- onExampleScriptClick={handleExampleScriptClick}
+ onExampleScriptClick={(template) => loadTemplate(template)}
onExampleImageClick={() =>
updateSourceAndAspectRatio(exampleImage, 'image', 'example-grad.png')
}
diff --git a/app/components/ascii-preview.tsx b/app/components/ascii-preview.tsx
index 3745f8b..7df79ed 100644
--- a/app/components/ascii-preview.tsx
+++ b/app/components/ascii-preview.tsx
@@ -8,18 +8,21 @@
import {
Action16Icon,
AutoRestart12Icon,
+ DirectionDownIcon,
DirectionRightIcon,
DocumentApi16Icon,
Folder16Icon,
Resize16Icon,
} from '@oxide/design-system/icons/react'
import useResizeObserver from '@react-hook/resize-observer'
+import cn from 'classnames'
import { motion } from 'motion/react'
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
import { useHotkeys } from 'react-hotkeys-hook'
import type { createAnimation, Program } from '~/lib/animation'
import { InputButton, InputNumber } from '~/lib/ui/src'
+import { TEMPLATES, type TemplateType } from '~/templates'
import AsciiAnimation from './ascii-animation'
import type { GridType } from './ascii-art-generator'
@@ -43,7 +46,7 @@ interface AsciiPreviewProps {
setAnimationController: (controller: AnimationController) => void
isExporting: boolean
onUploadClick?: () => void
- onExampleScriptClick?: () => void
+ onExampleScriptClick?: (templateType: TemplateType) => void
onExampleImageClick?: () => void
}
@@ -54,13 +57,17 @@ const DemoCard = ({
title,
onClick,
index,
+ hasDropdown = false,
+ onDropdownChange,
}: {
icon: React.ReactNode
title: string
onClick?: () => void
index: number
+ hasDropdown?: boolean
+ onDropdownChange?: (value: string) => void
}) => (
-
{icon}
{title}
-
+ {hasDropdown && (
+
+
+
+
+ )}
+
+
)
const useSize = (target: HTMLDivElement | null) => {
@@ -217,7 +249,11 @@ export function AsciiPreview({
index={1}
icon={}
title="Run example script"
- onClick={onExampleScriptClick}
+ hasDropdown={true}
+ onDropdownChange={(templateKey) =>
+ onExampleScriptClick?.(templateKey as TemplateType)
+ }
+ onClick={() => onExampleScriptClick?.('sin')}
/>
+
value={templateType}
onChange={handleTemplateChange}
@@ -91,7 +91,7 @@ export function ProjectManagement({
- Load
+ Load JSON