This document describes how the Bespoke framework is used in this application: layout, design system integration, and conventions. It is the canonical contract for this repo.
This application includes:
- CodeSignal Design System foundations: colors, spacing, typography, button
- CodeSignal Design System components (optional): boxes, dropdown, input, tags, modal
- bespoke.css – Bespoke layout, utilities, and temporary components
- components/modal/modal.css and modal.js (design system; used for help modal)
- app.js (WebSocket, help modal bootstrap, logger)
- server.js (static server, WebSocket, POST /message, POST /log)
- Use the
.bespokeclass on the body element for scoping. - Load design system CSS, then bespoke.css, then app-specific CSS.
- Load app.js and app-specific scripts as modules.
- ALWAYS use the
.bespokeclass on the body element for scoping. - USE design system components directly with proper classes:
- Buttons:
button button-primary,button button-secondary,button button-danger,button button-text,button button-tertiary - Boxes/Cards:
box cardfor card containers - Inputs: Add
inputclass to input elements:<input type="text" class="input" />
- Buttons:
- USE design system CSS custom properties for styling:
- Colors:
--Colors-*(e.g.,--Colors-Primary-Default,--Colors-Text-Body-Default) - Spacing:
--UI-Spacing-*(e.g.,--UI-Spacing-spacing-ml,--UI-Spacing-spacing-xl) - Typography:
--Fonts-*,--Fonts-Headlines-* - Borders:
--UI-Radius-*(e.g.,--UI-Radius-radius-s,--UI-Radius-radius-m) - Font families:
--body-family,--heading-family
- Colors:
- OVERRIDE design system variables in app-specific CSS, not in bespoke.css.
- FOLLOW design system naming conventions for consistency.
- Load help content (e.g. from
help-content.html) and use the design system Modal:Modal.createHelpModal({ title: 'Help', content, triggerSelector: '#btn-help' }). - Include
modal.cssand importModalfromdesign-system/components/modal/modal.js.
- Wrap async operations in try-catch blocks.
- Provide meaningful error messages; log errors to console.
- Implement retry logic for network operations where appropriate.
- Handle localStorage quota exceeded when persisting data.
- Validate data before saving.
- CSS: kebab-case (e.g. geometry-plane.css)
- JavaScript/TypeScript: kebab-case (e.g. geometry-plane.ts)
- Data files: kebab-case (e.g. solution.json)
- Image files: kebab-case (e.g. overview.png)
This section explains how the CodeSignal Design System is used with Bespoke in this application.
Bespoke uses the CodeSignal Design System for components and tokens, with layout and utilities in bespoke.css. All styles are scoped under .bespoke to prevent interference with parent site styles.
<link rel="stylesheet" href="./bespoke.css" /><body class="bespoke">
<!-- Application content -->
</body><div class="bespoke">
<header class="header">
<h1>App Title</h1>
<button class="button button-text">Help</button>
</header>
<main class="main-layout">
<aside class="sidebar">
<section class="box card">
<h2>Settings</h2>
<form>
<label>Name
<input type="text" class="input" placeholder="Enter name" />
</label>
<button type="submit" class="button button-primary">Save</button>
</form>
</section>
</aside>
<div class="content-area">
<!-- Main content -->
</div>
</main>
</div><header class="header">
<h1>App Title</h1>
<button class="button button-text">Help</button>
</header><main class="main-layout">
<aside class="sidebar">
<!-- Sidebar content -->
</aside>
<div class="content-area">
<!-- Main content area -->
</div>
</main><section class="box card">
<h2>Card Title</h2>
<p>Card content goes here</p>
</section><label>Field Name
<input type="text" class="input" />
</label><button class="button button-text">Text</button>
<button class="button button-primary">Primary</button>
<button class="button button-danger">Danger</button>
<button class="button button-tertiary">Secondary</button>Use the design system Modal for help content:
import Modal from './design-system/components/modal/modal.js';
const helpModal = Modal.createHelpModal({
title: 'Help',
content: helpContent,
triggerSelector: '#btn-help'
});See client/design-system/components/modal/README.md for full API.
Override design system CSS variables in app-specific CSS (--Colors-*, --UI-Spacing-*, --Fonts-*, --UI-Radius-*).
The framework respects the user's system preference for light/dark theme. No extra configuration is required.
- Always wrap in
.bespoketo avoid style conflicts with the host page. - Use design system components directly with the documented class combinations.
- Use semantic HTML for accessibility.
- Override in app-specific CSS using design system variables; do not edit bespoke.css for app-specific overrides.
- Test in both themes (light and dark).