@harmonia-core/ui 1.2.8 → 1.2.9

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.
Files changed (2) hide show
  1. package/README.md +121 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # @harmonia-core/ui
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@harmonia-core/ui.svg)](https://www.npmjs.com/package/@harmonia-core/ui)
4
+ [![License](https://img.shields.io/npm/l/@harmonia-core/ui.svg)](LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue.svg)](https://www.typescriptlang.org/)
6
+ [![React](https://img.shields.io/badge/React-18%2B-blue.svg)](https://react.dev)
7
+ [![npm downloads](https://img.shields.io/npm/dm/@harmonia-core/ui.svg)](https://www.npmjs.com/package/@harmonia-core/ui)
8
+
3
9
  A capacity-adaptive UI framework that treats human cognitive, temporal, and emotional state as first-class inputs.
4
10
 
5
11
  Instead of inferring or profiling users, Harmonia derives discrete interface mode tokens from explicit state — density, motion, contrast, and focus — and lets components consume them in JavaScript.
6
12
 
7
- [Live demo](https://harmonia-ui.vercel.app) | [Convention example](https://harmonia-ui.vercel.app/convention)
13
+ [Live demo](https://harmonia-ui.vercel.app) |
14
+ [Convention example](https://harmonia-ui.vercel.app/convention) •
15
+ [GitHub](https://github.com/vanessa/harmonia-ui) •
16
+ [Issues](https://github.com/vanessa/harmonia-ui/issues) •
17
+ [Discussions](https://github.com/vanessa/harmonia-ui/discussions)
8
18
 
9
19
  ---
10
20
 
@@ -121,6 +131,40 @@ See the [live demo](https://harmonia-ui.vercel.app) for all three components in
121
131
 
122
132
  ---
123
133
 
134
+ ## When NOT to Use Harmonia
135
+
136
+ Harmonia is optimized for applications where **user capacity varies significantly** throughout a session. It may not be the right fit for:
137
+
138
+ ### ❌ Poor Fit
139
+
140
+ - **Gaming:** Requires continuous high-frequency state updates, not discrete capacity changes
141
+ - **High-frequency trading/financial UIs:** State changes every millisecond; discrete capacity doesn't apply
142
+ - **Real-time collaborative editing:** Mode changes every keystroke would distract multi-user environments
143
+ - **Custom capacity inference:** You need proprietary ML/profiling logic (Harmonia uses explicit state only)
144
+ - **Static apps:** Content and layout don't change much regardless of user state
145
+
146
+ ### ✅ Good Fit
147
+
148
+ - **Productivity apps:** Writing, coding, design tools (capacity varies as user gets tired)
149
+ - **Learning platforms:** Student capacity decreases as session length increases
150
+ - **Wellness/health apps:** Mood and energy state directly affect what users need
151
+ - **Admin dashboards:** Operators have different needs depending on alertness, time available
152
+ - **Accessibility-first apps:** Adaptive UI as accessibility feature for cognitive conditions
153
+ - **Research/survey tools:** Adjust complexity based on respondent capacity
154
+ - **Documentation sites:** Readers can adapt complexity per their current capacity
155
+
156
+ ### ⚠️ Trade-offs
157
+
158
+ - **Requires React 18+:** Cannot use with older React versions
159
+ - **Takes CSS var approach:** Not compatible with Tailwind CSS preset; uses runtime CSS manipulation
160
+ - **Signal detection is 2s polling:** Not suitable for real-time updates (by design — prevents thrashing)
161
+ - **Manual state input:** Users must interact with controls (no surveillance/profiling)
162
+ - **Adds ~1 MB (patterns):** PatternStore uses localStorage; acceptable for most apps
163
+
164
+ **Still not sure?** [Open a discussion](https://github.com/vanessa/harmonia-ui/discussions) — we're happy to advise.
165
+
166
+ ---
167
+
124
168
  ## Usage
125
169
 
126
170
  ### Consuming mode tokens in a component
@@ -263,25 +307,86 @@ Four human-readable labels derived from raw inputs, first match wins:
263
307
 
264
308
  ---
265
309
 
266
- ## API reference
310
+ ## What's New (v1.2.7)
311
+
312
+ - ✨ **Arousal dimension** — Pace token (`calm|normal|activated`) for motion speed
313
+ - ✨ **Haptic feedback** — `triggerHaptic()` using Vibration API
314
+ - ✨ **Sonic feedback** — `playSonicFeedback()` using Web Audio API
315
+ - 🔨 **Type consolidation** — Improved IDE autocomplete and maintainability
316
+ - 🐛 **Better error handling** — More informative error messages
317
+ - 📦 **Zero dependencies** — Still minimal bundle size (~15 KB gzipped)
318
+
319
+ **Upcoming in v1.3:**
320
+ - sessionDuration pattern matching (currently time-of-day / day-of-week only)
321
+ - Additional Renge token profiles
322
+ - Performance optimizations
323
+
324
+ [See all versions →](https://www.npmjs.com/package/@harmonia-core/ui?activeTab=versions)
325
+
326
+ ---
327
+
328
+ ## API Reference
329
+
330
+ Complete documentation of all hooks, types, and utilities.
267
331
 
268
332
  ### Hooks
269
333
 
270
- | Hook | Returns | Description |
271
- |------|---------|-------------|
272
- | `useDerivedMode()` | `{ field: CapacityField, mode: InterfaceMode }` | Primary hook — builds the field and runs deriveMode in one call |
273
- | `useEffectiveMotion()` | `{ mode: MotionMode, tokens: MotionTokens }` | Motion with prefers-reduced-motion override |
274
- | `useCapacityContext()` | `AmbientContext` | Raw context — prefer useDerivedMode for most uses |
275
- | `useFieldControls()` | `{ setCapacity, setEmotionalState, setAutoMode }` | Imperative setters for manual control |
276
- | `usePredictedCapacity()` | `CapacityField \| null` | Prediction based on stored patterns (≥12 samples required) |
277
- | `useEnergyField()` | `FieldValue<number>` | Live energy field with trend/velocity |
278
- | `useAttentionField()` | `FieldValue<number>` | Live attention field |
279
- | `useEmotionalValenceField()` | `FieldValue<number>` | Live valence field |
280
- | `usePrefersReducedMotion()` | `boolean` | System prefers-reduced-motion query |
334
+ **Core:**
335
+ - `useDerivedMode()` — Get current mode + field values + label
336
+ - `useCapacityContext()` Access raw `AmbientContext` (signals, fields, sliders)
337
+
338
+ **Field Hooks:**
339
+ - `useEnergyField()` Energy field value + trend
340
+ - `useAttentionField()` Attention field value + trend
341
+ - `useEmotionalValenceField()` Emotional valence field value + trend
342
+ - `useFieldControls()` Get/set slider values (manual mode)
343
+
344
+ **Motion & Feedback:**
345
+ - `useEffectiveMotion()` — Current motion mode with `prefers-reduced-motion` override
346
+ - `usePrefersReducedMotion()` — Check if user prefers reduced motion (OS setting)
347
+ - `useFeedback()` — Access haptic (`triggerHaptic`), sonic (`playSonicFeedback`), visual feedback utilities
348
+
349
+ **Advanced:**
350
+ - `usePredictedCapacity()` — Get capacity predicted from past patterns (5s refresh)
351
+
352
+ ### Utilities
353
+
354
+ **Mode & Tokens:**
355
+ - `deriveMode(field: CapacityField): InterfaceMode` — Derive tokens from field values
356
+ - `deriveModeLabel(field: CapacityField): string` — Get mode label ("Minimal" | "Calm" | "Focused" | "Exploratory")
357
+ - `getModeBadgeColor(mode: string): string` — Theme color for mode label
358
+
359
+ **Animation Classes:**
360
+ - `entranceClass(mode: InterfaceMode): string` — CSS class for entrance animation
361
+ - `hoverClass(mode: InterfaceMode): string` — CSS class for hover animation
362
+ - `ambientClass(mode: InterfaceMode): string` — CSS class for ambient motion
363
+ - `listItemClass(index: number, mode: InterfaceMode): string` — Staggered animation for list items
364
+ - `focusBeaconClass(mode: InterfaceMode): string` — Beacon glow for focused elements
365
+ - `focusTextClass(mode: InterfaceMode): string` — Text focus effect
366
+
367
+ **Utilities:**
368
+ - `detectConflicts(field: CapacityField): string[]` — Check for contradictory input states
369
+
370
+ ### Types
371
+
372
+ **Main:**
373
+ - `CapacityField` — Derived field values: `{ cognitive, temporal, emotional, valence, energy }`
374
+ - `InterfaceMode` — Mode tokens: `{ density, motion, contrast, focus, guidance, choiceLoad, pace }`
375
+ - `AmbientContext` — Full ambient state with signals, fields, sliders
376
+
377
+ **Constants:**
378
+ - `PHI = 1.618...` — Golden ratio
379
+ - `FIBONACCI = [1, 1, 2, 3, 5, 8, 13, ...]` — Fibonacci sequence
380
+ - `MOTION_TOKENS = ['off', 'soothing', 'subtle', 'expressive']`
381
+ - `DENSITY_TOKENS = ['low', 'medium', 'high']`
382
+
383
+ For complete type definitions, see: [lib/capacity/types.ts](./lib/capacity/types.ts)
384
+
385
+ For live API examples, run: `pnpm run dev` and visit http://localhost:3000 (use `AmbientFieldMonitor` to inspect values)
281
386
 
282
- ### `rengeVars` (from `@renge-ui/tokens`)
387
+ ### Design tokens (rengeVars)
283
388
 
284
- Typed CSS variable references use instead of raw `"var(--renge-*)"` strings for IDE autocomplete and guaranteed correctness:
389
+ Use `rengeVars` from `@renge-ui/tokens` for typed CSS variable references with IDE autocomplete:
285
390
 
286
391
  ```ts
287
392
  import { rengeVars } from "@renge-ui/tokens"
@@ -293,22 +398,7 @@ style={{ color: rengeVars.color.accent }} // "var(--renge-color-accen
293
398
  style={{ borderRadius: rengeVars.radius[2] }} // "var(--renge-radius-2)"
294
399
  ```
295
400
 
296
- Groups: `color`, `space`, `fontSize`, `lineHeight`, `duration`, `easing`, `radius`.
297
-
298
- ### Functions
299
-
300
- | Function | Signature | Description |
301
- |----------|-----------|-------------|
302
- | `deriveMode` | `(field: CapacityField) => InterfaceMode` | Pure — derive mode tokens from a field snapshot |
303
- | `deriveModeLabel` | `(field: CapacityField) => InterfaceModeLabel` | Pure — derive the human-readable mode label |
304
- | `entranceClass` | `(motion: MotionMode) => string` | CSS class for entrance animations |
305
- | `hoverClass` | `(motion: MotionMode) => string` | CSS class for hover interactions |
306
- | `ambientClass` | `(motion: MotionMode) => string` | CSS class for ambient/idle animations |
307
- | `focusBeaconClass` | `(focus: FocusMode) => string` | CSS class for focus beacon indicator |
308
- | `getSpacing` | `(step: number) => number` | Fibonacci spacing scale (step × 6px) |
309
- | `getFontSize` | `(role: TypographyRole) => string` | φ-derived font sizes |
310
- | `triggerHaptic` | `(pattern: HapticPatternName) => void` | Web Vibration API — opt-in haptic feedback |
311
- | `playPacedSonic` | `(pace: ArousalMode) => void` | Web Audio API — opt-in sonic feedback |
401
+ Available scales: `color`, `space`, `fontSize`, `lineHeight`, `duration`, `easing`, `radius`.
312
402
 
313
403
  ---
314
404
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmonia-core/ui",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "private": false,
5
5
  "description": "A capacity-adaptive UI framework that treats human cognitive, temporal, and emotional state as first-class inputs. Derives interface modes (density, motion, contrast, focus) from explicit user state — no inference, no profiling.",
6
6
  "keywords": [