@harmonia-core/ui 1.2.8 → 1.2.11
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 +121 -31
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# @harmonia-core/ui
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@harmonia-core/ui)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://react.dev)
|
|
7
|
+
[](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) |
|
|
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
|
-
##
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
###
|
|
387
|
+
### Design tokens (rengeVars)
|
|
283
388
|
|
|
284
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "1.2.11",
|
|
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": [
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"dist"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@renge-ui/tokens": "^2.
|
|
50
|
+
"@renge-ui/tokens": "^2.5.0",
|
|
51
51
|
"react": ">=18.0.0",
|
|
52
52
|
"react-dom": ">=18.0.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@renge-ui/tailwind": "^2.
|
|
57
|
-
"@renge-ui/tokens": "^2.
|
|
56
|
+
"@renge-ui/tailwind": "^2.7.1",
|
|
57
|
+
"@renge-ui/tokens": "^2.5.0",
|
|
58
58
|
"@tailwindcss/postcss": "^4.1.9",
|
|
59
59
|
"@testing-library/dom": "^10.4.1",
|
|
60
60
|
"@testing-library/jest-dom": "^6.9.1",
|