How gustavwilliam/arrow-canvas works
Project type and purpose
• This is a single-page, front-end web application built with Vue 3 and Vite.
File structure
• Top-level files:
• index.html, main.js, App.vue → entrypoint of the SPA
• package.json, vite.config.js, postcss.config.js, tailwind.config.js → build/config files
• src/
• components/ → UI building blocks (CanvasSquare, TheCanvas, ToolPicker, Dropdown, Menu, TheTilesetDisplay)
• stores/ → Pinia state management (selection.js, state.js)
• public/tilesets/… → static SVG assets used at runtime
• readme-images/ → documentation images
Extract insights from the README
• Uses Vue’s reactivity + Pinia for state (selected tool, current canvas selection).
• Built & served by Vite.
Main components and interactions (to include
a. User (Browser)
→ interacts with UI components (ToolPicker, Dropdowns, Canvas squares).
b. Vue 3 Application Core
• App.vue / main.js: bootstrap Vue + mount root component.
• Component Tree:
– ToolPicker & Toolbar components
– TheCanvas & CanvasSquare components
– TheTilesetDisplay
– Menu/Dropdown for settings (light/dark)
c. State Layer (Pinia stores)
• selection.js: tracks which canvas square(s) are selected.
• state.js: current tool, mode (light/dark), tileset choice.
d. Utility Layer
e. Static Assets
• public/tilesets: SVG files named by direction pattern.
f. Build/Serve Pipeline
• Vite Dev Server or built static files served by any HTTP server.
Interactions:
1. Browser loads index.html → runs main.js → Vue app initialized.
2. User selects a tool via ToolPicker → Pinia store update.
3. User clicks on CanvasSquare → Pinia store updates selection.
5. TheTilesetDisplay picks the matching SVG from public/tilesets and renders.
Architectural patterns & design principles
• Component-based UI (Vue Single File Components).
• Unidirectional data flow: store ← UI events; UI ← store.
• Separation of concerns: UI (components), state (stores), logic (utils), assets (public).
• Build tool/plugin system (Vite + PostCSS + TailwindCSS).
Detailed component breakdown (optional sub-components)
• ToolPicker Group → buttons → emits “selectTool”
• Dropdown & Menu → configure mode/tileset
• CanvasSquare → onClick → updates selection store
• TheCanvas → iterates squares, passes geometry data to TheTilesetDisplay
• TheTilesetDisplay → constructs filename using utils, loads SVG