@meistrari/tela-build 1.84.0 → 1.86.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 +7 -0
- package/components/tela/button/button.vue +4 -4
- package/components/tela/chat/chat.mdx +1 -1
- package/components/tela/chat/text-message/index.vue +1 -1
- package/components/tela/file-upload/file-upload.vue +3 -3
- package/components/tela/uploader/uploader-drop-zone.vue +4 -4
- package/components/tela/video-player/video-player.mdx +101 -0
- package/components/tela/video-player/video-player.vue +603 -0
- package/docs/typography.md +43 -7
- package/package.json +1 -1
- package/unocss.config.ts +17 -9
- package/utils/design-tokens.ts +47 -0
- package/components/tela/link-decoration/link-decoration.vue +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Latest updates and announcements.
|
|
4
4
|
|
|
5
|
+
## October 9, 2026
|
|
6
|
+
|
|
7
|
+
- [Typography](/typography) adds the styles that only existed in Figma: `display-{large|medium|small}-<weight>`, `paragraph-{20|16|14|quote}-<weight>`, `button-{16|14|12}-<weight>` (same `<family>-<size>-<weight>` pattern as `body-*` and `heading-*`), the 10px body size (`body-10-*`), and an `underline` weight (`body-14-underline`) that renders regular weight with an underline.
|
|
8
|
+
- `TelaLinkDecoration` is removed. Use a plain `<a>` (or `<span>`) with a `body-<size>-underline` token instead: `<TelaLinkDecoration :href="url">Docs</TelaLinkDecoration>` → `<a :href="url" body-12-underline text-gray-900>Docs</a>`. The underline keeps the same 3px offset.
|
|
9
|
+
- [Typography](/typography) `body-caption-<size>-<weight>` is replaced by `body-<size>-<weight>-uppercase` (`body-caption-9-medium` → `body-9-medium-uppercase`). Rendering is unchanged: uppercase with 0.05em tracking.
|
|
10
|
+
|
|
5
11
|
## October 8, 2026
|
|
6
12
|
|
|
7
13
|
- [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.
|
|
8
14
|
|
|
9
15
|
## October 7, 2026
|
|
10
16
|
|
|
17
|
+
- New [Video Player](/components/video-player) (`TelaVideoPlayer`): a video with custom controls for play/pause, volume, scrubbing, playback speed, captions, picture-in-picture and fullscreen, plus keyboard shortcuts. Accessible labels are English by default and translatable through `labels`.
|
|
11
18
|
- [Tags Select](/components/tags) back and edit buttons, [Sheet](/components/sheet) content close buttons, and the [Sidebar](/patterns/sidebar) user menu trigger receive shared translated accessible names automatically.
|
|
12
19
|
- [Uploader](/patterns/uploader) disclosure controls use a single named button with the expanded state.
|
|
13
20
|
- [Input](/components/input) clear buttons and tooltips use the shared translated label unless `clearLabel` is provided.
|
|
@@ -35,9 +35,9 @@ const hasLeadingIcon = computed(() => !!((props.loading && props.leading) || slo
|
|
|
35
35
|
const hasTrailingIcon = computed(() => !!((props.loading && !props.leading) || slots.trailing || (props.icon && !props.leading)))
|
|
36
36
|
|
|
37
37
|
const sizeStyle = computed(() => (({
|
|
38
|
-
sm: '[--padding-x:10px]
|
|
39
|
-
md: '[--padding-x:12px]
|
|
40
|
-
lg: '[--padding-x:16px]
|
|
38
|
+
sm: '[--padding-x:10px] button-12-semibold py-[4px] rounded-[9px]',
|
|
39
|
+
md: '[--padding-x:12px] button-14-semibold py-[7px] rounded-[11px]',
|
|
40
|
+
lg: '[--padding-x:16px] button-16-semibold py-[8px] rounded-[12px]',
|
|
41
41
|
}) as Record<ButtonSize, string>)[resolvedSize.value] ?? '')
|
|
42
42
|
|
|
43
43
|
const paddingStyle = computed(() => [
|
|
@@ -76,7 +76,7 @@ const iconSize = computed(() => (({
|
|
|
76
76
|
:is="tag"
|
|
77
77
|
:to="to"
|
|
78
78
|
:class="cn(
|
|
79
|
-
'box-border
|
|
79
|
+
'box-border select-none flex items-center justify-center gap-4px ease-out duration-40',
|
|
80
80
|
disabled ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
81
81
|
resolvedStyle,
|
|
82
82
|
)"
|
|
@@ -221,7 +221,7 @@ const labels = useTelaLabels()
|
|
|
221
221
|
<span class="body-12-regular text-gray-600">{{ timestampString }}</span>
|
|
222
222
|
<TelaIcon v-if="version" name="i-ph-dot" color="gray-300" />
|
|
223
223
|
<div v-if="version" py-2px px-4px rounded-5px bg-gray-200 h-16px>
|
|
224
|
-
<p body-
|
|
224
|
+
<p body-9-bold-uppercase text-gray-600>
|
|
225
225
|
{{ version }}
|
|
226
226
|
</p>
|
|
227
227
|
</div>
|
|
@@ -196,16 +196,16 @@ const telaLabels = useTelaLabels()
|
|
|
196
196
|
<TelaIcon name="i-ph-upload-simple-bold" size="16px" color="gray-400" />
|
|
197
197
|
<div class="flex flex-col items-center justify-center gap-1">
|
|
198
198
|
<h5 heading-h5-semibold text-primary>
|
|
199
|
-
{{ labels.dragAndDrop }} <
|
|
199
|
+
{{ labels.dragAndDrop }} <span class="body-14-underline ml-1px text-gray-700">{{ labels.orBrowse }}</span>
|
|
200
200
|
</h5>
|
|
201
201
|
<div flex="~ col" gap-1px items-center>
|
|
202
202
|
<p flex items-center gap-4px body-12-regular text-tertiary>
|
|
203
203
|
{{ labels.supportedFormats }}: {{ fileTypesDisplay.text }}
|
|
204
204
|
<template v-if="fileTypesDisplay.hasMore">
|
|
205
205
|
{{ labels.and }}
|
|
206
|
-
<
|
|
206
|
+
<span class="body-12-underline underline-offset-2px">
|
|
207
207
|
{{ fileTypesDisplay.moreCount }} {{ labels.more }}
|
|
208
|
-
</
|
|
208
|
+
</span>
|
|
209
209
|
<TelaTooltip variant="multiline" content-class="w-fit min-w-100px max-w-100px" :description="fileTypesDisplay.moreTooltip" side="right">
|
|
210
210
|
<TelaIcon name="i-ph-info-bold" size="14px" color="gray-400" />
|
|
211
211
|
</TelaTooltip>
|
|
@@ -55,16 +55,16 @@ const emit = defineEmits<{
|
|
|
55
55
|
<TelaIcon v-else name="i-ph-upload-simple-bold" size="16px" color="gray-400" />
|
|
56
56
|
<div flex="~ col" items-center gap-5px justify-center>
|
|
57
57
|
<h5 heading-h5-semibold text-primary>
|
|
58
|
-
{{ dragAndDropYourFilesLabel }} <
|
|
58
|
+
{{ dragAndDropYourFilesLabel }} <span class="body-14-underline ml-1px text-gray-900">
|
|
59
59
|
{{ orBrowseLabel }}
|
|
60
|
-
</
|
|
60
|
+
</span>
|
|
61
61
|
</h5>
|
|
62
62
|
<p flex items-center gap-4px body-12-regular text-tertiary>
|
|
63
63
|
{{ supportedFormatsLabel }} {{ fileTypesDisplay.text }} {{ andLabel }}
|
|
64
64
|
<template v-if="fileTypesDisplay.hasMore">
|
|
65
|
-
<
|
|
65
|
+
<span class="body-12-underline underline-offset-2px">
|
|
66
66
|
{{ fileTypesDisplay.moreCount }} {{ moreLabel }}
|
|
67
|
-
</
|
|
67
|
+
</span>
|
|
68
68
|
<TelaTooltip variant="multiline" content-class="w-fit min-w-100px max-w-100px" :description="fileTypesDisplay.moreTooltip" side="right">
|
|
69
69
|
<TelaIcon name="i-ph-info-bold" size="14px" color="gray-400" />
|
|
70
70
|
</TelaTooltip>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Meta, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Media/VideoPlayer" tags={['new']} />
|
|
4
|
+
|
|
5
|
+
# TelaVideoPlayer
|
|
6
|
+
|
|
7
|
+
A video player with custom controls: play/pause, a hover volume slider, a scrubbable progress bar with buffered range and hover time, playback speed, captions, picture-in-picture and fullscreen. Controls fade out after a short idle while playing and come back on pointer movement or focus.
|
|
8
|
+
|
|
9
|
+
The player is a 16:9 black surface in both themes, so its controls are always white.
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
type VideoPlayerProps = {
|
|
15
|
+
src: string
|
|
16
|
+
poster?: string
|
|
17
|
+
tracks?: VideoPlayerTrack[]
|
|
18
|
+
crossorigin?: 'anonymous' | 'use-credentials'
|
|
19
|
+
labels?: Partial<VideoPlayerLabels>
|
|
20
|
+
class?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type VideoPlayerTrack = {
|
|
24
|
+
src: string
|
|
25
|
+
srcLang: string
|
|
26
|
+
label: string
|
|
27
|
+
kind: 'subtitles' | 'captions'
|
|
28
|
+
default?: boolean
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Emits
|
|
33
|
+
|
|
34
|
+
- `play` — playback started
|
|
35
|
+
- `pause` — playback paused
|
|
36
|
+
- `ended` — playback reached the end
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Basic Usage
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<TelaVideoPlayer
|
|
44
|
+
src="https://tela.com/videos/hero-showcase.mp4"
|
|
45
|
+
poster="https://tela.com/videos/hero-showcase-poster.jpg"
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Custom Width and Radius
|
|
50
|
+
|
|
51
|
+
The root accepts `class`, merged with `cn()`, so width and radius can be overridden.
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<TelaVideoPlayer
|
|
55
|
+
src="https://tela.com/videos/hero-showcase.mp4"
|
|
56
|
+
poster="https://tela.com/videos/hero-showcase-poster.jpg"
|
|
57
|
+
class="max-w-480px rounded-12px"
|
|
58
|
+
/>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Captions
|
|
62
|
+
|
|
63
|
+
Pass WebVTT files through `tracks`. A captions toggle appears in the control bar when at least one track is set, and it toggles the first track. Track files on another origin only load when the player sets `crossorigin`: pass `crossorigin="anonymous"` and serve both the track and the video `src` with CORS headers. With `crossorigin` set, a video served without CORS headers fails to load.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const tracks: VideoPlayerTrack[] = [
|
|
67
|
+
{ src: '/captions/intro.en.vtt', srcLang: 'en', label: 'English', kind: 'captions', default: true },
|
|
68
|
+
]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Translation
|
|
72
|
+
|
|
73
|
+
Every accessible label has an English default. Pass `labels` to translate any of them: `region`, `play`, `pause`, `mute`, `unmute`, `volume`, `seek`, `playbackSpeed`, `showCaptions`, `hideCaptions`, `pictureInPicture`, `fullscreen`, `exitFullscreen`.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const labels = { play: t('video.play'), pause: t('video.pause') }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Interaction
|
|
80
|
+
|
|
81
|
+
- Click the video to play or pause; double click toggles fullscreen.
|
|
82
|
+
- Hover the speaker to open the vertical volume slider; drag or use arrow keys on it.
|
|
83
|
+
- Drag the progress bar to scrub. Hovering shows the time under the pointer over the total.
|
|
84
|
+
- The speed button cycles `1×`, `1.25×`, `1.5×`, `2×`.
|
|
85
|
+
- Fullscreen uses the container, so the custom controls stay visible. iPhone Safari has no element fullscreen and falls back to the native video fullscreen.
|
|
86
|
+
- Below the `sm` breakpoint the speed and picture-in-picture buttons are hidden.
|
|
87
|
+
|
|
88
|
+
## Keyboard
|
|
89
|
+
|
|
90
|
+
While the player has focus:
|
|
91
|
+
|
|
92
|
+
| Key | Action |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `Space` / `K` | Play or pause |
|
|
95
|
+
| `M` | Mute or unmute |
|
|
96
|
+
| `F` | Toggle fullscreen |
|
|
97
|
+
| `C` | Toggle captions |
|
|
98
|
+
| `←` / `→` | Seek 5 seconds |
|
|
99
|
+
| `↑` / `↓` | Volume up or down |
|
|
100
|
+
|
|
101
|
+
Space on a focused button activates that button instead of toggling playback. The seek and volume sliders are focusable with Tab and take arrow keys; the seek slider also takes `Home` and `End`. Controls stay visible while a control has keyboard focus.
|
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type VideoPlayerTrack = {
|
|
5
|
+
src: string
|
|
6
|
+
srcLang: string
|
|
7
|
+
label: string
|
|
8
|
+
kind: 'subtitles' | 'captions'
|
|
9
|
+
default?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type VideoPlayerLabels = {
|
|
13
|
+
region: string
|
|
14
|
+
play: string
|
|
15
|
+
pause: string
|
|
16
|
+
mute: string
|
|
17
|
+
unmute: string
|
|
18
|
+
volume: string
|
|
19
|
+
seek: string
|
|
20
|
+
playbackSpeed: string
|
|
21
|
+
showCaptions: string
|
|
22
|
+
hideCaptions: string
|
|
23
|
+
pictureInPicture: string
|
|
24
|
+
fullscreen: string
|
|
25
|
+
exitFullscreen: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const props = withDefaults(defineProps<{
|
|
29
|
+
src: string
|
|
30
|
+
poster?: string
|
|
31
|
+
tracks?: VideoPlayerTrack[]
|
|
32
|
+
crossorigin?: 'anonymous' | 'use-credentials'
|
|
33
|
+
labels?: Partial<VideoPlayerLabels>
|
|
34
|
+
class?: HTMLAttributes['class']
|
|
35
|
+
}>(), {
|
|
36
|
+
tracks: () => [],
|
|
37
|
+
labels: () => ({}),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits<{
|
|
41
|
+
play: []
|
|
42
|
+
pause: []
|
|
43
|
+
ended: []
|
|
44
|
+
}>()
|
|
45
|
+
|
|
46
|
+
const DEFAULT_LABELS: VideoPlayerLabels = {
|
|
47
|
+
region: 'Video player',
|
|
48
|
+
play: 'Play',
|
|
49
|
+
pause: 'Pause',
|
|
50
|
+
mute: 'Mute',
|
|
51
|
+
unmute: 'Unmute',
|
|
52
|
+
volume: 'Volume',
|
|
53
|
+
seek: 'Seek',
|
|
54
|
+
playbackSpeed: 'Playback speed',
|
|
55
|
+
showCaptions: 'Show captions',
|
|
56
|
+
hideCaptions: 'Hide captions',
|
|
57
|
+
pictureInPicture: 'Picture in picture',
|
|
58
|
+
fullscreen: 'Fullscreen',
|
|
59
|
+
exitFullscreen: 'Exit fullscreen',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }))
|
|
63
|
+
|
|
64
|
+
const container = ref<HTMLElement>()
|
|
65
|
+
const video = ref<HTMLVideoElement>()
|
|
66
|
+
|
|
67
|
+
const isMounted = useMounted()
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
playing,
|
|
71
|
+
currentTime,
|
|
72
|
+
duration,
|
|
73
|
+
volume,
|
|
74
|
+
muted,
|
|
75
|
+
rate,
|
|
76
|
+
buffered,
|
|
77
|
+
selectedTrack,
|
|
78
|
+
enableTrack,
|
|
79
|
+
disableTrack,
|
|
80
|
+
supportsPictureInPicture,
|
|
81
|
+
togglePictureInPicture,
|
|
82
|
+
} = useMediaControls(video, {
|
|
83
|
+
src: toRef(props, 'src'),
|
|
84
|
+
tracks: toRef(props, 'tracks'),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
isFullscreen,
|
|
89
|
+
isSupported: isFullscreenSupported,
|
|
90
|
+
toggle: toggleContainerFullscreen,
|
|
91
|
+
} = useFullscreen(container)
|
|
92
|
+
|
|
93
|
+
function togglePlay() {
|
|
94
|
+
playing.value = !playing.value
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* The play toggle waits out the double-click window so a double click only toggles fullscreen. */
|
|
98
|
+
const DOUBLE_CLICK_DELAY = 250
|
|
99
|
+
|
|
100
|
+
let surfaceClickTimer: ReturnType<typeof setTimeout> | undefined
|
|
101
|
+
|
|
102
|
+
function onSurfaceClick() {
|
|
103
|
+
clearTimeout(surfaceClickTimer)
|
|
104
|
+
surfaceClickTimer = setTimeout(togglePlay, DOUBLE_CLICK_DELAY)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function onSurfaceDoubleClick() {
|
|
108
|
+
clearTimeout(surfaceClickTimer)
|
|
109
|
+
toggleFullscreen()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function toggleMute() {
|
|
113
|
+
muted.value = !muted.value
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const IDLE_DELAY = 2200
|
|
117
|
+
|
|
118
|
+
const isUserActive = ref(true)
|
|
119
|
+
|
|
120
|
+
let idleTimer: ReturnType<typeof setTimeout> | undefined
|
|
121
|
+
|
|
122
|
+
function markActive() {
|
|
123
|
+
isUserActive.value = true
|
|
124
|
+
|
|
125
|
+
clearTimeout(idleTimer)
|
|
126
|
+
|
|
127
|
+
idleTimer = setTimeout(() => {
|
|
128
|
+
isUserActive.value = false
|
|
129
|
+
}, IDLE_DELAY)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function onPointerLeave() {
|
|
133
|
+
clearTimeout(idleTimer)
|
|
134
|
+
isUserActive.value = false
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onBeforeUnmount(() => {
|
|
138
|
+
clearTimeout(surfaceClickTimer)
|
|
139
|
+
clearTimeout(idleTimer)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const isScrubbing = ref(false)
|
|
143
|
+
const isVolumeScrubbing = ref(false)
|
|
144
|
+
|
|
145
|
+
const isControlFocused = ref(false)
|
|
146
|
+
|
|
147
|
+
function onFocusIn(event: FocusEvent) {
|
|
148
|
+
isControlFocused.value = event.target instanceof HTMLElement
|
|
149
|
+
&& event.target !== container.value
|
|
150
|
+
&& event.target.matches(':focus-visible')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function onFocusOut() {
|
|
154
|
+
isControlFocused.value = false
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const areControlsVisible = computed(() => !playing.value || isUserActive.value || isScrubbing.value || isVolumeScrubbing.value || isControlFocused.value)
|
|
158
|
+
|
|
159
|
+
function formatTime(seconds: number) {
|
|
160
|
+
if (!Number.isFinite(seconds) || seconds < 0)
|
|
161
|
+
seconds = 0
|
|
162
|
+
|
|
163
|
+
const total = Math.floor(seconds)
|
|
164
|
+
const hours = Math.floor(total / 3600)
|
|
165
|
+
const minutes = Math.floor((total % 3600) / 60)
|
|
166
|
+
const secs = total % 60
|
|
167
|
+
const pad = (value: number) => String(value).padStart(2, '0')
|
|
168
|
+
|
|
169
|
+
return hours > 0 ? `${hours}:${pad(minutes)}:${pad(secs)}` : `${pad(minutes)}:${pad(secs)}`
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const elapsedLabel = computed(() => formatTime(currentTime.value))
|
|
173
|
+
const durationLabel = computed(() => formatTime(duration.value))
|
|
174
|
+
const remainingLabel = computed(() => `−${formatTime(Math.max(duration.value - currentTime.value, 0))}`)
|
|
175
|
+
|
|
176
|
+
const SEEK_STEP = 5
|
|
177
|
+
const VOLUME_STEP = 0.1
|
|
178
|
+
|
|
179
|
+
const progressBar = ref<HTMLElement>()
|
|
180
|
+
|
|
181
|
+
const progress = computed(() => (duration.value ? currentTime.value / duration.value : 0))
|
|
182
|
+
|
|
183
|
+
const bufferedProgress = computed(() => {
|
|
184
|
+
const last = buffered.value.at(-1)
|
|
185
|
+
|
|
186
|
+
if (!duration.value || !last)
|
|
187
|
+
return 0
|
|
188
|
+
|
|
189
|
+
return Math.min(last[1] / duration.value, 1)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
const hoverRatio = ref<number | null>(null)
|
|
193
|
+
|
|
194
|
+
const hoverLabel = computed(() => (hoverRatio.value === null ? '' : formatTime(hoverRatio.value * duration.value)))
|
|
195
|
+
|
|
196
|
+
function ratioFromEvent(event: PointerEvent) {
|
|
197
|
+
const rect = progressBar.value!.getBoundingClientRect()
|
|
198
|
+
|
|
199
|
+
return Math.min(Math.max((event.clientX - rect.left) / rect.width, 0), 1)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function onBarPointerMove(event: PointerEvent) {
|
|
203
|
+
hoverRatio.value = ratioFromEvent(event)
|
|
204
|
+
|
|
205
|
+
if (isScrubbing.value)
|
|
206
|
+
currentTime.value = hoverRatio.value * duration.value
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function onBarPointerDown(event: PointerEvent) {
|
|
210
|
+
if (!duration.value)
|
|
211
|
+
return
|
|
212
|
+
|
|
213
|
+
isScrubbing.value = true
|
|
214
|
+
progressBar.value!.setPointerCapture(event.pointerId)
|
|
215
|
+
currentTime.value = ratioFromEvent(event) * duration.value
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function onBarPointerUp(event: PointerEvent) {
|
|
219
|
+
if (!isScrubbing.value)
|
|
220
|
+
return
|
|
221
|
+
|
|
222
|
+
isScrubbing.value = false
|
|
223
|
+
progressBar.value!.releasePointerCapture(event.pointerId)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function onBarPointerLeave() {
|
|
227
|
+
if (!isScrubbing.value)
|
|
228
|
+
hoverRatio.value = null
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function seekTo(time: number) {
|
|
232
|
+
currentTime.value = Math.min(Math.max(time, 0), duration.value)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function seekBy(delta: number) {
|
|
236
|
+
seekTo(currentTime.value + delta)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function hasModifier(event: KeyboardEvent) {
|
|
240
|
+
return event.ctrlKey || event.metaKey || event.altKey || event.defaultPrevented
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function onBarKeydown(event: KeyboardEvent) {
|
|
244
|
+
const actions: Record<string, () => void> = {
|
|
245
|
+
ArrowLeft: () => seekBy(-SEEK_STEP),
|
|
246
|
+
ArrowDown: () => seekBy(-SEEK_STEP),
|
|
247
|
+
ArrowRight: () => seekBy(SEEK_STEP),
|
|
248
|
+
ArrowUp: () => seekBy(SEEK_STEP),
|
|
249
|
+
Home: () => seekTo(0),
|
|
250
|
+
End: () => seekTo(duration.value),
|
|
251
|
+
}
|
|
252
|
+
const action = actions[event.key]
|
|
253
|
+
|
|
254
|
+
if (!action || !duration.value || hasModifier(event))
|
|
255
|
+
return
|
|
256
|
+
|
|
257
|
+
event.preventDefault()
|
|
258
|
+
event.stopPropagation()
|
|
259
|
+
|
|
260
|
+
action()
|
|
261
|
+
markActive()
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const RATES = [1, 1.25, 1.5, 2]
|
|
265
|
+
|
|
266
|
+
const rateLabel = computed(() => `${rate.value}×`)
|
|
267
|
+
|
|
268
|
+
function cycleRate() {
|
|
269
|
+
const index = RATES.indexOf(rate.value)
|
|
270
|
+
rate.value = RATES[(index + 1) % RATES.length]!
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const hasCaptions = computed(() => props.tracks.length > 0)
|
|
274
|
+
const areCaptionsOn = computed(() => selectedTrack.value !== -1)
|
|
275
|
+
|
|
276
|
+
function toggleCaptions() {
|
|
277
|
+
if (areCaptionsOn.value)
|
|
278
|
+
disableTrack()
|
|
279
|
+
else
|
|
280
|
+
enableTrack(0)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Fullscreen: iPhone Safari has no element fullscreen, only the native video one. */
|
|
284
|
+
function toggleFullscreen() {
|
|
285
|
+
const element = video.value
|
|
286
|
+
|
|
287
|
+
if (isFullscreenSupported.value)
|
|
288
|
+
toggleContainerFullscreen()
|
|
289
|
+
else if (element && 'webkitEnterFullscreen' in element && typeof element.webkitEnterFullscreen === 'function')
|
|
290
|
+
element.webkitEnterFullscreen()
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function onKeydown(event: KeyboardEvent) {
|
|
294
|
+
if (hasModifier(event))
|
|
295
|
+
return
|
|
296
|
+
|
|
297
|
+
/* Space on a focused button activates that button, not playback */
|
|
298
|
+
if (event.key === ' ' && event.target instanceof HTMLButtonElement)
|
|
299
|
+
return
|
|
300
|
+
|
|
301
|
+
const actions: Record<string, () => void> = {
|
|
302
|
+
' ': togglePlay,
|
|
303
|
+
'k': togglePlay,
|
|
304
|
+
'm': toggleMute,
|
|
305
|
+
'f': toggleFullscreen,
|
|
306
|
+
'c': () => hasCaptions.value && toggleCaptions(),
|
|
307
|
+
'ArrowLeft': () => seekBy(-SEEK_STEP),
|
|
308
|
+
'ArrowRight': () => seekBy(SEEK_STEP),
|
|
309
|
+
'ArrowUp': () => adjustVolume(VOLUME_STEP),
|
|
310
|
+
'ArrowDown': () => adjustVolume(-VOLUME_STEP),
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const action = actions[event.key]
|
|
314
|
+
|
|
315
|
+
if (!action)
|
|
316
|
+
return
|
|
317
|
+
|
|
318
|
+
event.preventDefault()
|
|
319
|
+
action()
|
|
320
|
+
markActive()
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const volumeBar = ref<HTMLElement>()
|
|
324
|
+
|
|
325
|
+
const effectiveVolume = computed(() => (muted.value ? 0 : volume.value))
|
|
326
|
+
|
|
327
|
+
const VOLUME_TRACK_PADDING = 10
|
|
328
|
+
|
|
329
|
+
function setVolume(value: number) {
|
|
330
|
+
volume.value = Math.min(Math.max(value, 0), 1)
|
|
331
|
+
muted.value = volume.value === 0
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function adjustVolume(delta: number) {
|
|
335
|
+
setVolume(effectiveVolume.value + delta)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function setVolumeFromEvent(event: PointerEvent) {
|
|
339
|
+
const rect = volumeBar.value!.getBoundingClientRect()
|
|
340
|
+
const trackTop = rect.top + VOLUME_TRACK_PADDING
|
|
341
|
+
const trackHeight = rect.height - VOLUME_TRACK_PADDING * 2
|
|
342
|
+
|
|
343
|
+
setVolume(1 - (event.clientY - trackTop) / trackHeight)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function onVolumePointerDown(event: PointerEvent) {
|
|
347
|
+
event.preventDefault()
|
|
348
|
+
|
|
349
|
+
isVolumeScrubbing.value = true
|
|
350
|
+
volumeBar.value!.setPointerCapture(event.pointerId)
|
|
351
|
+
setVolumeFromEvent(event)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function onVolumePointerMove(event: PointerEvent) {
|
|
355
|
+
if (isVolumeScrubbing.value)
|
|
356
|
+
setVolumeFromEvent(event)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function onVolumePointerUp(event: PointerEvent) {
|
|
360
|
+
if (!isVolumeScrubbing.value)
|
|
361
|
+
return
|
|
362
|
+
|
|
363
|
+
isVolumeScrubbing.value = false
|
|
364
|
+
volumeBar.value!.releasePointerCapture(event.pointerId)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function onVolumeKeydown(event: KeyboardEvent) {
|
|
368
|
+
const steps: Record<string, number> = { ArrowLeft: -VOLUME_STEP, ArrowDown: -VOLUME_STEP, ArrowRight: VOLUME_STEP, ArrowUp: VOLUME_STEP }
|
|
369
|
+
const step = steps[event.key]
|
|
370
|
+
|
|
371
|
+
if (step === undefined || hasModifier(event))
|
|
372
|
+
return
|
|
373
|
+
|
|
374
|
+
event.preventDefault()
|
|
375
|
+
event.stopPropagation()
|
|
376
|
+
|
|
377
|
+
adjustVolume(step)
|
|
378
|
+
markActive()
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const volumeIcon = computed(() => {
|
|
382
|
+
if (muted.value || volume.value === 0)
|
|
383
|
+
return 'i-ph-speaker-slash'
|
|
384
|
+
|
|
385
|
+
return volume.value < 0.5 ? 'i-ph-speaker-low' : 'i-ph-speaker-high'
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
const buttonClass = 'flex items-center justify-center shrink-0 size-28px rounded-8px text-white/90 transition-[color,background-color,transform] duration-150 ease-out hover:text-white hover:bg-white/15 active:scale-95 outline-none focus-visible:ring-1 focus-visible:ring-white/60'
|
|
389
|
+
|
|
390
|
+
const timeClass = 'shrink-0 body-12-medium tabular-nums text-white'
|
|
391
|
+
|
|
392
|
+
const iconVariants = {
|
|
393
|
+
initial: { scale: 0.9, opacity: 0 },
|
|
394
|
+
animate: { scale: 1, opacity: 1 },
|
|
395
|
+
exit: { scale: 0.9, opacity: 0 },
|
|
396
|
+
} as const
|
|
397
|
+
|
|
398
|
+
const iconTransition = {
|
|
399
|
+
type: 'spring',
|
|
400
|
+
duration: 0.3,
|
|
401
|
+
bounce: 0,
|
|
402
|
+
} as const
|
|
403
|
+
</script>
|
|
404
|
+
|
|
405
|
+
<template>
|
|
406
|
+
<div
|
|
407
|
+
ref="container"
|
|
408
|
+
tabindex="0"
|
|
409
|
+
role="region"
|
|
410
|
+
:aria-label="text.region"
|
|
411
|
+
:class="cn(
|
|
412
|
+
'group/player relative w-full aspect-video bg-black rounded-16px overflow-hidden outline-none select-none focus-visible:ring-2 focus-visible:ring-white/60',
|
|
413
|
+
isFullscreen && 'rounded-none',
|
|
414
|
+
!areControlsVisible && 'cursor-none',
|
|
415
|
+
props.class,
|
|
416
|
+
)"
|
|
417
|
+
@pointermove="markActive"
|
|
418
|
+
@pointerdown="markActive"
|
|
419
|
+
@pointerleave="onPointerLeave"
|
|
420
|
+
@keydown="onKeydown"
|
|
421
|
+
@focusin="onFocusIn"
|
|
422
|
+
@focusout="onFocusOut"
|
|
423
|
+
>
|
|
424
|
+
<video
|
|
425
|
+
ref="video"
|
|
426
|
+
:poster="poster"
|
|
427
|
+
:crossorigin="crossorigin"
|
|
428
|
+
preload="metadata"
|
|
429
|
+
playsinline
|
|
430
|
+
:class="cn(
|
|
431
|
+
'absolute inset-0 size-full object-contain [&::cue]:bg-black/65 [&::cue]:text-white [&::cue]:text-16px',
|
|
432
|
+
areControlsVisible ? 'cursor-pointer' : 'cursor-none',
|
|
433
|
+
)"
|
|
434
|
+
@click="onSurfaceClick"
|
|
435
|
+
@dblclick="onSurfaceDoubleClick"
|
|
436
|
+
@play="emit('play')"
|
|
437
|
+
@pause="emit('pause')"
|
|
438
|
+
@ended="emit('ended')"
|
|
439
|
+
/>
|
|
440
|
+
|
|
441
|
+
<div
|
|
442
|
+
aria-hidden="true"
|
|
443
|
+
:class="cn(
|
|
444
|
+
'pointer-events-none absolute inset-x-0 bottom-0 h-120px bg-gradient-to-t from-black/60 to-transparent transition-opacity duration-300 ease-out',
|
|
445
|
+
areControlsVisible ? 'opacity-100' : 'opacity-0',
|
|
446
|
+
)"
|
|
447
|
+
/>
|
|
448
|
+
|
|
449
|
+
<div
|
|
450
|
+
:class="cn(
|
|
451
|
+
'absolute inset-x-0 bottom-0 flex items-center gap-12px px-24px pb-20px pt-32px text-white transition-opacity duration-300 ease-out max-sm:px-16px max-sm:pb-14px',
|
|
452
|
+
areControlsVisible ? 'opacity-100' : 'opacity-0 pointer-events-none',
|
|
453
|
+
)"
|
|
454
|
+
>
|
|
455
|
+
<div class="flex items-center gap-8px">
|
|
456
|
+
<button
|
|
457
|
+
type="button"
|
|
458
|
+
:aria-label="playing ? text.pause : text.play"
|
|
459
|
+
:class="buttonClass"
|
|
460
|
+
@click="togglePlay"
|
|
461
|
+
>
|
|
462
|
+
<AnimatePresence mode="popLayout" :initial="false">
|
|
463
|
+
<Motion
|
|
464
|
+
:key="playing ? 'pause' : 'play'"
|
|
465
|
+
as="span"
|
|
466
|
+
class="flex"
|
|
467
|
+
v-bind="iconVariants"
|
|
468
|
+
:transition="iconTransition"
|
|
469
|
+
>
|
|
470
|
+
<TelaIcon
|
|
471
|
+
:name="playing ? 'i-ph-pause-fill' : 'i-ph-play-fill'"
|
|
472
|
+
size="16px"
|
|
473
|
+
:class="!playing && '-ml-2px'"
|
|
474
|
+
/>
|
|
475
|
+
</Motion>
|
|
476
|
+
</AnimatePresence>
|
|
477
|
+
</button>
|
|
478
|
+
|
|
479
|
+
<div class="group/volume relative flex items-center">
|
|
480
|
+
<button
|
|
481
|
+
type="button"
|
|
482
|
+
:aria-label="muted ? text.unmute : text.mute"
|
|
483
|
+
:class="buttonClass"
|
|
484
|
+
@click="toggleMute"
|
|
485
|
+
>
|
|
486
|
+
<TelaIcon :name="volumeIcon" size="18px" />
|
|
487
|
+
</button>
|
|
488
|
+
|
|
489
|
+
<!-- Padded so the pointer can travel from the button to the slider without closing it -->
|
|
490
|
+
<div
|
|
491
|
+
:class="cn(
|
|
492
|
+
'absolute bottom-full left-1/2 -translate-x-1/2 pb-6px transition-opacity duration-150 ease-out',
|
|
493
|
+
isVolumeScrubbing ? 'opacity-100' : 'opacity-0 pointer-events-none group-hover/volume:opacity-100 group-hover/volume:pointer-events-auto group-focus-within/volume:opacity-100 group-focus-within/volume:pointer-events-auto',
|
|
494
|
+
)"
|
|
495
|
+
>
|
|
496
|
+
<div
|
|
497
|
+
ref="volumeBar"
|
|
498
|
+
role="slider"
|
|
499
|
+
:aria-label="text.volume"
|
|
500
|
+
aria-orientation="vertical"
|
|
501
|
+
tabindex="0"
|
|
502
|
+
:aria-valuemin="0"
|
|
503
|
+
:aria-valuemax="100"
|
|
504
|
+
:aria-valuenow="Math.round(effectiveVolume * 100)"
|
|
505
|
+
class="flex items-center justify-center w-28px h-88px py-10px rounded-8px bg-white/15 cursor-crosshair touch-none outline-none focus-visible:ring-1 focus-visible:ring-white/60"
|
|
506
|
+
@pointerdown="onVolumePointerDown"
|
|
507
|
+
@pointermove="onVolumePointerMove"
|
|
508
|
+
@pointerup="onVolumePointerUp"
|
|
509
|
+
@pointercancel="onVolumePointerUp"
|
|
510
|
+
@keydown="onVolumeKeydown"
|
|
511
|
+
>
|
|
512
|
+
<div class="relative w-2px h-full rounded-full bg-white/20 overflow-hidden">
|
|
513
|
+
<div class="absolute inset-x-0 bottom-0 bg-white" :style="{ height: `${effectiveVolume * 100}%` }" />
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
|
|
520
|
+
<div class="flex flex-1 min-w-0 items-center gap-8px">
|
|
521
|
+
<span :class="timeClass">{{ elapsedLabel }}</span>
|
|
522
|
+
|
|
523
|
+
<div
|
|
524
|
+
ref="progressBar"
|
|
525
|
+
role="slider"
|
|
526
|
+
:aria-label="text.seek"
|
|
527
|
+
:aria-valuemin="0"
|
|
528
|
+
:aria-valuemax="Math.round(duration)"
|
|
529
|
+
:aria-valuenow="Math.round(currentTime)"
|
|
530
|
+
:aria-valuetext="elapsedLabel"
|
|
531
|
+
tabindex="0"
|
|
532
|
+
class="relative flex flex-1 items-center h-20px rounded-4px cursor-crosshair touch-none outline-none focus-visible:ring-1 focus-visible:ring-white/60"
|
|
533
|
+
@pointerdown="onBarPointerDown"
|
|
534
|
+
@pointermove="onBarPointerMove"
|
|
535
|
+
@pointerup="onBarPointerUp"
|
|
536
|
+
@pointercancel="onBarPointerUp"
|
|
537
|
+
@pointerleave="onBarPointerLeave"
|
|
538
|
+
@keydown="onBarKeydown"
|
|
539
|
+
>
|
|
540
|
+
<div class="relative w-full h-4px rounded-full bg-white/20 overflow-hidden">
|
|
541
|
+
<div class="absolute inset-y-0 left-0 bg-white/25" :style="{ width: `${bufferedProgress * 100}%` }" />
|
|
542
|
+
<div class="absolute inset-y-0 left-0 bg-white" :style="{ width: `${progress * 100}%` }" />
|
|
543
|
+
</div>
|
|
544
|
+
|
|
545
|
+
<div
|
|
546
|
+
v-if="hoverRatio !== null && duration"
|
|
547
|
+
class="pointer-events-none absolute inset-y-0 -translate-x-1/2 flex flex-col items-center justify-end"
|
|
548
|
+
:style="{ left: `${hoverRatio * 100}%` }"
|
|
549
|
+
>
|
|
550
|
+
<span class="absolute bottom-full mb-6px whitespace-nowrap body-12-medium tabular-nums">
|
|
551
|
+
<span class="text-white">{{ hoverLabel }}</span>
|
|
552
|
+
<span class="text-white/50"> / {{ durationLabel }}</span>
|
|
553
|
+
</span>
|
|
554
|
+
<div class="w-1px h-full bg-white/80" />
|
|
555
|
+
</div>
|
|
556
|
+
</div>
|
|
557
|
+
|
|
558
|
+
<span :class="timeClass">{{ remainingLabel }}</span>
|
|
559
|
+
</div>
|
|
560
|
+
|
|
561
|
+
<div class="flex items-center gap-8px">
|
|
562
|
+
<button
|
|
563
|
+
type="button"
|
|
564
|
+
:aria-label="text.playbackSpeed"
|
|
565
|
+
:class="cn(buttonClass, 'min-w-52px body-12-medium tabular-nums max-sm:hidden')"
|
|
566
|
+
@click="cycleRate"
|
|
567
|
+
>
|
|
568
|
+
{{ rateLabel }}
|
|
569
|
+
</button>
|
|
570
|
+
|
|
571
|
+
<button
|
|
572
|
+
v-if="hasCaptions"
|
|
573
|
+
type="button"
|
|
574
|
+
:aria-label="areCaptionsOn ? text.hideCaptions : text.showCaptions"
|
|
575
|
+
:aria-pressed="areCaptionsOn"
|
|
576
|
+
:class="cn(buttonClass, !areCaptionsOn && 'opacity-60')"
|
|
577
|
+
@click="toggleCaptions"
|
|
578
|
+
>
|
|
579
|
+
<TelaIcon name="i-ph-subtitles" size="18px" />
|
|
580
|
+
</button>
|
|
581
|
+
|
|
582
|
+
<button
|
|
583
|
+
v-if="isMounted && supportsPictureInPicture"
|
|
584
|
+
type="button"
|
|
585
|
+
:aria-label="text.pictureInPicture"
|
|
586
|
+
:class="cn(buttonClass, 'max-sm:hidden')"
|
|
587
|
+
@click="togglePictureInPicture"
|
|
588
|
+
>
|
|
589
|
+
<TelaIcon name="i-ph-picture-in-picture" size="18px" />
|
|
590
|
+
</button>
|
|
591
|
+
|
|
592
|
+
<button
|
|
593
|
+
type="button"
|
|
594
|
+
:aria-label="isFullscreen ? text.exitFullscreen : text.fullscreen"
|
|
595
|
+
:class="buttonClass"
|
|
596
|
+
@click="toggleFullscreen"
|
|
597
|
+
>
|
|
598
|
+
<TelaIcon :name="isFullscreen ? 'i-ph-corners-in' : 'i-ph-corners-out'" size="18px" />
|
|
599
|
+
</button>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
</div>
|
|
603
|
+
</template>
|
package/docs/typography.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Typography tweaks for a more polished UI.
|
|
4
4
|
|
|
5
|
-
Tokens follow the pattern
|
|
5
|
+
Tokens follow the pattern `<family>-<size>-<weight>`: `heading-h2-semibold`, `body-14-medium`, `display-large-semibold`, `paragraph-16-regular`, `button-14-semibold`. Grouped below by category.
|
|
6
6
|
|
|
7
7
|
## Headings
|
|
8
8
|
|
|
@@ -17,9 +17,19 @@ Each heading level has three weight variants (`regular`, `medium`, `semibold`).
|
|
|
17
17
|
| `heading-h5-semibold` | 14px / 16px | Card titles, small headings | `body-12` |
|
|
18
18
|
| `heading-h6-semibold` | 12px / 14px | Smallest heading | `body-12` |
|
|
19
19
|
|
|
20
|
+
## Display
|
|
21
|
+
|
|
22
|
+
Marketing-scale titles for hero sections and empty states. Like headings, `semibold` resolves to 520.
|
|
23
|
+
|
|
24
|
+
| Token | Size / Line height | Letter spacing |
|
|
25
|
+
| ------------------------- | ------------------ | -------------- |
|
|
26
|
+
| `display-large-semibold` | 80px / 80px | -4.5px |
|
|
27
|
+
| `display-medium-semibold` | 48px / 48px | -2.2px |
|
|
28
|
+
| `display-small-semibold` | 40px / 40px | -2px |
|
|
29
|
+
|
|
20
30
|
## Body
|
|
21
31
|
|
|
22
|
-
Each body size has `regular` and `
|
|
32
|
+
Each body size has `regular`, `medium` and `semibold` variants — regular for reading text, medium for labels and emphasis.
|
|
23
33
|
|
|
24
34
|
| Token | Size / Line height | Usage | Pairs with |
|
|
25
35
|
| ------------------------------------ | ------------------ | ------------------------------ | -------------------- |
|
|
@@ -27,14 +37,40 @@ Each body size has `regular` and `medium` variants — regular for reading text,
|
|
|
27
37
|
| `body-16-regular` / `body-16-medium` | 16px / 20px | Primary reading text | `heading-h2` |
|
|
28
38
|
| `body-14-regular` / `body-14-medium` | 14px / 18px | Supporting text, descriptions | `heading-h3` / `h4` |
|
|
29
39
|
| `body-12-regular` / `body-12-medium` | 12px / 16px | Captions, labels, metadata | `heading-h5` / `h6` |
|
|
40
|
+
| `body-10-regular` / `body-10-semibold` | 10px / 12px | Dense metadata, tiny labels | — |
|
|
41
|
+
|
|
42
|
+
Swap the weight for `underline` (`body-14-underline`) to get the regular weight with a 3px-offset underline. Use it on a plain `<a>` for inline links, paired with a text color (`text-gray-900`).
|
|
43
|
+
|
|
44
|
+
## Uppercase
|
|
45
|
+
|
|
46
|
+
Append `-uppercase` to any body token (`body-<size>-<weight>-uppercase`) to render it uppercase with 0.05em tracking.
|
|
47
|
+
|
|
48
|
+
| Token | Size / Line height | Usage |
|
|
49
|
+
| ------------------------------------------------------ | ------------------ | --------------------------------------------------- |
|
|
50
|
+
| `body-12-semibold-uppercase` | 12px / 16px | Section eyebrows, group labels |
|
|
51
|
+
| `body-10-medium-uppercase` / `body-10-semibold-uppercase` | 10px / 12px | Column headers, compact labels |
|
|
52
|
+
| `body-9-medium-uppercase` | 9px / 16px | Uppercase micro-labels — timestamps, badges |
|
|
53
|
+
|
|
54
|
+
## Paragraph
|
|
55
|
+
|
|
56
|
+
Long-form reading with taller line height than `body-*`. Use `regular`.
|
|
57
|
+
|
|
58
|
+
| Token | Size / Line height | Usage |
|
|
59
|
+
| ------------------------- | ------------------ | ----------------------- |
|
|
60
|
+
| `paragraph-20-regular` | 20px / 32px | Lead paragraphs |
|
|
61
|
+
| `paragraph-16-regular` | 16px / 28px | Articles, documentation |
|
|
62
|
+
| `paragraph-14-regular` | 14px / 24px | Dense long-form text |
|
|
63
|
+
| `paragraph-quote-regular` | 20px / 28px | Pull quotes |
|
|
30
64
|
|
|
31
|
-
##
|
|
65
|
+
## Button
|
|
32
66
|
|
|
33
|
-
|
|
34
|
-
| ------------------------ | ------------------ | ----------------------------------------------------- |
|
|
35
|
-
| `body-caption-9-medium` | 9px / 16px | Uppercase micro-labels — timestamps, column headers |
|
|
67
|
+
Button labels: body sizes with button tracking, set in `semibold`. Use them for custom button-like controls; `TelaButton` handles its own label.
|
|
36
68
|
|
|
37
|
-
|
|
69
|
+
| Token | Size / Line height | Letter spacing |
|
|
70
|
+
| -------------------- | ------------------ | -------------- |
|
|
71
|
+
| `button-16-semibold` | 16px / 20px | -0.15px |
|
|
72
|
+
| `button-14-semibold` | 14px / 18px | -0.15px |
|
|
73
|
+
| `button-12-semibold` | 12px / 16px | 0px |
|
|
38
74
|
|
|
39
75
|
## Weights
|
|
40
76
|
|
package/package.json
CHANGED
package/unocss.config.ts
CHANGED
|
@@ -64,11 +64,18 @@ export default defineConfig({
|
|
|
64
64
|
['touch-hitbox', 'relative before:absolute before:left-1/2 before:top-1/2 before:block before:h-full before:min-h-44px before:w-full before:min-w-44px before:content-empty before:translate-x--50% before:translate-y--50%'],
|
|
65
65
|
[/u-ring-([\d.]+)/, ([_, v]) => `ring-${v}`],
|
|
66
66
|
// typography
|
|
67
|
-
[/(body|heading)
|
|
67
|
+
[/(body|heading|display|paragraph|button)-(h[1-6]|large|medium|small|quote|\d+)-(thin|regular|medium|semibold|bold|underline)(-uppercase)?/i, ([_, tag, size, weight, type]) => {
|
|
68
|
+
const isUppercase = type === '-uppercase'
|
|
69
|
+
const isUnderline = weight?.toLowerCase() === 'underline'
|
|
70
|
+
const decoration = `${isUppercase ? 'uppercase tracking-0.05em!' : ''} ${isUnderline ? 'underline underline-offset-3px' : ''}`
|
|
71
|
+
|
|
68
72
|
const [sizeFromToken] = Object
|
|
69
73
|
.entries(DT.fontSize)
|
|
70
74
|
.find(([sizeKey, [sizeValue]]) => {
|
|
71
|
-
|
|
75
|
+
// display, paragraph and button sizes are keyed by name (`display-large`, `paragraph-16`)
|
|
76
|
+
if (sizeKey.includes('-'))
|
|
77
|
+
return sizeKey === `${tag}-${size}`
|
|
78
|
+
else if (tag === 'body' && !sizeKey.includes('h'))
|
|
72
79
|
return sizeValue === `${size}px`
|
|
73
80
|
else if (tag === 'heading' && sizeKey.includes('h'))
|
|
74
81
|
return sizeValue === `${size}px` || sizeKey === size
|
|
@@ -77,19 +84,20 @@ export default defineConfig({
|
|
|
77
84
|
}) ?? []
|
|
78
85
|
|
|
79
86
|
if (!sizeFromToken) {
|
|
80
|
-
return `text-${size}px leading-1em font-${
|
|
87
|
+
return `text-${size}px leading-1em font-${isUnderline ? 'regular' : weight} ${decoration}`
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
const sizeFontSpecs = (DT.fontSize as any)[sizeFromToken] as [string, { 'line-height': string, 'letter-spacing': string }]
|
|
84
91
|
const sizeStyle = `text-size-[${sizeFontSpecs[0]}] leading-${sizeFontSpecs[1]['line-height']} tracking-[${sizeFontSpecs[1]['letter-spacing']}]`
|
|
85
|
-
const isCaption = type === '-caption'
|
|
86
92
|
|
|
87
|
-
// Headings use a lighter semibold than body text
|
|
88
|
-
const fontWeight =
|
|
89
|
-
? DT.fontWeight.
|
|
90
|
-
: weight
|
|
93
|
+
// Headings and display use a lighter semibold than body text
|
|
94
|
+
const fontWeight = isUnderline
|
|
95
|
+
? DT.fontWeight.regular
|
|
96
|
+
: ['heading', 'display'].includes(tag!.toLowerCase()) && weight?.toLowerCase() === 'semibold'
|
|
97
|
+
? DT.fontWeight.headingSemibold
|
|
98
|
+
: weight
|
|
91
99
|
|
|
92
|
-
return `${sizeStyle} font-${fontWeight} ${
|
|
100
|
+
return `${sizeStyle} font-${fontWeight} ${decoration}`
|
|
93
101
|
}],
|
|
94
102
|
// Catch for `text-(primary|secondary|tertiary|subtle|contrast|inverse|success|error|warning|pending)`
|
|
95
103
|
[/text-(primary|secondary|tertiary|subtle|contrast|inverse|success|error|warning|pending)/, ([_, v]) => `text-text-${v}`],
|
package/utils/design-tokens.ts
CHANGED
|
@@ -443,10 +443,57 @@ const FONT_SIZES: Record<string, [string, FontSizeMetrics]> = {
|
|
|
443
443
|
'line-height': '16px',
|
|
444
444
|
'letter-spacing': '0px',
|
|
445
445
|
}],
|
|
446
|
+
'2xs': ['10px', {
|
|
447
|
+
'line-height': '12px',
|
|
448
|
+
'letter-spacing': '0px',
|
|
449
|
+
}],
|
|
446
450
|
'xxs': ['9px', {
|
|
447
451
|
'line-height': '16px',
|
|
448
452
|
'letter-spacing': '1px',
|
|
449
453
|
}],
|
|
454
|
+
// display
|
|
455
|
+
'display-large': ['80px', {
|
|
456
|
+
'line-height': '80px',
|
|
457
|
+
'letter-spacing': '-4.5px',
|
|
458
|
+
}],
|
|
459
|
+
'display-medium': ['48px', {
|
|
460
|
+
'line-height': '48px',
|
|
461
|
+
'letter-spacing': '-2.2px',
|
|
462
|
+
}],
|
|
463
|
+
'display-small': ['40px', {
|
|
464
|
+
'line-height': '40px',
|
|
465
|
+
'letter-spacing': '-2px',
|
|
466
|
+
}],
|
|
467
|
+
// paragraph (long-form reading, taller line height than body)
|
|
468
|
+
'paragraph-20': ['20px', {
|
|
469
|
+
'line-height': '32px',
|
|
470
|
+
'letter-spacing': '-0.2px',
|
|
471
|
+
}],
|
|
472
|
+
'paragraph-16': ['16px', {
|
|
473
|
+
'line-height': '28px',
|
|
474
|
+
'letter-spacing': '-0.18px',
|
|
475
|
+
}],
|
|
476
|
+
'paragraph-14': ['14px', {
|
|
477
|
+
'line-height': '24px',
|
|
478
|
+
'letter-spacing': '-0.15px',
|
|
479
|
+
}],
|
|
480
|
+
'paragraph-quote': ['20px', {
|
|
481
|
+
'line-height': '28px',
|
|
482
|
+
'letter-spacing': '-0.2px',
|
|
483
|
+
}],
|
|
484
|
+
// button
|
|
485
|
+
'button-16': ['16px', {
|
|
486
|
+
'line-height': '20px',
|
|
487
|
+
'letter-spacing': '-0.15px',
|
|
488
|
+
}],
|
|
489
|
+
'button-14': ['14px', {
|
|
490
|
+
'line-height': '18px',
|
|
491
|
+
'letter-spacing': '-0.15px',
|
|
492
|
+
}],
|
|
493
|
+
'button-12': ['12px', {
|
|
494
|
+
'line-height': '16px',
|
|
495
|
+
'letter-spacing': '0px',
|
|
496
|
+
}],
|
|
450
497
|
}
|
|
451
498
|
|
|
452
499
|
export const DT = {
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
const props = defineProps<{
|
|
3
|
-
class?: string
|
|
4
|
-
href?: string
|
|
5
|
-
}>()
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<template>
|
|
9
|
-
<component
|
|
10
|
-
:is="props.href ? 'a' : 'span'"
|
|
11
|
-
:href="props.href"
|
|
12
|
-
:class="cn('text-gray-900 underline underline-offset-3px', props.class)"
|
|
13
|
-
>
|
|
14
|
-
<slot />
|
|
15
|
-
</component>
|
|
16
|
-
</template>
|