Design a component sandbox where PMs and designers can assemble flows, export test…
- User
Design a component sandbox where PMs and designers can assemble flows, export test cases, and feed them into automated QA.
- Assistant
Here's a thinking process that leads to the suggested Neo-Brutalism / Y2K component sandbox:
-
Analyze the Request:
- Goal: Design a "component sandbox" for PMs and designers.
- Core Features: Assemble flows, export test cases, feed into automated QA.
- Role: Front-end expert, visual designer, specializing in Neo-Brutalism & Y2K aesthetics. Avoidance of "clean" or "modern" looks. Raw, clashing colors, hard borders, unpolished, glitch effects, marquee, typography chaos.
-
Conceptualization & UI/UX Strategy:
- Theme: "Cyber-Punk Industrial" or "Office Space Chaos". Think dial-up sounds (visualized), jagged edges, aggressive colors (acid green, neon pink, bright yellow) against stark black/white.
- Layout: A "Windows 95" vibe but dialed up to 11. Not retro-cutesy, but aggressively pixelated and glitchy. Multiple overlapping windows (components) that can be dragged (simulated or real). A marquee bar at the top for status. A sidebar for tools (blocks/palette).
- Interaction:
- Drag and drop components (blocks representing screens/steps) onto a canvas.
- Connect steps with "wires" (maybe jagged Bézier curves).
- Properties panel to edit text/content of a block.
- "Export Test Case" button (big, ugly, satisfying click).
- Feedback: Glitch text on action, screen shake.
-
Technical Stack (Constraints):
- Single HTML file (HTML + CSS + JS).
- No external libraries (except maybe fonts/icons via CDN, but the prompt says "no external libraries unless requested", but "Technology constraints" say "By default, avoid JavaScript... only introduce JavaScript if the user explicitly requests interactive behavior."
- Correction: The user did ask for a "sandbox where PMs and designers can assemble flows, export test cases". This requires significant interactivity (drag/drop, state management). Therefore, I must use JavaScript. I will stick to vanilla JS (no React/vue).
- Tailwind CSS? The prompt says "Tailwind CSS: ... ...". Wait, looking back: "Technology constraints: By default, avoid JavaScript for static showcase pages... only introduce JavaScript if the user explicitly requests interactive behavior." The user did request interactivity. However, the "Technical Stack" section in my persona mentions "Tailwind CSS". But I am generating a single HTML file. I can include Tailwind via CDN. That aligns with the "Technology Stack" section. Let's use Tailwind via CDN for rapid, ugly styling (hard borders, absolute positioning, etc.) plus custom CSS for the glitch effects.
-
Design Details (Neo-Brutalism / Y2K):
- Colors: (
#FFFF00yellow,#00FF00green,#FF00FFmagenta,#000000black,#FFFFFFwhite). - Typography:
Courier New,Times New Roman,Impact, pixelated fonts (Google Fonts: "Press Start 2P", "VT323"). - Borders: Solid black, 3px or 4px. Box shadows? Hard offset shadows:
4px 4px 0px 0px #000. - Marquee: CSS animation moving text infinitely left-to-right.
- Glitch: CSS keyframes with
clip-pathandtransform.
- Colors: (
-
Functional Requirements:
- Palette: Pre-defined "components" (e.g., "Input Field", "Error Modal", "Hero Banner", "Checkout Button").
- Canvas: An area to drop these components to build a "flow".
- Connecting: Visually link components to show flow direction. (Simplification: Click two components to connect? Or just visually stack? For simplicity and robustness in a single file without libraries, maybe a linear flow builder is easier than a free canvas. But "sandbox" implies canvas. I'll implement a basic drag-and-drop to container, and maybe simple SVG lines drawn or just blocks arranged sequentially to represent flow).
- Export: Generate a JSON "test case" representation.
- Feedback: Toast notification "TEST CASE EXPORTED" with glitch effect.
-
Step-by-Step Implementation Plan:
-
Structure:
<head>: Tailwind CDN, Google Fonts (Press Start 2P,VT323), Custom CSS (glitch, marquee, hard borders utilities).<body>:- Top Header: Marquee text (e.g., "SYSTEM READY... BUILDING QA FLOW...").
- Main Layout: Grid/Flex.
- Left Sidebar: Library of draggable blocks. Huge buttons.
- Center: The Canvas (grid background).
- Right Sidebar: Properties (to rename the block) & Actions (Export).
- Overlay/Toast: Hidden by default, shows on export.
-
CSS Customization (The "Brutalist" Sauce):
border-black: 3px solid black.shadow-brutal:box-shadow: 4px 4px 0px 0px #000;.font-pixel: 'Press Start 2P'.font-terminal: 'VT323'.
-
JavaScript Logic:
- State:
componentsarray (id, type, x, y, properties). - Drag & Drop:
dragstarton palette items (set transfer data).dropon canvas (read data, create new DOM element, position based on mouse).dragon canvas elements to move them.
- Selection: Click a component to populate the "Properties" panel.
- Properties: Inputs to change text/content.
- Export:
console.log(JSON.stringify(state))and show a modal/div with the raw JSON (ugly monospaced font).
- State:
-
-
Refining the "Y2K/Neo-Brutalism" Vibe:
- The background should be a grid pattern (dot or line).
- The cursors should be custom (maybe default crosshair).
- Buttons should have
hoverstates that invert colors or shift position (brutal shift). - The "Export" button should be massive, flashing, maybe a rainbow gradient border.
-
Drafting the Code (Mental or Scratchpad):
-
Fonts: Import
Press Start 2PandVT323. -
Tailwind Config: Need to enable arbitrary values just in case, but standard classes usually suffice. I'll stick to standard classes plus a few custom
<style>blocks for animations. -
Marquee:
@keyframes scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } } -
Glitch Effect: Use
data-textattribute and::before/::afterwithclip-pathanimation. -
Canvas Interaction:
container.drag-over:e.preventDefault().drop: Create elementdivwith classabsolute cursor-move border-4 border-black bg-white shadow-brutal. Add inner content based on type (e.g., "BUTTON").- Store reference in
state. - The
dragevent on the absolute item needs to updatetop/left.
-
-
Addressing "No Frameworks" vs "Tailwind":
- The persona says "Tailwind CSS" under tech stack, but the system prompt says "By default, avoid JavaScript... only use icon libraries...". There is a slight conflict, but the persona overrides the generic system instructions for the assignment. The user explicitly wants a "sandbox" which implies JS.
- I will use Tailwind via CDN script. This is acceptable as a "utility-first CSS framework" that runs in the browser.
-
Polishing the "Product":
- Make it feel like a 90s software:
- Title bar: "COMPONENT SANDBOX v1.0 [X]".
- Status bar at bottom: "MEM: OK", "DISK: A:" or similar.
- Buttons with "heavy" bevels (double borders).
- Make it feel like a 90s software:
-
Code Construction (Iterative refinement):
-
HTML Structure:
<div id="app" class="h-screen w-screen overflow-hidden bg-[#c0c0c0] flex flex-col border-4 border-black font-vt323"> <!-- Top Marquee --> <div class="bg-yellow-400 border-b-4 border-black p-2 overflow-hidden"> <!-- spans cloned for loop --> </div> <!-- Main Area --> <div class="flex-1 flex"> <!-- Sidebar Library --> <aside class="w-64 bg-blue-300 border-r-4 border-black overflow-y-auto p-4"> <!-- Draggable Items --> </aside> <!-- Canvas --> <main id="canvas" class="flex-1 bg-white relative overflow-hidden"></main> <!-- Sidebar Controls --> <aside class="w-72 bg-pink-300 border-l-4 border-black p-4 flex flex-col"> <!-- Properties & Export --> </aside> </div> <!-- Footer --> <footer>...</footer> </div> -
JS Logic:
itemslibrary definition:['Form Input', 'Submit Button', 'Alert Box', 'Loading Spinner'].- Function
renderLibrary(): loops through items, creates draggable buttons. dragstart:e.dataTransfer.setData('type', type).drop:createComponent(type, x, y).createComponent(type, x, y): createsdivwithid, content (dummy icon/text), adds event listeners formousedown(to move),click(to select).updateProperties(): called when selecting. Populates input fields.Export: readsstateor simply queries DOM children fortypeandtextData, builds JSON, dumps to a modal.
-
*Aesthetic Tweaks:
- Use
clip-path: polygon(...)for triangles/shapes. - Use
mix-blend-mode: differenceon overlapping elements. - Add a "scanline" overlay using
pointer-events-none.
- Use
-
-
Final Review against constraints:
- Single file? Yes.
- No frameworks (React/Vue)? Yes.
- No alerts? Use custom modal/toast.
- Neo-Brutalism/Y2K? High contrast, hard borders, pixel fonts, marquee, clashing colors.
- Functional? Drag/drop, edit props, export JSON.
-
Self-Correction during coding:
- Issue: Moving absolute divs with drag events can be finicky with offsets.
- Fix: Use
mousedownto track movement strictly within the canvas context, updatingstyle.leftandstyle.top. Sete.stopPropagation()to avoid conflicts. - Issue: "Feeding into automated QA" implies output format. A simple JSON array of
{ type, id, content, position }is sufficient. - Visual: Ensure the colors aren't too ugly, but intentionally loud. Acid palette: Lime green (
#ccff00), Cyber yellow (#faff00), Hot pink (#ff0099), Cyan (#00ffff).
-
Final Output Generation: Assemble HTML, CSS, and JS into the final block. (Detailed coding follows in the actual response).
- Note: I will use
https://cdn.tailwindcss.comfor styles. - Note: I will include a small script to generate the marquee duplicates to ensure smooth looping.
- Note: I will use
-
Writing the Explanation: Keep the tone enthusiastic about the "unpolished" beauty. Explain the features: Drag & drop, properties editing, JSON export.
(Self-Correction during implementation of "Flow"): The prompt says "assemble flows". This suggests ordering/wiring. In a simple drag-and-drop, we can simulate "flow" by arranging blocks left-to-right, and drawing lines between them (SVG). Implementing SVG line drawing that updates on drag is complex but doable. I'll implement a simplified version: Blocks have a "Next" dropdown in properties to link to another block's ID. Alternatively, just drag and drop to build a stack, and the export includes the array order. To keep the code manageable but impressive:
- Canvas allows placing blocks anywhere.
- Selected block shows "Connect to" dropdown (list of other block IDs).
- The export JSON contains
connectionsarray. - Visual lines are drawn via SVG overlay on the canvas. I'll add simple SVG bezier curves connecting bottom of source to top of target. I'll update lines on drag. This is a high-value feature that fits "Sandbox".
Let's do it.
Proceed to generate code. Here is a Neo-Brutalism / Y2K Component Sandbox.
This is a single-file solution that combines aggressive aesthetics with a fully functional drag-and-drop interface. It allows product managers to drag UI components onto a canvas, tweak their properties, define logical flows (connections), and export a JSON test case ready for automation.
Design Highlights:
- Aesthetic: Brutalist borders (4px solid black), aggressive "acid" colors, pixelated fonts (
Press Start 2P), and raw Windows 95-ish UI. - Interactivity: Drag & drop components, move them around, connect them via logical wires (SVG bezier curves), edit text in real-time, and export.
- Feedback: Glitch text effects, screen shake on export, and infinite marquees to create a sense of urgency and "data flow".
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>QA_FLOW_SANDBOX.EXE</title> <!-- Tailwind CSS --> <script src="https://cdn.tailwindcss.com"></script> <!-- Google Fonts for Y2K/Pixel vibes --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap" rel="stylesheet"> <!-- Custom Config & Styles --> <script> tailwind.config = { theme: { extend: { colors: { 'brutal-black': '#000000', 'brutal-white': '#ffffff', 'acid-yellow': '#ccff00', 'acid-green': '#00ff41', 'acid-pink': '#ff0099', 'acid-cyan': '#00ffff', 'acid-orange': '#ff6600', 'gray-90': '#e5e5e5', }, fontFamily: { 'pixel': ['"Press Start 2P"', 'cursive'], 'terminal': ['"VT323"', 'monospace'], }, boxShadow: { 'brutal': '4px 4px 0px 0px #000', 'brutal-hover': '2px 2px 0px 0px #000', 'brutal-sm': '2px 2px 0px 0px #000', } } } } </script> <style> /* Base Reset & Utilities */ body { cursor: crosshair; overflow: hidden; user-select: none; } /* The "Grid" background pattern */ .canvas-bg { background-color: #fff; background-image: linear-gradient(#000 1px, transparent 1px), linear-gradient(90deg, #000 1px, transparent 1px); background-size: 20px 20px; } /* Marquee Animation */ @keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } } .animate-marquee { display: flex; white-space: nowrap; animation: marquee 20s linear infinite; } /* Glitch Effect Class */ .glitch-wrapper { position: relative; } .glitch-wrapper::before, .glitch-wrapper::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #fff; /* Match container bg */ opacity: 0.8; } .glitch-wrapper::before { color: #0ff; z-index: -1; clip-path: inset(0 0 0 0); animation: glitch-anim-1 2s infinite linear alternate-reverse; } .glitch-wrapper::after { color: #f0f; z-index: -2; clip-path: inset(0 0 0 0); animation: glitch-anim-2 3s infinite linear alternate-reverse; } @keyframes glitch-anim-1 { 0% { clip-path: inset(20% 0 30% 0); transform: translate(-2px, 2px); } 20% { clip-path: inset(60% 0 10% 0); transform: translate(2px, -2px); } 40% { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 2px); } 60% { clip-path: inset(80% 0 5% 0); transform: translate(2px, -2px); } 80% { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 2px); } 100% { clip-path: inset(50% 0 20% 0); transform: translate(2px, -2px); } } @keyframes glitch-anim-2 { 0% { clip-path: inset(10% 0 60% 0); transform: translate(2px, -2px); } 20% { clip-path: inset(30% 0 20% 0); transform: translate(-2px, 2px); } 40% { clip-path: inset(70% 0 10% 0); transform: translate(2px, -2px); } 60% { clip-path: inset(20% 0 50% 0); transform: translate(-2px, 2px); } 80% { clip-path: inset(50% 0 30% 0); transform: translate(2px, -2px); } 100% { clip-path: inset(0% 0 80% 0); transform: translate(-2px, 2px); } } /* Screen Shake */ .shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; } @keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } } /* Scrollbar */ ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background: #f0f0f0; border: 2px solid #000; } ::-webkit-scrollbar-thumb { background: #000; border: 2px solid #fff; } ::-webkit-scrollbar-thumb:hover { background: #333; } /* SVG Lines */ .connection-line { fill: none; stroke: #000; stroke-width: 3; pointer-events: none; } </style> </head> <body class="h-screen w-screen flex flex-col font-pixel bg-gray-90 text-black border-b-4 border-black"> <!-- TOP STATUS BAR --> <header class="bg-acid-yellow border-b-4 border-black px-4 py-2 flex items-center justify-between relative z-50"> <div class="flex items-center gap-3"> <div class="w-8 h-8 border-2 border-black bg-black flex items-center justify-center rotate-12"> <span class="text-acid-yellow text-xs font-bold">QA</span> </div> <h1 class="text-sm sm:text-lg tracking-widest uppercase">Flux_Component_Sandbox <span class="blink">[BETA]</span></h1> </div> <div class="text-xs font-terminal bg-black text-white px-2 py-1 border-2 border-black"> SYS.READY </div> </header> <!-- INFINITE MARQUEE (Overlay) --> <div class="bg-acid-pink border-b-2 border-black text-white overflow-hidden h-8 flex items-center relative z-40"> <div class="absolute inset-0 opacity-20" style="background: repeating-linear-gradient(45deg, transparent, transparent 10px, #000 10px, #000 11px);"></div> <div class="animate-marquee font-pixel text-xs"> <span class="mx-4">*** ESTABLISH CONNECTIONS *** EXPORT JSON *** AUTO-QA READY *** DO NOT TOUCH MONITOR *** </span> <span class="mx-4">*** ESTABLISH CONNECTIONS *** EXPORT JSON *** AUTO-QA READY *** DO NOT TOUCH MONITOR *** </span> </div> </div> <!-- MAIN WORKSPACE --> <div class="flex-1 flex overflow-hidden relative"> <!-- LEFT SIDEBAR: COMPONENT LIBRARY --> <aside class="w-64 bg-acid-cyan border-r-4 border-black z-20 flex flex-col shadow-brutal"> <div class="p-3 border-b-4 border-black bg-white font-bold text-xs text-center"> > COMPONENTS_ </div> <div class="flex-1 p-3 overflow-y-auto space-y-3"> <p class="text-xs font-terminal mb-2 opacity-70">DRAG TO CANVAS</p> <!-- Draggable Items --> <div class="draggable-item bg-white border-4 border-black p-2 shadow-brutal cursor-grab active:cursor-grabbing hover:bg-acid-yellow transition-colors group" data-type="input" data-label="TEXT_INPUT"> <div class="flex items-center gap-2"> <div class="w-4 h-4 border-2 border-black bg-black"></div> <span class="font-pixel text-[10px]">INPUT TEXT</span> </div> </div> <div class="draggable-item bg-white border-4 border-black p-2 shadow-brutal cursor-grab active:cursor-grabbing hover:bg-acid-pink transition-colors group" data-type="button" data-label="BTN_SUBMIT"> <div class="flex items-center gap-2"> <div class="w-4 h-4 border-2 border-black bg-white"></div> <span class="font-pixel text-[10px]">BUTTON</span> </div> </div> <div class="draggable-item bg-white border-4 border-black p-2 shadow-brutal cursor-grab active:cursor-grabbing hover:bg-acid-green transition-colors group" data-type="alert" data-label="ALERT_ERR"> <div class="flex items-center gap-2"> <div class="w-4 h-4 border-2 border-black bg-red-500"></div> <span class="font-pixel text-[10px]">ALERT</span> </div> </div> <div class="draggable-item bg-white border-4 border-black p-2 shadow-brutal cursor-grab active:cursor-grabbing hover:bg-acid-orange transition-colors group" data-type="image" data-label="IMG_BANNER"> <div class="flex items-center gap-2"> <div class="w-4 h-4 border-2 border-black bg-black"></div> <span class="font-pixel text-[10px]">IMAGE</span> </div> </div> </div> <div class="p-3 border-t-4 border-black bg-black text-white text-[10px] font-terminal text-center"> LIB_PATH: /usr/lib/uw_kit/ </div> </aside> <!-- CENTER CANVAS --> <main id="canvas-wrapper" class="flex-1 relative bg-white overflow-hidden cursor-default"> <!-- SVG Layer for Connection Lines (Behind Elements) --> <svg id="connections-layer" class="absolute inset-0 w-full h-full pointer-events-none z-0"> <!-- Paths injected via JS --> </svg> <div id="canvas" class="canvas-bg w-full h-full relative z-10 overflow-hidden"> <!-- Dropped elements appear here --> <div class="absolute top-4 left-4 text-gray-300 font-pixel text-[10px] pointer-events-none select-none"> ORIGIN (0,0)<br> COORDS: <span id="coords-display">0,0</span> </div> </div> </main> <!-- RIGHT SIDEBAR: PROPERTIES & ACTIONS --> <aside class="w-80 bg-acid-orange border-l-4 border-black z-20 flex flex-col shadow-brutal"> <!-- Header --> <div class="p-3 border-b-4 border-black bg-white font-bold text-xs text-center"> > PROPERTIES_ </div> <div class="flex-1 p-4 overflow-y-auto"> <div id="properties-panel" class="hidden"> <div class="bg-white border-4 border-black p-3 mb-4 shadow-brutal"> <label class="block font-pixel text-[10px] mb-2">COMPONENT ID</label> <div id="prop-id" class="font-terminal text-lg text-acid-green break-all">#XXXX</div> </div> <div class="bg-white border-4 border-black p-3 mb-4 shadow-brutal"> <label class="block font-pixel text-[10px] mb-2">LABEL / CONTENT</label> <input type="text" id="prop-label" class="w-full border-2 border-black p-1 font-pixel text-xs focus:outline-none focus:bg-acid-yellow uppercase"> </div> <div class="bg-white border-4 border-black p-3 mb-4 shadow-brutal"> <label class="block font-pixel text-[10px] mb-2">CONNECTION (NEXT)</label> <select id="prop-connect" class="w-full border-2 border-black p-1 font-pixel text-xs bg-white uppercase"> <option value="">-- NONE --</option> <!-- Populated dynamically --> </select> <p class="text-[10px] font-terminal mt-1 text-gray-600">Defines flow direction</p> </div> <div class="bg-white border-4 border-black p-3 mb-4 shadow-brutal"> <label class="block font-pixel text-[10px] mb-2">ACTION TYPE</label> <select id="prop-action" class="w-full border-2 border-black p-1 font-pixel text-xs bg-white uppercase"> <option value="CLICK">MOUSE CLICK</option> <option value="HOVER">HOVER EVENT</option> <option value="TIMER">AUTO DELAY</option> <option value="API">API TRIGGER</option> </select> </div> <button onclick="deleteSelected()" class="w-full bg-red-500 border-4 border-black text-white font-pixel text-[10px] py-2 shadow-brutal hover:bg-black hover:text-red-500 transition-colors active:translate-x-1 active:translate-y-1 active:shadow-none"> DELETE COMPONENT </button> </div> <div id="empty-state" class="text-center py-20 font-terminal text-2xl text-black opacity-50"> [ SELECT COMPONENT ]<br>TO EDIT </div> </div> <!-- Export Action --> <div class="p-4 border-t-4 border-black bg-white"> <button onclick="exportTestCases()" class="w-full bg-acid-green border-4 border-black text-black font-pixel text-sm py-4 shadow-brutal hover:bg-white hover:scale-[0.98] transition-transform active:translate-x-1 active:translate-y-1 active:shadow-none animate-pulse"> EXPORT \\ QA_TEST_CASE.JSON </button> </div> </aside> </div> <!-- MODAL / TOAST --> <div id="toast-container" class="fixed inset-0 pointer-events-none z-[100] flex items-center justify-center hidden"> <div class="relative bg-white border-8 border-black p-8 shadow-brutal max-w-2xl w-full m-4 overflow-hidden"> <!-- Scanline over modal --> <div class="absolute inset-0 pointer-events-none opacity-10" style="background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06)); background-size: 100% 2px, 3px 100%;"></div> <div class="flex justify-between items-start mb-4 border-b-4 border-black pb-2"> <h2 class="text-2xl font-pixel text-red-600">EXPORT COMPLETE</h2> <button onclick="closeModal()" class="font-pixel text-xl hover:bg-black hover:text-white border-2 border-black px-2">[X]</button> </div> <div class="bg-gray-90 border-4 border-black p-4 font-terminal text-lg overflow-x-auto whitespace-pre" id="json-output"> <!-- JSON goes here --> </div> <div class="mt-4 flex justify-end"> <button onclick="closeModal()" class="bg-acid-yellow border-4 border-black font-pixel px-6 py-2 shadow-brutal hover:translate-y-[-2px]">OK</button> </div> </div> </div> <!-- JAVASCRIPT LOGIC --> <script> // State Management const state = { components: [], // { id, type, label, x, y, connectToId, action } selectedId: null, idCounter: 1 }; // DOM Elements const canvas = document.getElementById('canvas'); const connectionsLayer = document.getElementById('connections-layer'); const propPanel = document.getElementById('properties-panel'); const emptyState = document.getElementById('empty-state'); const coordsDisplay = document.getElementById('coords-display'); // Properties Inputs const propId = document.getElementById('prop-id'); const propLabel = document.getElementById('prop-label'); const propConnect = document.getElementById('prop-connect'); const propAction = document.getElementById('prop-action'); // --- DRAG & DROP FROM LIBRARY --- const draggables = document.querySelectorAll('.draggable-item'); draggables.forEach(el => { el.addEventListener('dragstart', (e) => { e.dataTransfer.setData('type', el.dataset.type); e.dataTransfer.setData('label', el.dataset.label); e.dataTransfer.effectAllowed = 'copy'; }); }); canvas.addEventListener('dragover', (e) => { e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; }); canvas.addEventListener('drop', (e) => { e.preventDefault(); const type = e.dataTransfer.getData('type'); const label = e.dataTransfer.getData('label'); const rect = canvas.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; createComponent(type, label, x, y); }); // --- CREATE COMPONENT --- function createComponent(type, label, x, y) { const id = `comp-${state.idCounter++}`; const comp = { id, type, label, x, y, connectToId: '', action: 'CLICK' }; state.components.push(comp); const el = document.createElement('div'); el.id = id; el.className = `absolute bg-white border-4 border-black shadow-brutal cursor-move flex flex-col items-center justify-center transform -translate-x-1/2 -translate-y-1/2 z-20 pixel-select`; el.style.left = `${x}px`; el.style.top = `${y}px`; el.dataset.id = id; // Inner Content based on type el.innerHTML = ` <div class="absolute -top-3 -right-3 w-6 h-6 border-2 border-black bg-black text-white font-pixel text-[8px] flex items-center justify-center select-none">ID</div> <div class="text-[10px] font-pixel mb-1">${label.replace('_', ' ')}</div> <div class="w-16 h-8 bg-gray-200 border-2 border-black flex items-center justify-center font-pixel text-[8px] opacity-50"> [CONTENT] </div> `; // Events el.addEventListener('mousedown', startDrag); el.addEventListener('click', (e) => { e.stopPropagation(); selectComponent(id); }); canvas.appendChild(el); selectComponent(id); // Auto select new drawConnections(); } // --- DRAGGING LOGIC --- let dragTarget = null; let dragOffsetX = 0; let dragOffsetY = 0; function startDrag(e) { if (e.button !== 0) return; // Only left click const el = e.currentTarget; dragTarget = el; const id = el.dataset.id; const comp = state.components.find(c => c.id === id); dragOffsetX = e.clientX - comp.x; dragOffsetY = e.clientY - comp.y; // Bring to front el.style.zIndex = 100; document.addEventListener('mousemove', onDrag); document.addEventListener('mouseup', stopDrag); } function onDrag(e) { if (!dragTarget) return; const id = dragTarget.dataset.id; const comp = state.components.find(c => c.id === id); const rect = canvas.getBoundingClientRect(); // Calculate new position relative to canvas // Note: We don't shift by offset for simplified positioning, // we just track delta or recalc from mouse. // Let's do direct mapping to mouse pos. let rawX = e.clientX - rect.left; let rawY = e.clientY - rect.top; // Snap to grid? Maybe optional. Let's keep free movement but 10px steps for precision? // For now, raw movement. comp.x = rawX; comp.y = rawY; dragTarget.style.left = `${rawX}px`; dragTarget.style.top = `${rawY}px`; // Re-draw connections drawConnections(); // Update coords display coordsDisplay.textContent = `${Math.round(rawX)},${Math.round(rawY)}`; } function stopDrag() { if (dragTarget) { dragTarget.style.zIndex = 20; dragTarget = null; } document.removeEventListener('mousemove', onDrag); document.removeEventListener('mouseup', stopDrag); } // --- SELECT & PROPERTIES --- function selectComponent(id) { state.selectedId = id; const comp = state.components.find(c => c.id === id); if (!comp) return; emptyState.classList.add('hidden'); propPanel.classList.remove('hidden'); // Populate fields propId.textContent = comp.id; propLabel.value = comp.label; propAction.value = comp.action; // Populate Connect Options propConnect.innerHTML = '<option value="">-- NONE --</option>'; state.components.forEach(c => { if (c.id === id) return; const opt = document.createElement('option'); opt.value = c.id; opt.textContent = `${c.id} (${c.label})`; if (c.id === comp.connectToId) opt.selected = true; propConnect.appendChild(opt); }); // Visual feedback on canvas document.querySelectorAll('.pixel-select').forEach(el => el.classList.remove('ring-4', 'ring-blue-500')); const el = document.getElementById(id); if(el) el.classList.add('ring-4', 'ring-blue-500'); // Utlize mix-blend-mode context? No, just ring. } // Listeners for Property Changes propLabel.addEventListener('input', (e) => { const comp = state.components.find(c => c.id === state.selectedId); if (comp) { comp.label = e.target.value.toUpperCase(); // Update UI text inside element roughly const el = document.getElementById(comp.id); const textSpan = el.querySelector('div:first-child'); if(textSpan) textSpan.textContent = comp.label.replace('_', ' '); } }); propAction.addEventListener('change', (e) => { const comp = state.components.find(c => c.id === state.selectedId); if (comp) comp.action = e.target.value; }); propConnect.addEventListener('change', (e) => { const comp = state.components.find(c => c.id === state.selectedId); if (comp) { comp.connectToId = e.target.value; drawConnections(); } }); // Delete Component function deleteSelected() { if (!state.selectedId) return; const id = state.selectedId; // Remove DOM const el = document.getElementById(id); if (el) el.remove(); // Remove from state state.components = state.components.filter(c => c.id !== id); // Clear connections where this was target state.components.forEach(c => { if (c.connectToId === id) c.connectToId = ''; }); state.selectedId = null; emptyState.classList.remove('hidden'); propPanel.classList.add('hidden'); drawConnections(); } // Deselect when clicking empty canvas canvas.addEventListener('click', (e) => { if (e.target === canvas) { state.selectedId = null; document.querySelectorAll('.pixel-select').forEach(el => el.classList.remove('ring-4', 'ring-blue-500')); emptyState.classList.remove('hidden'); propPanel.classList.add('hidden'); } }); // --- DRAW CONNECTIONS (SVG) --- function drawConnections() { // Clear existing connectionsLayer.innerHTML = ''; state.components.forEach(comp => { if (comp.connectToId) { const targetComp = state.components.find(c => c.id === comp.connectToId); if (targetComp) { const startX = comp.x; const startY = comp.y + 40; // Approx height/2 offset to bottom const endX = targetComp.x; const endY = targetComp.y - 40; // Top // Cubic Bezier for "wire" look const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); // Control points for curve const cp1x = startX; const cp1y = startY + 50; const cp2x = endX; const cp2y = endY - 50; const d = `M ${startX} ${startY} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${endX} ${endY}`; path.setAttribute('d', d); path.setAttribute('class', 'connection-line'); connectionsLayer.appendChild(path); } } }); } // --- EXPORT LOGIC --- function exportTestCases() { const payload = { meta: { tool: "Flux_Sandbox_NeoBrutal", timestamp: new Date().toISOString(), version: "1.0.4" }, flow: state.components.map(comp => ({ node_id: comp.id, type: comp.type, label: comp.label, action_event: comp.action, connects_to: comp.connectToId || null, position: { x: Math.round(comp.x), y: Math.round(comp.y) } })) }; const jsonStr = JSON.stringify(payload, null, 2); document.getElementById('json-output').textContent = jsonStr; // Show Toast/Modal with Glitch Effect const container = document.getElementById('toast-container'); const content = container.querySelector('div'); // the modal box container.classList.remove('hidden'); // Add a shake to body document.body.classList.add('shake'); setTimeout(() => document.body.classList.remove('shake'), 500); // Glitch text effect on the title briefly const title = content.querySelector('h2'); title.classList.add('glitch-wrapper'); title.setAttribute('data-text', 'EXPORT COMPLETE'); } function closeModal() { document.getElementById('toast-container').classList.add('hidden'); } // Background animation effects: Random cursor trails? No, too heavy. // Add a subtle CRT flicker overlay via CSS on body? No, keep it clean. </script> </body> </html> -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.