@mochabug/adapt-web 1.0.1-rc.12 → 1.0.1-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -132,6 +132,7 @@ Set via element reference — not available as HTML attributes.
132
132
  | `styles` | `Partial<CSSStyleDeclaration>` |
133
133
  | `persistOptions` | `{ storage?: 'session' \| 'local'; ttl?: number; key?: string }` |
134
134
  | `text` | `StatusText` |
135
+ | `theme` | `AdaptTheme` |
135
136
 
136
137
  ### Events
137
138
 
@@ -228,172 +229,128 @@ el.addEventListener('adapt-cap-solve', (e) => {
228
229
 
229
230
  ## Styling
230
231
 
231
- All visuals are controlled via CSS custom properties on `.mb-adapt`. The `dark-mode` attribute on the element automatically switches to dark defaults, but you can override any variable for either mode.
232
+ Three ways to theme, from simplest to most powerful:
232
233
 
233
- ### Matching your site's toolbar
234
+ ### 1. `theme` prop (recommended)
234
235
 
235
- Map your site's existing design tokens to the panel toolbar. These six variables control almost everything you see in the tab bar:
236
+ Set the `theme` JS property for semantic theming. Derives 30+ CSS variables from a few tokens.
236
237
 
237
- ```css
238
- /* Light mode — derive from your site's surface/text colors */
239
- .mb-adapt {
240
- --mb-adapt-fork-bg: #ffffff; /* panel content background */
241
- --mb-adapt-fork-tab-bg: #f5f5f5; /* inactive tab / toolbar background */
242
- --mb-adapt-fork-tab-active-bg: #ffffff; /* active tab background */
243
- --mb-adapt-fork-tab-color: #1a1a1a; /* active tab text */
244
- --mb-adapt-fork-tab-inactive-color: #888; /* inactive tab text */
245
- --mb-adapt-fork-separator: #e0e0e0; /* borders between tabs & panels */
246
- }
247
-
248
- /* Dark mode — add `dark-mode` attribute, then override */
249
- .mb-adapt[dark-mode] {
250
- --mb-adapt-fork-bg: #1e1e1e;
251
- --mb-adapt-fork-tab-bg: #2a2a2a;
252
- --mb-adapt-fork-tab-active-bg: #1e1e1e;
253
- --mb-adapt-fork-tab-color: #e0e0e0;
254
- --mb-adapt-fork-tab-inactive-color: #777;
255
- --mb-adapt-fork-separator: #3a3a3a;
256
- }
238
+ ```javascript
239
+ const el = document.querySelector('adapt-automation');
240
+ el.theme = {
241
+ mode: 'dark',
242
+ primary: '#6366f1',
243
+ background: '#0f172a',
244
+ surface: '#1e293b',
245
+ text: '#f1f5f9',
246
+ border: '#334155',
247
+ font: '"Inter", sans-serif',
248
+ };
257
249
  ```
258
250
 
259
- **Typical mapping from your site's design system:**
251
+ **`AdaptTheme` interface:**
260
252
 
261
- | Your site has | Maps to |
262
- |---|---|
263
- | Surface / card background | `--mb-adapt-fork-bg` |
264
- | Secondary / muted background | `--mb-adapt-fork-tab-bg` |
265
- | Primary text color | `--mb-adapt-fork-tab-color` |
266
- | Muted / secondary text | `--mb-adapt-fork-tab-inactive-color` |
267
- | Border / divider color | `--mb-adapt-fork-separator` |
268
- | Accent color | `--mb-adapt-separator-active` (resize handle highlight) |
269
- | Interactive hover tint | `--mb-adapt-button-hover-bg` |
253
+ | Token | Effect |
254
+ |-------|--------|
255
+ | `mode` | `'light'` or `'dark'` — toggles dark mode class |
256
+ | `primary` | Accent color derives separator, drop target, spinner colors |
257
+ | `background` | Root bg, active tab bg, status card bg |
258
+ | `surface` | Panel content bg, tab bar bg |
259
+ | `text` | Active tab text, status text, cap widget text |
260
+ | `textSecondary` | Inactive tab text |
261
+ | `border` | Tab separators, status card border, cap border |
262
+ | `font` | All panel UI text + cap widget |
263
+ | `vars` | `Record<string, string>` — direct variable overrides (key = name without `--mb-adapt-` prefix) |
264
+
265
+ The `vars` escape hatch lets you override any variable:
266
+
267
+ ```javascript
268
+ el.theme = {
269
+ primary: '#6366f1',
270
+ vars: {
271
+ 'floating-shadow': 'none',
272
+ 'floating-border': '2px solid #6366f1',
273
+ 'cap-border-radius': '0px',
274
+ },
275
+ };
276
+ ```
270
277
 
271
- ### Custom theme (light & dark)
278
+ ### 2. CSS custom properties
272
279
 
273
- A more complete example mapping a full brand palette primary, secondary, and accent colors to Adapt's CSS variables for both light and dark modes:
280
+ Set `--mb-adapt-*` variables on `.mb-adapt` or any ancestor. No Shadow DOMstandard CSS inheritance works.
274
281
 
275
282
  ```css
276
- /*
277
- * Example: brand theme using primary / secondary / accent colors.
278
- * Maps your design-system tokens to Adapt's CSS variables for both modes.
279
- */
280
-
281
- /* ── Light mode ────────────────────────────────── */
282
283
  .mb-adapt {
283
- /* Brand palette */
284
- --mb-adapt-fork-bg: #ffffff; /* surface */
285
- --mb-adapt-fork-tab-bg: #f0f4ff; /* primary-50 */
286
- --mb-adapt-fork-tab-active-bg: #ffffff; /* surface */
287
- --mb-adapt-fork-tab-color: #1e293b; /* on-surface */
288
- --mb-adapt-fork-tab-inactive-color: #64748b; /* on-surface-muted */
289
- --mb-adapt-fork-separator: #cbd5e1; /* outline */
290
-
291
- /* Accent — resize handle highlight */
292
- --mb-adapt-separator-active: rgba(79, 70, 229, 0.5); /* primary */
293
-
294
- /* Cap widget */
295
- --mb-adapt-cap-background: #ffffff;
296
- --mb-adapt-cap-border-color: #e2e8f0;
297
- --mb-adapt-cap-color: #1e293b;
298
- --mb-adapt-cap-spinner-color: #4f46e5; /* primary */
299
-
300
- /* Status cards */
301
- --mb-adapt-status-card-bg: #ffffff;
302
- --mb-adapt-status-card-border: #e2e8f0;
303
- --mb-adapt-status-text: #334155;
284
+ --mb-adapt-fork-bg: #ffffff;
285
+ --mb-adapt-fork-tab-bg: #f5f5f5;
286
+ --mb-adapt-fork-tab-color: #1a1a1a;
287
+ --mb-adapt-fork-separator: #e0e0e0;
304
288
  }
305
289
 
306
- /* ── Dark mode ─────────────────────────────────── */
307
- .mb-adapt[dark-mode] {
308
- --mb-adapt-fork-bg: #0f172a; /* surface-dark */
309
- --mb-adapt-fork-tab-bg: #1e293b; /* primary-900 */
310
- --mb-adapt-fork-tab-active-bg: #0f172a; /* surface-dark */
311
- --mb-adapt-fork-tab-color: #f1f5f9; /* on-surface-dark */
312
- --mb-adapt-fork-tab-inactive-color: #94a3b8; /* muted-dark */
313
- --mb-adapt-fork-separator: #334155; /* outline-dark */
314
-
315
- --mb-adapt-separator-active: rgba(129, 140, 248, 0.6); /* primary-light */
316
-
317
- --mb-adapt-cap-background: #1e293b;
318
- --mb-adapt-cap-border-color: #334155;
319
- --mb-adapt-cap-color: #f1f5f9;
320
- --mb-adapt-cap-spinner-color: #818cf8; /* primary-light */
321
-
322
- --mb-adapt-status-card-bg: #1e293b;
323
- --mb-adapt-status-card-border: #334155;
324
- --mb-adapt-status-text: #e2e8f0;
290
+ .mb-adapt--dark {
291
+ --mb-adapt-fork-bg: #1e1e1e;
292
+ --mb-adapt-fork-tab-bg: #2a2a2a;
293
+ --mb-adapt-fork-tab-color: #e0e0e0;
294
+ --mb-adapt-fork-separator: #3a3a3a;
325
295
  }
326
296
  ```
327
297
 
328
- ### Font
298
+ ### 3. Direct CSS on internal classes
329
299
 
330
- Set `--mb-adapt-font` to match your site's typeface. This applies to tab labels, status messages, drag ghosts, and all panel UI text.
300
+ No Shadow DOM all internal elements use plain CSS classes. Target them directly for effects that CSS variables can't express: animations, pseudo-elements, transitions, media queries.
331
301
 
332
- ```css
333
- .mb-adapt {
334
- --mb-adapt-font: "Inter", sans-serif;
335
- }
336
- ```
337
-
338
- ### Elevation and borders
339
-
340
- Floating panels, status cards, and drag ghosts each have independent shadow, border, and radius variables. Use these to match your site's elevation system.
302
+ **Animated gradient toolbar (liquid glass):**
341
303
 
342
304
  ```css
343
- /* Subtle, modern elevation */
344
- .mb-adapt {
345
- --mb-adapt-floating-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
346
- --mb-adapt-floating-border: 1px solid rgba(0, 0, 0, 0.06);
347
- --mb-adapt-floating-radius: 12px;
348
- --mb-adapt-floating-backdrop: none;
349
-
350
- --mb-adapt-status-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
351
- --mb-adapt-drag-ghost-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
352
- --mb-adapt-border-radius: 8px; /* iframe border radius */
305
+ @keyframes toolbar-glow {
306
+ 0%, 100% { background-position: 0% 50%; }
307
+ 50% { background-position: 100% 50%; }
353
308
  }
354
309
 
355
- /* Dark mode — increase shadow density, add subtle light border */
356
- .mb-adapt[dark-mode] {
357
- --mb-adapt-floating-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
358
- --mb-adapt-floating-border: 1px solid rgba(255, 255, 255, 0.08);
359
- --mb-adapt-status-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
360
- --mb-adapt-drag-ghost-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
310
+ /* Light mode — warm aurora */
311
+ .mb-adapt .mb-group-header {
312
+ background: linear-gradient(
313
+ 135deg,
314
+ rgba(99, 102, 241, 0.08) 0%,
315
+ rgba(168, 85, 247, 0.08) 25%,
316
+ rgba(236, 72, 153, 0.06) 50%,
317
+ rgba(99, 102, 241, 0.08) 100%
318
+ ) !important;
319
+ background-size: 300% 300%;
320
+ animation: toolbar-glow 8s ease infinite;
361
321
  }
362
- ```
363
322
 
364
- **Frosted glass effect**set a translucent background and enable `backdrop-filter`:
365
-
366
- ```css
367
- .mb-adapt {
368
- --mb-adapt-fork-bg: rgba(255, 255, 255, 0.7);
369
- --mb-adapt-fork-tab-bg: rgba(245, 245, 245, 0.5);
370
- --mb-adapt-floating-backdrop: blur(16px) saturate(180%);
371
- --mb-adapt-floating-border: 1px solid rgba(255, 255, 255, 0.2);
372
- --mb-adapt-floating-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
323
+ /* Dark modedeep neon */
324
+ .mb-adapt--dark .mb-group-header {
325
+ background: linear-gradient(
326
+ 135deg,
327
+ rgba(99, 102, 241, 0.15) 0%,
328
+ rgba(168, 85, 247, 0.12) 25%,
329
+ rgba(236, 72, 153, 0.10) 50%,
330
+ rgba(99, 102, 241, 0.15) 100%
331
+ ) !important;
332
+ background-size: 300% 300%;
333
+ animation: toolbar-glow 8s ease infinite;
373
334
  }
374
335
  ```
375
336
 
376
- **Flat / borderless** remove all elevation:
377
-
378
- ```css
379
- .mb-adapt {
380
- --mb-adapt-floating-shadow: none;
381
- --mb-adapt-floating-border: 1px solid var(--mb-adapt-fork-separator);
382
- --mb-adapt-floating-radius: 4px;
383
- --mb-adapt-status-card-shadow: none;
384
- --mb-adapt-drag-ghost-shadow: none;
385
- }
386
- ```
337
+ **Key classes you can target:**
387
338
 
388
- **Typical mapping from your site's design system:**
339
+ | Class | Element |
340
+ |-------|---------|
341
+ | `.mb-group-header` | Tab toolbar |
342
+ | `.mb-tab` | Individual tab |
343
+ | `.mb-tab[data-active="true"]` | Active tab |
344
+ | `.mb-group-content` | Panel content area |
345
+ | `.mb-floating-overlay` | Floating panel container |
346
+ | `.mb-layout-separator` | Resize handle between panels |
347
+ | `.mb-drag-ghost` | Tab drag preview |
348
+ | `.mb-adapt__status-card` | Error/stopped status card |
349
+ | `.mb-adapt__status-icon` | Status card icon |
350
+ | `.mb-adapt-minimized-tab` | Minimized panel tab |
351
+ | `.mb-drop-overlay` | Drop target highlight |
389
352
 
390
- | Your site has | Maps to |
391
- |---|---|
392
- | Card shadow / `--shadow-lg` | `--mb-adapt-floating-shadow` |
393
- | Card border / `--border-subtle` | `--mb-adapt-floating-border` |
394
- | Card radius / `--radius-lg` | `--mb-adapt-floating-radius` |
395
- | Tooltip/popover shadow | `--mb-adapt-status-card-shadow`, `--mb-adapt-drag-ghost-shadow` |
396
- | Glass/blur effect | `--mb-adapt-floating-backdrop` |
353
+ All three approaches compose use `theme` for colors, CSS variables for fine-tuning, and direct class targeting for animations.
397
354
 
398
355
  <details>
399
356
  <summary>Full CSS variable reference</summary>
@@ -418,6 +375,16 @@ Floating panels, status cards, and drag ghosts each have independent shadow, bor
418
375
  | `--mb-adapt-fork-tab-color` | `rgb(51,51,51)` | `#ffffff` | Active tab text |
419
376
  | `--mb-adapt-fork-tab-inactive-color` | `rgba(51,51,51,0.7)` | `#969696` | Inactive tab text |
420
377
  | `--mb-adapt-fork-separator` | `rgba(128,128,128,0.35)` | `rgb(68,68,68)` | Tab/panel borders |
378
+ | `--mb-adapt-tab-radius` | `0` | | Tab border-radius (use `999px` for pill shape) |
379
+ | `--mb-adapt-tab-shadow` | `none` | | Tab box-shadow |
380
+ | `--mb-adapt-tab-active-shadow` | `none` | | Active tab box-shadow |
381
+ | `--mb-adapt-tab-gap` | `0px` | | Tab margin (spacing between tabs) |
382
+ | `--mb-adapt-tab-padding` | `0 14px` | | Tab padding |
383
+ | `--mb-adapt-tab-font-size` | `13px` | | Tab label font size |
384
+ | `--mb-adapt-toolbar-height` | `40px` | | Toolbar / tab bar height |
385
+ | `--mb-adapt-toolbar-padding` | `0` | | Toolbar inner padding (standard CSS shorthand) |
386
+ | `--mb-adapt-tab-min-width` | `100px` | | Tab minimum width |
387
+ | `--mb-adapt-tab-spacing` | `6px` | | Gap between tab label and action buttons |
421
388
 
422
389
  ### Floating panels (elevation)
423
390