A little workshop for crafting portable pricing, feedback, and status widgets.
Small by design. Yours by nature. Pick a piece, make it yours, and give it a home anywhere on the web.
- Three Working Widgets: A pricing card with monthly/yearly billing, a five-star feedback form, and a service-status snapshot.
- Live Editing: Change text, prices, features, service labels, colors, and corner radius on the workbench.
- Canvas & Website Views: Inspect the actual component on a dotted canvas or inside a contrasting sample website. Preview height stays reserved across modes.
- Portable Web Components:
defineCustomElementand.ce.vuecreatewf-pricing,wf-rating, andwf-statuswith styles inside Shadow DOM. - Reactive Styling: SFC CSS
v-bind()updates widget appearance without leaking styles to the host. - Real Events: Billing, plan selection, ratings, feedback submission, and refresh requests dispatch
widget-actionevents. - Local Drafts: Debounced browser storage, validated restoration, and a two-step reset for the selected widget.
- Import & Export: Import a complete workspace; download JSON, standalone HTML, or a self-contained JS bundle; copy embed snippets and event handlers.
- Foundry Identity: Custom WF mark, favicon, social artwork, and deterministic configuration stamps in exported artifacts.
- Plain HTML Field Test: A separate host applies hostile global styles to demonstrate widget isolation.
demo-host.html # Plain HTML host; no workshop app
public/
|-- favicon.svg
|-- og.svg
|-- sample-widgets.json
`-- widget-foundry.js # Generated standalone bundle; Git-ignored
src/
|-- App.vue
|-- demo-host.ts
|-- main.ts
|-- style.css
|-- components/
| |-- AppIcon.vue
| |-- EditorField.vue
| |-- ExportDialog.vue
| |-- FoundryMark.vue
| |-- WidgetEditor.vue
| `-- WidgetPreview.vue
|-- domain/
| `-- widget.ts # Contracts, validation, exports, markers
|-- services/
| `-- workspace-store.ts
`-- widgets/
|-- PricingWidget.ce.vue
|-- RatingWidget.ce.vue
|-- StatusWidget.ce.vue
`-- register.ts
tests/
|-- widget.test.ts
`-- e2e/workshop.spec.ts
vite.config.ts # Workshop and plain host
vite.widgets.config.ts # Self-contained ES module
Vue 3, TypeScript 6, Vite 8, and Tailwind CSS 4. Locally bundled DM Sans and Bricolage Grotesque fonts. Prettier for formatting, Node's test runner for configuration/export boundaries, and Playwright for browser behavior.
The workshop uses Tailwind. Exported elements carry small, independent stylesheets because global Tailwind rules cannot style a shadow tree. Reactive styling uses Vue's native SFC CSS bindings. The editor uses defineModel; the export dialog uses Teleport and native modal focus handling.
public/sample-widgets.json contains all three fictional widget configurations. Import it to restore the sample collection. The plain HTML host loads the same fixture. Defaults also live in src/domain/widget.ts, allowing the workshop to start without an API request.
Requires Node.js 24 or later.
npm install
npm run devOpen the Local URL printed by Vite, normally http://localhost:5173. The predev hook automatically builds the standalone bundle.
npm run build
npm run previewThe production build checks Vue/TypeScript, generates the portable bundle, and builds both HTML entry points into dist/.
During development, the workshop updates live. After editing a .ce.vue file, run npm run build:widgets to refresh the generated bundle used by the plain host and HTML exports.
- Download the JS bundle or copy
dist/widget-foundry.jsto your web hosting. - Set its hosting directory URL in the export dialog.
- Copy the embed snippet or download the complete HTML example.
- Listen for events to connect your application's behavior.
document.querySelector('wf-pricing').addEventListener('widget-action', (event) => {
const [action] = event.detail
console.log(action)
})| Widget | Actions | Additional data |
|---|---|---|
| Pricing | billing-changed, choose-plan |
interval; selection adds plan and price |
| Feedback | rating-selected, feedback-submitted |
score; submission adds comment |
| Status | refresh-requested |
configured state |
Every action includes kind and id. Vue custom-element events expose emitted arguments as an array in event.detail. The bundled Vue runtime and inline styles require no Vue installation on the destination. Registration is guarded against loading the collection twice.
The stamp, such as WF-P-ABC123, is derived from the canonical validated configuration. It appears in the workbench, embed comment, data-foundry-id, and exported workspace provenance alongside the project name and CodeSculptor attribution.
This checksum helps recognize and compare exported configurations. It is not a cryptographic signature or uniqueness guarantee. No tracking request accompanies it.
- Pricing buttons emit selection intent; connect a billing provider to create purchases.
- Ratings and comments stay in the current widget session until the host handles submission.
- Service status and 30-day bars are illustrative samples. Refresh emits a request for the host to handle.
- Shadow DOM isolates styling; API authentication belongs to the host/backend.
- Text uses Vue interpolation. Export escapes attributes, restricts theme colors to hex values, and requires HTTP/HTTPS bundle origins.
- Invalid imports preserve the existing draft. Corrupted or inaccessible storage restores sample data.
- Local export URLs require a reachable development server. Use deployed hosting for shared embeds.
- Social artwork is SVG; render it to PNG for sharing platforms that require raster images.
npm run format:check
npm test
npm run build
npx playwright install chromium
npm run test:e2eBrowser checks cover editing/persistence, widget events, export/import, modal focus restoration, mobile overflow, and the standalone bundle under conflicting host styles. Downloaded HTML is also loaded independently to verify escaped configuration text and its origin marker; export controls are exercised on a 320 px screen.
/— workshop/demo-host.html— independent HTML integration test/widget-foundry.js— portable ES module/sample-widgets.json— importable fixture
vercel.json installs locked dependencies with npm ci, runs npm run build, and publishes dist. For vercel dev, the development command passes Vercel's $PORT to Vite with strict port binding. URL behavior is also declared explicitly.
/serves the workshop;/index.htmlredirects to its canonical root URL./demo-hostaliases the independent/demo-host.htmlpage.- HTML, fixtures, and the unversioned
widget-foundry.jsrequire cache revalidation. Content-hashed files in/assets/receive a one-year immutable cache policy. - The portable JS bundle exposes CORS and an explicit JavaScript content type so other domains can load it as an ES module.
- Responses include MIME sniffing protection and a referrer policy.
The routing rules target the two pages explicitly, leaving JS, CSS, fonts, and fixtures accessible at their original paths. The Vercel response-header rules apply on deployment; Vite's local preview does not emulate them. Other static hosts can serve dist with equivalent routing and headers.
MIT License. See LICENSE.