@meistrari/tela-build 1.99.0 → 1.100.0
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/CHANGELOG.md +2 -0
- package/composables/use-sound.ts +65 -0
- package/docs/sounds.md +94 -0
- package/lib/doc-generator.ts +1 -0
- package/nuxt.config.ts +1 -0
- package/package.json +2 -1
- package/utils/sounds/minimal.ts +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -131,6 +131,7 @@ Latest updates and announcements.
|
|
|
131
131
|
|
|
132
132
|
## October 8, 2026
|
|
133
133
|
|
|
134
|
+
- `useSound()` adds `playWhenAway(name, startedAt?, options?)` for long-running work: it plays only when the tab is hidden or when at least `minDurationMs` (default 5s) passed since `startedAt`, so fast results stay silent.
|
|
134
135
|
- [Tooltip](/components/tooltip#multiline-tooltip) multiline is more compact: the title is `body-12-semibold` (was `body-14-semibold`), the description is `neutral-300` (was white at 90%), and the 2px gap between them is gone.
|
|
135
136
|
|
|
136
137
|
## October 7, 2026
|
|
@@ -152,6 +153,7 @@ Latest updates and announcements.
|
|
|
152
153
|
|
|
153
154
|
## October 5, 2026
|
|
154
155
|
|
|
156
|
+
- New `useSound()` composable plays UI sounds from the [`@web-kits/audio`](https://audio.raphaelsalaja.com) Minimal patch: 26 short sine-wave tones (`click`, `toggleOn`, `success`, `error`, `copy`, `delete`, and more) synthesized at runtime, with no audio files. `play(name, options?)` is silent during SSR and when sounds are turned off, and browsers drop it until the page's first user gesture. `enabled` and `volume` are shared across the app and persisted in localStorage.
|
|
155
157
|
- [Floating chat](/templates/chat#floating) adds `position="left" | "right"` (default `right`) to place the launcher and panel in either bottom corner, with matching alignment and mirrored open/close animations.
|
|
156
158
|
- [Kbd](/components/kbd) icon keys render a 12px icon inside the 16×16 key, and Enter is now `TelaKbd icon="i-ph-arrow-bend-down-left"`. `TelaKbdReturn` is deprecated and logs a warning in development.
|
|
157
159
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { PlayOptions, VoiceHandle } from '@web-kits/audio'
|
|
2
|
+
import { createGlobalState, useLocalStorage } from '@vueuse/core'
|
|
3
|
+
import { defineSound } from '@web-kits/audio'
|
|
4
|
+
import * as minimal from '../utils/sounds/minimal'
|
|
5
|
+
|
|
6
|
+
const { _patch, _delete, ...rest } = minimal
|
|
7
|
+
const sounds = { ...rest, delete: _delete }
|
|
8
|
+
|
|
9
|
+
export type TelaSoundName = keyof typeof sounds
|
|
10
|
+
|
|
11
|
+
type Player = (options?: PlayOptions) => VoiceHandle
|
|
12
|
+
|
|
13
|
+
const players = new Map<TelaSoundName, Player>()
|
|
14
|
+
|
|
15
|
+
function getPlayer(name: TelaSoundName) {
|
|
16
|
+
const existing = players.get(name)
|
|
17
|
+
|
|
18
|
+
if (existing)
|
|
19
|
+
return existing
|
|
20
|
+
|
|
21
|
+
const player = defineSound(sounds[name])
|
|
22
|
+
|
|
23
|
+
players.set(name, player)
|
|
24
|
+
|
|
25
|
+
return player
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const useSoundSettings = createGlobalState(() => ({
|
|
29
|
+
enabled: useLocalStorage('tela-sounds-enabled', true),
|
|
30
|
+
volume: useLocalStorage('tela-sounds-volume', 1),
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
export function useSound() {
|
|
34
|
+
const { enabled, volume } = useSoundSettings()
|
|
35
|
+
|
|
36
|
+
function play(name: TelaSoundName, options: PlayOptions = {}): VoiceHandle | undefined {
|
|
37
|
+
if (typeof window === 'undefined' || !enabled.value || volume.value <= 0)
|
|
38
|
+
return undefined
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
return getPlayer(name)({ ...options, volume: (options.volume ?? 1) * volume.value })
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function playWhenAway(name: TelaSoundName, startedAt?: number, options: PlayOptions & { minDurationMs?: number } = {}) {
|
|
49
|
+
const { minDurationMs = 5000, ...playOptions } = options
|
|
50
|
+
const isHidden = typeof document !== 'undefined' && document.hidden
|
|
51
|
+
const tookLong = startedAt !== undefined && Date.now() - startedAt >= minDurationMs
|
|
52
|
+
|
|
53
|
+
if (!isHidden && !tookLong)
|
|
54
|
+
return undefined
|
|
55
|
+
|
|
56
|
+
return play(name, playOptions)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
play,
|
|
61
|
+
playWhenAway,
|
|
62
|
+
enabled,
|
|
63
|
+
volume,
|
|
64
|
+
}
|
|
65
|
+
}
|
package/docs/sounds.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Sounds
|
|
2
|
+
|
|
3
|
+
UI sounds come from `useSound()`, which plays short, quiet sine-wave tones synthesized at runtime, with no audio files. Sound is feedback. Treat it like animation: use it rarely and on purpose.
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
const { play } = useSound()
|
|
8
|
+
|
|
9
|
+
async function save() {
|
|
10
|
+
await saveDocument()
|
|
11
|
+
play('success')
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<TelaButton @click="save">
|
|
17
|
+
Save
|
|
18
|
+
</TelaButton>
|
|
19
|
+
</template>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Only for moments that matter
|
|
23
|
+
|
|
24
|
+
Be careful when adding a sound. Sounds are for unique moments the user would hate to miss: publishing something, a run or long task finishing, an upload completing, someone joining the page. Most actions, including deletes, favorites, toggles and navigation, stay silent.
|
|
25
|
+
|
|
26
|
+
Before adding one, search the app for existing `useSound()` calls. If the new moment isn't as important as the ones already there, don't add it. A few meaningful sounds are worth more than many small ones, so don't add too many.
|
|
27
|
+
|
|
28
|
+
## Should this make a sound?
|
|
29
|
+
|
|
30
|
+
Answer the same frequency question as for [animations](#animations), but be stricter. A sound reaches everyone in the room.
|
|
31
|
+
|
|
32
|
+
| Frequency | Decision |
|
|
33
|
+
| ------------------------------------------------------- | -------------------------- |
|
|
34
|
+
| 100+ times/day (typing, keyboard shortcuts, hover) | No sound. Ever. |
|
|
35
|
+
| Tens of times/day (tabs, toggles, list selection) | No sound by default |
|
|
36
|
+
| Occasional (send, copy, delete, save) | No sound by default |
|
|
37
|
+
| Rare (publish, a run or upload finishes, someone joins) | Sound helps |
|
|
38
|
+
|
|
39
|
+
- **Pair sound with something visible.** Sound confirms what the screen already shows. It never carries information on its own, because many users run muted.
|
|
40
|
+
- **Play one sound per action.** Don't stack `click` + `success` on the same press.
|
|
41
|
+
- **Play from a user gesture or the result of one.** Browsers keep audio suspended until the first interaction, so a sound triggered on page load is dropped.
|
|
42
|
+
- **Never play on hover or on keyboard-initiated actions**, even though `hover` and `keyPress` exist in the patch.
|
|
43
|
+
|
|
44
|
+
## Sound names
|
|
45
|
+
|
|
46
|
+
| Name | Use for |
|
|
47
|
+
| ------------------------------------ | ------------------------------------------------ |
|
|
48
|
+
| `tap`, `click` | A primary press that has no other feedback |
|
|
49
|
+
| `toggleOn`, `toggleOff`, `checkbox` | Settings that change state |
|
|
50
|
+
| `select`, `deselect` | Picking items in a multi-select surface |
|
|
51
|
+
| `expand`, `collapse` | Disclosure panels |
|
|
52
|
+
| `tabSwitch`, `pageEnter`, `pageExit` | Navigation (rarely: see the frequency table) |
|
|
53
|
+
| `success`, `error`, `warning`, `info` | Results of async work, alongside a toast or `TelaStatus` |
|
|
54
|
+
| `notification` | Something arrived that the user didn't trigger |
|
|
55
|
+
| `copy`, `send`, `delete`, `undo` | The matching actions |
|
|
56
|
+
| `pop`, `swoosh`, `slide` | Elements entering or leaving |
|
|
57
|
+
| `hover`, `keyPress` | Avoid. They exist in the patch for completeness |
|
|
58
|
+
|
|
59
|
+
## Long-running work
|
|
60
|
+
|
|
61
|
+
A run that finishes in a second needs no sound: the user is still looking at it. `playWhenAway(name, startedAt?, options?)` plays only when the tab is hidden or when at least `minDurationMs` (default `5000`) passed since `startedAt`, a `Date.now()` timestamp:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const { playWhenAway } = useSound()
|
|
65
|
+
|
|
66
|
+
const startedAt = Date.now()
|
|
67
|
+
const result = await runWorkflow()
|
|
68
|
+
playWhenAway(result.ok ? 'success' : 'error', startedAt)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Without `startedAt`, it plays only when the tab is hidden.
|
|
72
|
+
|
|
73
|
+
## Settings
|
|
74
|
+
|
|
75
|
+
`enabled` and `volume` are shared refs. They are global across the app and persisted in localStorage (`tela-sounds-enabled`, `tela-sounds-volume`). Bind them to a user preference instead of creating your own flag:
|
|
76
|
+
|
|
77
|
+
```vue
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
const { enabled } = useSound()
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<label flex items-center justify-between gap-12px>
|
|
84
|
+
<span body-14-medium text-primary>Interface sounds</span>
|
|
85
|
+
<TelaSwitch v-model="enabled" />
|
|
86
|
+
</label>
|
|
87
|
+
</template>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`play(name, options)` accepts `@web-kits/audio` `PlayOptions`. `volume` multiplies the global volume, and `jitter` adds small random variation to a sound that repeats:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
play('copy', { jitter: { detune: 40, volume: 0.1 } })
|
|
94
|
+
```
|
package/lib/doc-generator.ts
CHANGED
|
@@ -1013,6 +1013,7 @@ spacing, border radius, optical alignment. Triggers on UI polish, "feels off", d
|
|
|
1013
1013
|
| Surfaces | Border radius, depth strategy, elevation, outlines, hit areas |
|
|
1014
1014
|
| Typography | Heading tokens, body font sizes, font weights |
|
|
1015
1015
|
| Animations | Deciding when to animate, easing, duration, springs, and staggered enter animations |
|
|
1016
|
+
| Sounds | Deciding when an action plays a UI sound, picking the sound, and wiring \`useSound()\` |
|
|
1016
1017
|
|
|
1017
1018
|
## Common Mistakes
|
|
1018
1019
|
|
package/nuxt.config.ts
CHANGED
|
@@ -108,6 +108,7 @@ export default defineNuxtConfig({
|
|
|
108
108
|
// components makes Vite discover the dep mid-session, re-optimize, and
|
|
109
109
|
// hard-reload the browser. Prebundling them up front keeps dev stable.
|
|
110
110
|
include: [
|
|
111
|
+
'@web-kits/audio',
|
|
111
112
|
'clsx',
|
|
112
113
|
'date-fns',
|
|
113
114
|
'radix-vue',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/tela-build",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.100.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"app.config.ts",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"@vueuse/components": "12.8.2",
|
|
40
40
|
"@vueuse/core": "12.8.2",
|
|
41
41
|
"@vueuse/nuxt": "12.8.2",
|
|
42
|
+
"@web-kits/audio": "0.2.0",
|
|
42
43
|
"beautiful-mermaid": "1.1.3",
|
|
43
44
|
"class-variance-authority": "0.7.0",
|
|
44
45
|
"clsx": "2.1.1",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Minimal — generated by @web-kits/audio, lint-formatted. Do not tune by hand.
|
|
2
|
+
// Source: `npx @web-kits/audio add raphaelsalaja/audio --patch minimal`
|
|
3
|
+
import type { SoundDefinition, SoundPatch } from '@web-kits/audio'
|
|
4
|
+
|
|
5
|
+
export const tap: SoundDefinition = { source: { type: 'sine', frequency: 1200 }, envelope: { attack: 0, decay: 0.012, sustain: 0, release: 0.004 }, gain: 0.08 }
|
|
6
|
+
export const click: SoundDefinition = { source: { type: 'sine', frequency: 800 }, envelope: { attack: 0, decay: 0.015, sustain: 0, release: 0.005 }, gain: 0.1 }
|
|
7
|
+
export const keyPress: SoundDefinition = { source: { type: 'sine', frequency: 1100 }, envelope: { attack: 0, decay: 0.01, sustain: 0, release: 0.003 }, gain: 0.06 }
|
|
8
|
+
export const toggleOn: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 880 }, envelope: { attack: 0, decay: 0.02, sustain: 0, release: 0.006 }, gain: 0.08 }, { source: { type: 'sine', frequency: 1320 }, envelope: { attack: 0, decay: 0.02, sustain: 0, release: 0.006 }, delay: 0.03, gain: 0.07 }] }
|
|
9
|
+
export const toggleOff: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 1320 }, envelope: { attack: 0, decay: 0.02, sustain: 0, release: 0.006 }, gain: 0.08 }, { source: { type: 'sine', frequency: 880 }, envelope: { attack: 0, decay: 0.02, sustain: 0, release: 0.006 }, delay: 0.03, gain: 0.07 }] }
|
|
10
|
+
export const checkbox: SoundDefinition = { source: { type: 'sine', frequency: 1000 }, envelope: { attack: 0, decay: 0.018, sustain: 0, release: 0.005 }, gain: 0.09 }
|
|
11
|
+
export const select: SoundDefinition = { source: { type: 'sine', frequency: 1100 }, envelope: { attack: 0, decay: 0.02, sustain: 0, release: 0.006 }, gain: 0.08 }
|
|
12
|
+
export const deselect: SoundDefinition = { source: { type: 'sine', frequency: 900 }, envelope: { attack: 0, decay: 0.018, sustain: 0, release: 0.005 }, gain: 0.06 }
|
|
13
|
+
export const hover: SoundDefinition = { source: { type: 'sine', frequency: 1300 }, envelope: { attack: 0, decay: 0.01, sustain: 0, release: 0.004 }, gain: 0.04 }
|
|
14
|
+
export const tabSwitch: SoundDefinition = { source: { type: 'sine', frequency: 1050 }, envelope: { attack: 0, decay: 0.015, sustain: 0, release: 0.005 }, gain: 0.07 }
|
|
15
|
+
export const expand: SoundDefinition = { source: { type: 'sine', frequency: { start: 800, end: 1000 } }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, gain: 0.06 }
|
|
16
|
+
export const collapse: SoundDefinition = { source: { type: 'sine', frequency: { start: 1000, end: 800 } }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, gain: 0.06 }
|
|
17
|
+
export const pageEnter: SoundDefinition = { source: { type: 'sine', frequency: { start: 700, end: 900 } }, envelope: { attack: 0.003, decay: 0.04, sustain: 0, release: 0.015 }, gain: 0.05 }
|
|
18
|
+
export const pageExit: SoundDefinition = { source: { type: 'sine', frequency: { start: 900, end: 700 } }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.015 }, gain: 0.04 }
|
|
19
|
+
export const success: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 523 }, envelope: { attack: 0, decay: 0.05, sustain: 0, release: 0.015 }, gain: 0.1 }, { source: { type: 'sine', frequency: 784 }, envelope: { attack: 0, decay: 0.05, sustain: 0, release: 0.015 }, delay: 0.06, gain: 0.08 }] }
|
|
20
|
+
export const error: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 300 }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, gain: 0.12 }, { source: { type: 'sine', frequency: 280 }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, delay: 0.01, gain: 0.1 }] }
|
|
21
|
+
export const warning: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 440 }, envelope: { attack: 0, decay: 0.03, sustain: 0, release: 0.01 }, gain: 0.1 }, { source: { type: 'sine', frequency: 466 }, envelope: { attack: 0, decay: 0.03, sustain: 0, release: 0.01 }, delay: 0.008, gain: 0.08 }] }
|
|
22
|
+
export const notification: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 660 }, envelope: { attack: 0, decay: 0.05, sustain: 0, release: 0.02 }, gain: 0.1 }, { source: { type: 'sine', frequency: 880 }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.015 }, delay: 0.08, gain: 0.08 }] }
|
|
23
|
+
export const info: SoundDefinition = { source: { type: 'sine', frequency: 880 }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.015 }, gain: 0.08 }
|
|
24
|
+
export const copy: SoundDefinition = { layers: [{ source: { type: 'sine', frequency: 1000 }, envelope: { attack: 0, decay: 0.012, sustain: 0, release: 0.004 }, gain: 0.08 }, { source: { type: 'sine', frequency: 1200 }, envelope: { attack: 0, decay: 0.012, sustain: 0, release: 0.004 }, delay: 0.035, gain: 0.07 }] }
|
|
25
|
+
export const send: SoundDefinition = { source: { type: 'sine', frequency: { start: 600, end: 1000 } }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, gain: 0.08 }
|
|
26
|
+
export const _delete: SoundDefinition = { source: { type: 'sine', frequency: { start: 500, end: 250 } }, envelope: { attack: 0, decay: 0.05, sustain: 0, release: 0.015 }, gain: 0.1 }
|
|
27
|
+
export const undo: SoundDefinition = { source: { type: 'sine', frequency: { start: 800, end: 600 } }, envelope: { attack: 0, decay: 0.035, sustain: 0, release: 0.01 }, gain: 0.07 }
|
|
28
|
+
export const pop: SoundDefinition = { source: { type: 'sine', frequency: { start: 400, end: 200 } }, envelope: { attack: 0, decay: 0.04, sustain: 0, release: 0.012 }, gain: 0.1 }
|
|
29
|
+
export const swoosh: SoundDefinition = { source: { type: 'sine', frequency: { start: 600, end: 1400 } }, envelope: { attack: 0.005, decay: 0.04, sustain: 0, release: 0.015 }, gain: 0.05 }
|
|
30
|
+
export const slide: SoundDefinition = { source: { type: 'sine', frequency: { start: 800, end: 1100 } }, envelope: { attack: 0.003, decay: 0.035, sustain: 0, release: 0.012 }, gain: 0.05 }
|
|
31
|
+
|
|
32
|
+
export const _patch: SoundPatch = {
|
|
33
|
+
...{ name: 'Minimal', author: 'Raphael Salaja', version: '1.0.0', description: 'Pure sine waves, ultra-clean feedback — the quietest, most transparent UI sounds', tags: ['ui', 'minimal', 'clean', 'sine'] },
|
|
34
|
+
sounds: { tap, click, 'key-press': keyPress, 'toggle-on': toggleOn, 'toggle-off': toggleOff, checkbox, select, deselect, hover, 'tab-switch': tabSwitch, expand, collapse, 'page-enter': pageEnter, 'page-exit': pageExit, success, error, warning, notification, info, copy, send, 'delete': _delete, undo, pop, swoosh, slide },
|
|
35
|
+
}
|