// ============================================
// DEMO RENDERER - Generic rendering for command and skill demos
// ============================================
import { getCommandDemo } from './demos/commands/index.js';
import { getSkillDemo } from './demos/skills/index.js';
/**
* Initialize a command demo's JS after its HTML has been inserted into the DOM.
* Call this after innerHTML is set and split compare is initialized.
*/
export function initCommandDemo(commandId, container) {
const demo = getCommandDemo(commandId);
if (demo && typeof demo.init === 'function') {
const demoArea = container.querySelector('.split-after .split-content') || container;
console.log('[initCommandDemo]', commandId, 'demoArea:', demoArea);
demo.init(demoArea);
}
}
/**
* Render a command demo with split-screen comparison
*/
export function renderCommandDemo(commandId) {
const demo = getCommandDemo(commandId);
if (!demo) {
// teach-impeccable is a setup command, not a visual transform — show usage guide instead
if (commandId === 'teach-impeccable') {
return `
When to run
1.Once per project, before using other commands
2.Again if your brand or design direction changes
What it does
→Scans your codebase for existing design patterns
→Asks about brand, users, and aesthetic direction
→Saves a Design Context to your AI config file
All other commands use this context automatically.
`;
}
return `
Visual demo for /${commandId} coming soon
`;
}
// Use split-screen comparison
return `
${demo.before}
${demo.after || demo.before}
${demo.caption}
`;
}
/**
* Render a skill demo (with tabs if multiple demos)
*/
export function renderSkillDemo(skillId) {
const skill = getSkillDemo(skillId);
if (!skill || !skill.tabs || skill.tabs.length === 0) {
return `
Demo for ${skillId.replace(/-/g, ' ')} coming soon