summaryrefslogtreecommitdiff
path: root/plugins/theme-examples/hooks/interactive.tsx
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-11-20 20:52:52 +0000
committerClaude <noreply@anthropic.com>2026-11-20 20:52:52 +0000
commit4e7fef8cacbc5d051fbcb94dfba9f14f285216dc (patch)
tree58ed0d877ed34991db52f3ee8779bf6a68ecaa1f /plugins/theme-examples/hooks/interactive.tsx
parentf87ea647eab3b3aa765ed79dbc1eaeb1450d18d2 (diff)
parentd586c3f10a8c2366179bf46b097b4f652622ffc6 (diff)
Merge remote-tracking branch 'origin/main' into mhegazy/sg-count-dropped-changesmhegazy/sg-count-dropped-changes
Diffstat (limited to 'plugins/theme-examples/hooks/interactive.tsx')
-rw-r--r--plugins/theme-examples/hooks/interactive.tsx48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/theme-examples/hooks/interactive.tsx b/plugins/theme-examples/hooks/interactive.tsx
new file mode 100644
index 00000000..7f0b2cc6
--- /dev/null
+++ b/plugins/theme-examples/hooks/interactive.tsx
@@ -0,0 +1,48 @@
+import type { ElementConstructor, RenderElement, ShaderProps } from 'claude-code'
+
+import type { ShaderScene } from './themes'
+
+/**
+ * Lays a theme's shader over its still Svg. A theme with no shader gets the Svg back unchanged.
+ *
+ * A new scene needs its name in `ShaderScene` and a case of its own here: the type checker refuses a name with no case,
+ * and where no checker ran such a theme shows its Svg alone.
+ * Claude Code finds shader files by reading this source, and takes only a `module` written as a string in an element
+ * named `Shader`: a path from a list, or a renamed parameter, leaves the Svg showing alone.
+ */
+export function overShader(
+ Shader: ElementConstructor<ShaderProps> | undefined,
+ shader: ShaderScene | undefined,
+ still: RenderElement,
+): RenderElement {
+ // A Claude Code from before shaders gives no Shader: the Svg is the whole scene.
+ if (Shader === undefined || shader === undefined) {
+ return still
+ }
+
+ switch (shader) {
+ case 'duck-pond':
+ return <Shader module="./scenes/duck-pond/scene.ts">{still}</Shader>
+ case 'falling-sand':
+ return <Shader module="./scenes/falling-sand/scene.ts">{still}</Shader>
+ case 'field-lines':
+ return <Shader module="./scenes/field-lines/scene.ts">{still}</Shader>
+ case 'garden-beetles':
+ return <Shader module="./scenes/garden-beetles/scene.ts">{still}</Shader>
+ case 'koi-pond':
+ return <Shader module="./scenes/koi-pond/scene.ts">{still}</Shader>
+ case 'ripple-tank':
+ return <Shader module="./scenes/ripple-tank/scene.ts">{still}</Shader>
+ case 'sea-sparkle':
+ return <Shader module="./scenes/sea-sparkle/scene.ts">{still}</Shader>
+ case 'semicolony':
+ return <Shader module="./scenes/semicolony/scene.ts">{still}</Shader>
+ case 'star-chart':
+ return <Shader module="./scenes/star-chart/scene.ts">{still}</Shader>
+ }
+
+ // Reached only by a name with no case above, which the type checker refuses on this line.
+ shader satisfies never
+
+ return still
+}