@meistrari/tela-build 1.104.0 → 1.106.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 +4 -0
- package/components/tela/animated/animated-number.vue +5 -52
- package/components/tela/chat/chat.mdx +4 -2
- package/components/tela/chat/icons/grok.vue +3 -0
- package/components/tela/chat/icons/kimi.vue +3 -0
- package/components/tela/onboarding-card/onboarding-card.mdx +122 -0
- package/components/tela/onboarding-card/onboarding-card.vue +194 -0
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
- package/types/index.ts +1 -0
- package/types/onboarding-card.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,14 @@ Latest updates and announcements.
|
|
|
4
4
|
|
|
5
5
|
## November 18, 2026
|
|
6
6
|
|
|
7
|
+
- [Chat → Model Selector](/templates/chat#model-selector) New provider icons `TelaChatIconsGrok` (xAI's Grok mark) and `TelaChatIconsKimi` (Moonshot AI's Kimi mark), drawn like `TelaChatIconsGemini`: one color (`currentColor`) on a 16px, 24-unit box, so Grok and Kimi models line up with the others in the model list.
|
|
8
|
+
- Icons: `i-custom:assistantAvatar` is the Tela Assistant avatar: the Tela logomark in white on a 48% black rounded tile, drawn at 16×16. The assistant onboarding card uses it.
|
|
9
|
+
- [Animated Number](/components/animated-number) spaces its digits with the font's own tabular figures (`tabular-nums`) instead of padding each digit to the width of the widest one, which left wide gaps around narrow digits such as `1`. Digits still keep a steady width while they change, and the spacing now follows the typeface at every text size.
|
|
7
10
|
- [Chat → Model Selector](/templates/chat#model-selector) A selected reasoning level is now also cleared on mount when the selected model has no reasoning levels (empty `reasoning-options`), and when the host sets `v-model:reasoning` to a level the current `reasoning-options` don't include. Before, it was kept in both cases, so the parent could still send it. New `reasoningLoading` prop: while it is `true`, the level is kept, so hosts that load the levels asynchronously don't lose a saved level.
|
|
8
11
|
|
|
9
12
|
## November 17, 2026
|
|
10
13
|
|
|
14
|
+
- [Onboarding Card](/components/onboarding-card) is a new component for short, step-by-step feature introductions: a 280px card with an illustration from the `#thumb` slot, a title and a description per step, step dots that double as navigation, and "Skip" with a next arrow, or "Got it" on the last step. The current step is bound with `v-model:step`, and `skip` and `finish` leave dismissing to the host. All copy comes from `steps` and `labels`. The card has no entrance of its own, so the host animates it in (the docs show a `Motion` with `as-child`), and each step advances by itself after `duration` (default 5000ms, `0` turns it off) while the current dot fills like a progress bar. Hovering or keyboard focus pauses it, and the last step waits for the user. Between steps the illustration fades out and the next one remounts, so `#thumb` content can play its own entrance. Going to the last step, "Skip" fades out and the arrow widens into the finish button. Under `prefers-reduced-motion`, only the progress fill still moves.
|
|
11
15
|
- [Chat → Model Selector](/templates/chat#model-selector) When `reasoning-options` changes and no longer includes the selected level, `v-model:reasoning` is cleared, so the menu and the parent agree.
|
|
12
16
|
- [Combobox](/components/combobox) Table layout matches the design specs: group headings and the Cost / Input / Output headers are 10px semibold, provider icons are 15px inside their 20px box, and token limits are 11px uppercase on every row, in primary text on the selected and highlighted rows. The trigger drops the `Claude ` prefix (`Claude Opus 5` reads `Opus 5`).
|
|
13
17
|
- [Combobox](/components/combobox) Options that carry `cost` or token limits render as a table: a 360px panel, the first group heading carries `Cost` / `Input` / `Output` columns, and each row shows the icon, the label (12px semibold), the cost as five `$` and the input and output limits in fixed columns. Descriptions and the Multimodal badge are not shown in this layout; search still matches descriptions. The search icon and headings line up at 16px, and the tabs row is not shown (option `tabs` are ignored in this layout). The `Input` / `Output` headers reuse `labelInputMax` / `labelOutputMax` (defaults now `Input` / `Output`), and the new `labelCost` prop translates `Cost`.
|
|
@@ -14,13 +14,9 @@ const LEAVE_ACTIVE = '!absolute left-0 top-0 pointer-events-none transition-[tra
|
|
|
14
14
|
const LEAVE_TO = 'opacity-0 [filter:blur(0.12em)] [transform:translateY(-0.45em)_scale(0.8)]'
|
|
15
15
|
const MOVE = 'transition-[transform,opacity,filter] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]'
|
|
16
16
|
const WIDTH_ANIMATION = { duration: 280, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' }
|
|
17
|
-
const DIGITS = [...'0123456789']
|
|
18
|
-
const DIGIT_TIGHTENING = 0.01
|
|
19
|
-
const DIGIT_PROBE = 'absolute invisible'
|
|
20
17
|
|
|
21
18
|
const root = ref<HTMLElement | null>(null)
|
|
22
19
|
const reducedMotion = ref(false)
|
|
23
|
-
const digitMargins = ref<Record<string, string>>({})
|
|
24
20
|
let widthAnimation: Animation | undefined
|
|
25
21
|
let integerDigits: { id: number, text: string }[] = []
|
|
26
22
|
let nextDigitId = 0
|
|
@@ -56,7 +52,7 @@ const cells = computed(() => {
|
|
|
56
52
|
let before = props.prefix ?? ''
|
|
57
53
|
let after = ''
|
|
58
54
|
|
|
59
|
-
const numberCells: { key: string, text: string
|
|
55
|
+
const numberCells: { key: string, text: string }[] = []
|
|
60
56
|
|
|
61
57
|
for (const part of parts) {
|
|
62
58
|
if (part.type === 'integer') {
|
|
@@ -64,12 +60,12 @@ const cells = computed(() => {
|
|
|
64
60
|
const digit = digits[digitIndex++]
|
|
65
61
|
|
|
66
62
|
if (digit)
|
|
67
|
-
numberCells.push({ key: `integer-${digit.id}`, text: digit.text
|
|
63
|
+
numberCells.push({ key: `integer-${digit.id}`, text: digit.text })
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
else if (part.type === 'fraction') {
|
|
71
67
|
for (const digit of part.value)
|
|
72
|
-
numberCells.push({ key: `fraction-${fractionIndex++}`, text: digit
|
|
68
|
+
numberCells.push({ key: `fraction-${fractionIndex++}`, text: digit })
|
|
73
69
|
}
|
|
74
70
|
else if (part.type === 'group') {
|
|
75
71
|
numberCells.push({ key: `group-${groupIndex++}`, text: part.value })
|
|
@@ -94,46 +90,7 @@ const cells = computed(() => {
|
|
|
94
90
|
]
|
|
95
91
|
})
|
|
96
92
|
|
|
97
|
-
function measureDigits() {
|
|
98
|
-
const element = root.value
|
|
99
|
-
|
|
100
|
-
if (!element)
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
const probes = DIGITS.map((digit) => {
|
|
104
|
-
const probe = document.createElement('span')
|
|
105
|
-
|
|
106
|
-
probe.className = DIGIT_PROBE
|
|
107
|
-
probe.textContent = digit
|
|
108
|
-
|
|
109
|
-
return probe
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
element.append(...probes)
|
|
113
|
-
|
|
114
|
-
const widths = probes.map(probe => Number.parseFloat(getComputedStyle(probe).width))
|
|
115
|
-
|
|
116
|
-
const fontSize = Number.parseFloat(getComputedStyle(element).fontSize)
|
|
117
|
-
|
|
118
|
-
for (const probe of probes)
|
|
119
|
-
probe.remove()
|
|
120
|
-
|
|
121
|
-
const widest = Math.max(...widths)
|
|
122
|
-
|
|
123
|
-
if (!(widest > 0) || !(fontSize > 0))
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
digitMargins.value = Object.fromEntries(DIGITS.map((digit, index) => [digit, `${(widest - (widths[index] ?? widest)) / 2 / fontSize - DIGIT_TIGHTENING}em`]))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
onMounted(() => {
|
|
130
|
-
measureDigits()
|
|
131
|
-
document.fonts?.ready.then(measureDigits)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
93
|
watch(text, async () => {
|
|
135
|
-
measureDigits()
|
|
136
|
-
|
|
137
94
|
reducedMotion.value = window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
138
95
|
|
|
139
96
|
const element = root.value
|
|
@@ -166,7 +123,7 @@ function pinLeavingCell(element: Element) {
|
|
|
166
123
|
ref="root"
|
|
167
124
|
role="img"
|
|
168
125
|
:aria-label="text"
|
|
169
|
-
class="relative inline-block whitespace-pre"
|
|
126
|
+
class="relative inline-block whitespace-pre tabular-nums"
|
|
170
127
|
>
|
|
171
128
|
<TransitionGroup
|
|
172
129
|
tag="span"
|
|
@@ -187,11 +144,7 @@ function pinLeavingCell(element: Element) {
|
|
|
187
144
|
:leave-active-class="LEAVE_ACTIVE"
|
|
188
145
|
:leave-to-class="LEAVE_TO"
|
|
189
146
|
>
|
|
190
|
-
<span
|
|
191
|
-
:key="cell.text"
|
|
192
|
-
class="inline-block"
|
|
193
|
-
:style="cell.isDigit ? { marginInline: digitMargins[cell.text] } : undefined"
|
|
194
|
-
>{{ cell.text }}</span>
|
|
147
|
+
<span :key="cell.text" class="inline-block">{{ cell.text }}</span>
|
|
195
148
|
</Transition>
|
|
196
149
|
</span>
|
|
197
150
|
</TransitionGroup>
|
|
@@ -1421,7 +1421,7 @@ An avatar beside a message, and the provider icons used by the model selector.
|
|
|
1421
1421
|
|
|
1422
1422
|
```vue
|
|
1423
1423
|
<script setup lang="ts">
|
|
1424
|
-
import { TelaChatIconsAnthropic, TelaChatIconsGemini, TelaChatIconsOpenai } from '#components'
|
|
1424
|
+
import { TelaChatIconsAnthropic, TelaChatIconsGemini, TelaChatIconsGrok, TelaChatIconsKimi, TelaChatIconsOpenai } from '#components'
|
|
1425
1425
|
</script>
|
|
1426
1426
|
|
|
1427
1427
|
<template>
|
|
@@ -1435,6 +1435,8 @@ import { TelaChatIconsAnthropic, TelaChatIconsGemini, TelaChatIconsOpenai } from
|
|
|
1435
1435
|
<TelaChatIconsAnthropic class="size-20px" />
|
|
1436
1436
|
<TelaChatIconsOpenai class="size-20px" />
|
|
1437
1437
|
<TelaChatIconsGemini class="size-20px" />
|
|
1438
|
+
<TelaChatIconsGrok class="size-20px" />
|
|
1439
|
+
<TelaChatIconsKimi class="size-20px" />
|
|
1438
1440
|
</div>
|
|
1439
1441
|
</div>
|
|
1440
1442
|
</template>
|
|
@@ -1480,7 +1482,7 @@ import { TelaChatIconsAnthropic, TelaChatIconsGemini, TelaChatIconsOpenai } from
|
|
|
1480
1482
|
| `TelaChatStopRunButton` | Replaces the prompt input while a turn runs; centered pill that emits `stop`. |
|
|
1481
1483
|
| `TelaChatAnimateEnter` | Enter/exit preset (fade, slide, slight scale) for a surface that comes and goes; when it wraps the prompt input or stop button the body docks the wrapper. Pair with `AnimatePresence`. |
|
|
1482
1484
|
| `TelaChatTextShimmer` | Shimmering text, used for thinking/loading indicators. |
|
|
1483
|
-
| `TelaChatIconsAnthropic` / `TelaChatIconsOpenai` / `TelaChatIconsGemini` | Provider icons for model options. |
|
|
1485
|
+
| `TelaChatIconsAnthropic` / `TelaChatIconsOpenai` / `TelaChatIconsGemini` / `TelaChatIconsGrok` / `TelaChatIconsKimi` | Provider icons for model options. |
|
|
1484
1486
|
| `TelaChatPoweredByTela` | "Powered by" + Tela wordmark footer. |
|
|
1485
1487
|
|
|
1486
1488
|
## Anatomy
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg width="16" height="16" fill="currentColor" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815" /></svg>
|
|
3
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg width="16" height="16" fill="currentColor" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z" /><path d="M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z" /></svg>
|
|
3
|
+
</template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# TelaOnboardingCard
|
|
2
|
+
|
|
3
|
+
A 280px card that walks the user through a short feature introduction, one step at a time. Each step has an illustration on a gray band, a title and a description. The footer shows one dot per step, with the current one stretched into a pill, and the actions: "Skip" and a next arrow on every step but the last, which shows "Got it" instead.
|
|
4
|
+
|
|
5
|
+
The card holds no copy of its own. Pass the text through `steps` and the button labels through `labels`, which default to English. The illustration comes from the `#thumb` slot, which receives the current `step` and its `index`, so each feature supplies its own visuals.
|
|
6
|
+
|
|
7
|
+
The current step is bound with `v-model:step` (0-based). The next arrow and the dots update it, so a dot also takes the user back to an earlier step. `skip` and `finish` only emit: the host decides what dismissing means, such as remembering that the user has seen it.
|
|
8
|
+
|
|
9
|
+
### Motion
|
|
10
|
+
|
|
11
|
+
- The card has no entrance of its own, so the host decides how it appears. To rise it in, wrap it in a `Motion` with `as-child` (see [With an Entrance](#with-an-entrance)).
|
|
12
|
+
- Each step advances by itself after `duration` milliseconds (default `5000`), while the current dot's pill fills from left to right. On the last step the pill fills and stays, without finishing. Hovering the card or focusing it with the keyboard pauses the timer. Moving to another step, by clicking or by the timer, starts the new step's timer from zero. `:duration="0"` turns auto-advance off and shows the pill full.
|
|
13
|
+
- Between steps the illustration fades out over 150ms, the band stays empty for another 150ms, and then the next step's `#thumb` content mounts. Content in the slot can run its own CSS entrance animation on mount, and it runs again each time the user comes back to that step. The title and description crossfade over 200ms.
|
|
14
|
+
- Going to the last step, "Skip" fades out and the arrow button widens to the left into the finish button. Going back reverses it.
|
|
15
|
+
- Under `prefers-reduced-motion` the fades and morph are dropped. The pill still fills, because it shows the time left before the step advances.
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script setup>
|
|
23
|
+
import { ref } from 'vue'
|
|
24
|
+
|
|
25
|
+
const step = ref(0)
|
|
26
|
+
|
|
27
|
+
const steps = [
|
|
28
|
+
{ title: 'Meet the command bar', description: 'Press Cmd K anywhere to search, run actions or jump to a page.' },
|
|
29
|
+
{ title: 'Pin what you use', description: 'Pinned items stay at the top of the bar, in the order you choose.' },
|
|
30
|
+
{ title: 'Make it yours', description: 'Change shortcuts and hide actions in Settings, under Command bar.' },
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
const icons = ['i-ph-command', 'i-ph-push-pin', 'i-ph-sliders-horizontal']
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<TelaOnboardingCard v-model:step="step" :steps="steps" @skip="step = 0" @finish="step = 0">
|
|
38
|
+
<template #thumb="{ index }">
|
|
39
|
+
<div class="flex items-center justify-center size-56px rounded-12px bg">
|
|
40
|
+
<TelaIcon :name="icons[index]" size="24px" class="text-icon" />
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
</TelaOnboardingCard>
|
|
44
|
+
</template>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Without Auto-Advance
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<TelaOnboardingCard
|
|
51
|
+
:duration="0"
|
|
52
|
+
:steps="[
|
|
53
|
+
{ title: 'Drafts are private', description: 'Only you see a draft until you publish it to the project.' },
|
|
54
|
+
{ title: 'Publish when ready', description: 'Publishing makes the draft visible to everyone in the project.' },
|
|
55
|
+
]"
|
|
56
|
+
/>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### With an Entrance
|
|
60
|
+
|
|
61
|
+
The card rises by its own height and fades in over 300ms. `as-child` puts the motion on the card's own `section`, without a wrapper element, and `MotionConfig` with `reduced-motion="user"` drops the rise under `prefers-reduced-motion`.
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<template>
|
|
65
|
+
<MotionConfig reduced-motion="user">
|
|
66
|
+
<Motion
|
|
67
|
+
v-if="open"
|
|
68
|
+
as-child
|
|
69
|
+
:initial="{ opacity: 0, scale: 0.9, y: '100%' }"
|
|
70
|
+
:animate="{ opacity: 1, scale: 1, y: 0 }"
|
|
71
|
+
:transition="{ duration: 0.3, ease: [0.23, 1, 0.32, 1] }"
|
|
72
|
+
>
|
|
73
|
+
<TelaOnboardingCard :steps="steps" @skip="open = false" @finish="open = false" />
|
|
74
|
+
</Motion>
|
|
75
|
+
</MotionConfig>
|
|
76
|
+
</template>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Translated Labels
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<TelaOnboardingCard
|
|
83
|
+
:steps="[{ title: 'Conheça o Tela Assistant', description: 'Peça para ele construir ou resolver tarefas rápido.' }]"
|
|
84
|
+
:labels="{ skip: 'Pular', next: 'Próximo', finish: 'Entendi', goToStep: (step, total) => `Etapa ${step} de ${total}` }"
|
|
85
|
+
/>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Props
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
type OnboardingCardProps = {
|
|
92
|
+
steps: { title: string, description: string }[]
|
|
93
|
+
duration?: number | false // default 5000
|
|
94
|
+
labels?: Partial<{
|
|
95
|
+
skip: string
|
|
96
|
+
next: string
|
|
97
|
+
finish: string
|
|
98
|
+
goToStep: (step: number, total: number) => string
|
|
99
|
+
}>
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Model
|
|
104
|
+
|
|
105
|
+
- `v-model:step` - The index of the current step, starting at `0`. Defaults to `0`.
|
|
106
|
+
|
|
107
|
+
## Events
|
|
108
|
+
|
|
109
|
+
- `skip` - The user clicked "Skip". Receives the index of the step they were on.
|
|
110
|
+
- `finish` - The user clicked "Got it" on the last step.
|
|
111
|
+
|
|
112
|
+
## Slots
|
|
113
|
+
|
|
114
|
+
- `thumb` - The illustration in the 128px gray band at the top, centered. Receives `{ step, index }`. It remounts on every step change, so CSS entrance animations on its content play each time.
|
|
115
|
+
|
|
116
|
+
## Accessibility
|
|
117
|
+
|
|
118
|
+
- The card is a `section` labelled by the current step's title, which is announced when the step changes
|
|
119
|
+
- Each dot is a button named by `labels.goToStep`, and the current one has `aria-current="step"`
|
|
120
|
+
- The illustration is `aria-hidden`, so it should not carry information the title and description lack
|
|
121
|
+
- Hovering the card or focusing it with the keyboard pauses auto-advance
|
|
122
|
+
- Under `prefers-reduced-motion` only the progress pill keeps moving
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AnimationPlaybackControls } from 'motion-v'
|
|
3
|
+
import { animate } from 'motion-v'
|
|
4
|
+
import type { TelaOnboardingCardLabels, TelaOnboardingCardStep } from '../../../types/onboarding-card'
|
|
5
|
+
import { buttonVariants } from '../button/button-variants'
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(defineProps<{
|
|
8
|
+
steps: TelaOnboardingCardStep[]
|
|
9
|
+
labels?: Partial<TelaOnboardingCardLabels>
|
|
10
|
+
/** Milliseconds each step stays before advancing to the next. `0` or `false` turns auto-advance off. */
|
|
11
|
+
duration?: number | false
|
|
12
|
+
}>(), {
|
|
13
|
+
labels: () => ({}),
|
|
14
|
+
duration: 5000,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits<{
|
|
18
|
+
skip: [step: number]
|
|
19
|
+
finish: []
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
defineSlots<{
|
|
23
|
+
thumb?: (props: { step: TelaOnboardingCardStep, index: number }) => any
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const step = defineModel<number>('step', { default: 0 })
|
|
27
|
+
|
|
28
|
+
const copy = computed<TelaOnboardingCardLabels>(() => ({
|
|
29
|
+
skip: 'Skip',
|
|
30
|
+
next: 'Next',
|
|
31
|
+
finish: 'Got it',
|
|
32
|
+
goToStep: (current, total) => `Step ${current} of ${total}`,
|
|
33
|
+
...props.labels,
|
|
34
|
+
}))
|
|
35
|
+
|
|
36
|
+
const titleId = useId()
|
|
37
|
+
const index = computed(() => Math.min(Math.max(step.value, 0), props.steps.length - 1))
|
|
38
|
+
const current = computed(() => props.steps[index.value])
|
|
39
|
+
const isLast = computed(() => index.value === props.steps.length - 1)
|
|
40
|
+
|
|
41
|
+
const EASE_OUT = [0.23, 1, 0.32, 1] as const
|
|
42
|
+
|
|
43
|
+
const reducedMotion = usePreferredReducedMotion()
|
|
44
|
+
const seconds = (value: number) => reducedMotion.value === 'reduce' ? 0 : value
|
|
45
|
+
|
|
46
|
+
const thumbExit = computed(() => ({
|
|
47
|
+
opacity: [1, 0, 0],
|
|
48
|
+
transition: { duration: seconds(0.3), times: [0, 0.5, 1], ease: EASE_OUT },
|
|
49
|
+
}))
|
|
50
|
+
const fade = computed(() => ({
|
|
51
|
+
initial: { opacity: 0 },
|
|
52
|
+
animate: { opacity: 1 },
|
|
53
|
+
exit: { opacity: 0 },
|
|
54
|
+
transition: { duration: seconds(0.2), ease: EASE_OUT },
|
|
55
|
+
}))
|
|
56
|
+
|
|
57
|
+
const hovered = ref(false)
|
|
58
|
+
const focused = ref(false)
|
|
59
|
+
const paused = computed(() => hovered.value || focused.value)
|
|
60
|
+
|
|
61
|
+
const dots = ref<HTMLElement | null>(null)
|
|
62
|
+
let progress: AnimationPlaybackControls | undefined
|
|
63
|
+
|
|
64
|
+
watch([index, () => props.duration, dots], ([, duration]) => {
|
|
65
|
+
progress?.stop()
|
|
66
|
+
progress = undefined
|
|
67
|
+
|
|
68
|
+
const el = dots.value?.querySelector('[data-progress]')
|
|
69
|
+
|
|
70
|
+
if (!el || !duration)
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
const run = animate(el, { scaleX: [0, 1] }, { duration: duration / 1000, ease: 'linear' })
|
|
74
|
+
|
|
75
|
+
progress = run
|
|
76
|
+
|
|
77
|
+
if (paused.value)
|
|
78
|
+
run.pause()
|
|
79
|
+
|
|
80
|
+
run.then(() => {
|
|
81
|
+
if (progress === run)
|
|
82
|
+
next()
|
|
83
|
+
})
|
|
84
|
+
}, { flush: 'post' })
|
|
85
|
+
|
|
86
|
+
watch(paused, isPaused => isPaused ? progress?.pause() : progress?.play())
|
|
87
|
+
onBeforeUnmount(() => progress?.stop())
|
|
88
|
+
|
|
89
|
+
function onFocusIn(event: FocusEvent) {
|
|
90
|
+
focused.value = event.target instanceof Element && event.target.matches(':focus-visible')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function next() {
|
|
94
|
+
if (!isLast.value)
|
|
95
|
+
step.value = index.value + 1
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const finishLabel = ref<HTMLElement | null>(null)
|
|
99
|
+
const { width: finishLabelWidth } = useElementSize(finishLabel)
|
|
100
|
+
const actionWidth = computed(() => isLast.value ? `${finishLabelWidth.value + 24}px` : '32px')
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<template>
|
|
104
|
+
<section
|
|
105
|
+
v-if="current"
|
|
106
|
+
:aria-labelledby="`${titleId}-${index}`"
|
|
107
|
+
flex="~ col" w-280px overflow-hidden bg rounded-12px border-0.5px
|
|
108
|
+
class="border-black/12 [box-shadow:0_4px_16px_0_rgba(85,91,98,0.14)]"
|
|
109
|
+
@mouseenter="hovered = true"
|
|
110
|
+
@mouseleave="hovered = false"
|
|
111
|
+
@focusin="onFocusIn"
|
|
112
|
+
@focusout="focused = false"
|
|
113
|
+
>
|
|
114
|
+
<div h-128px bg-lowered aria-hidden="true">
|
|
115
|
+
<AnimatePresence mode="popLayout" :initial="false">
|
|
116
|
+
<Motion :key="index" flex items-center justify-center h-full :exit="thumbExit">
|
|
117
|
+
<slot name="thumb" :step="current" :index="index" />
|
|
118
|
+
</Motion>
|
|
119
|
+
</AnimatePresence>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div grid px-16px pt-12px aria-live="polite">
|
|
123
|
+
<AnimatePresence :initial="false">
|
|
124
|
+
<Motion :key="index" flex="~ col" gap-2px class="[grid-area:1/1]" v-bind="fade">
|
|
125
|
+
<h3 :id="`${titleId}-${index}`" text-13px leading-16px tracking--0.15px font-semibold text-primary text-balance>
|
|
126
|
+
{{ current.title }}
|
|
127
|
+
</h3>
|
|
128
|
+
<p text-13px leading-16px tracking--0.15px text-secondary text-balance>
|
|
129
|
+
{{ current.description }}
|
|
130
|
+
</p>
|
|
131
|
+
</Motion>
|
|
132
|
+
</AnimatePresence>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div flex items-center justify-between gap-8px pl-16px pr-8px py-8px>
|
|
136
|
+
<div ref="dots" flex items-center>
|
|
137
|
+
<button
|
|
138
|
+
v-for="(_, dot) in steps"
|
|
139
|
+
:key="dot"
|
|
140
|
+
type="button"
|
|
141
|
+
flex px-2px py-6px cursor-pointer outline-none rounded-full focus-visible:ring-0.5px focus-visible:ring-cyan-600
|
|
142
|
+
:aria-label="copy.goToStep(dot + 1, steps.length)"
|
|
143
|
+
:aria-current="dot === index ? 'step' : undefined"
|
|
144
|
+
@click="step = dot"
|
|
145
|
+
>
|
|
146
|
+
<span
|
|
147
|
+
relative h-4px rounded-full overflow-hidden bg-lowered duration-200 motion-reduce:transition-none
|
|
148
|
+
class="transition-[width] ease-[cubic-bezier(0.23,1,0.32,1)]"
|
|
149
|
+
:class="dot === index ? 'w-20px' : 'w-4px'"
|
|
150
|
+
>
|
|
151
|
+
<span
|
|
152
|
+
v-if="dot === index"
|
|
153
|
+
data-progress
|
|
154
|
+
absolute inset-0 bg-stone-600 origin-left
|
|
155
|
+
/>
|
|
156
|
+
</span>
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div relative flex>
|
|
161
|
+
<AnimatePresence :initial="false">
|
|
162
|
+
<Motion v-if="!isLast" as-child v-bind="fade">
|
|
163
|
+
<TelaButton variant="ghost" absolute right-36px @click="emit('skip', index)">
|
|
164
|
+
{{ copy.skip }}
|
|
165
|
+
</TelaButton>
|
|
166
|
+
</Motion>
|
|
167
|
+
</AnimatePresence>
|
|
168
|
+
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
relative h-32px rounded-10px overflow-hidden cursor-pointer
|
|
172
|
+
:class="cn(buttonVariants({ variant: 'primary' }), 'transition-[width,background-color] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none')"
|
|
173
|
+
:style="{ width: actionWidth }"
|
|
174
|
+
:aria-label="isLast ? undefined : copy.next"
|
|
175
|
+
@click="isLast ? emit('finish') : next()"
|
|
176
|
+
>
|
|
177
|
+
<TelaIcon
|
|
178
|
+
name="i-ph-caret-right-bold"
|
|
179
|
+
size="md"
|
|
180
|
+
absolute top-7px right-7px transition-opacity duration-150 motion-reduce:transition-none
|
|
181
|
+
:class="isLast && 'opacity-0'"
|
|
182
|
+
/>
|
|
183
|
+
<span
|
|
184
|
+
ref="finishLabel"
|
|
185
|
+
absolute top-7px right-12px button-14-semibold whitespace-nowrap transition-opacity duration-150 motion-reduce:transition-none
|
|
186
|
+
:class="!isLast && 'opacity-0'"
|
|
187
|
+
>
|
|
188
|
+
{{ copy.finish }}
|
|
189
|
+
</span>
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</section>
|
|
194
|
+
</template>
|
package/nuxt.config.ts
CHANGED
|
@@ -70,6 +70,7 @@ export default defineNuxtConfig({
|
|
|
70
70
|
canvas: '<svg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="12" height="2" rx="1" fill="#3562E7"/><rect y="4" width="12" height="2" rx="1" fill="#3562E7"/><rect y="8" width="7" height="2" rx="1" fill="#3562E7"/></svg>',
|
|
71
71
|
openai: '<svg viewBox="2.5 2.5 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M18.8545 10.5474C19.0334 10.0086 19.0953 9.43791 19.036 8.87334C18.9767 8.30877 18.7977 7.76335 18.5107 7.27352C18.0854 6.53313 17.4359 5.94695 16.6559 5.59949C15.876 5.25202 15.0058 5.16122 14.1709 5.34018C13.6966 4.81256 13.0917 4.41903 12.4172 4.19912C11.7426 3.97922 11.0221 3.94068 10.3279 4.08737C9.63377 4.23406 8.99043 4.56082 8.46252 5.03484C7.93461 5.50885 7.54072 6.11343 7.32041 6.78785C6.76419 6.90191 6.23872 7.13337 5.77912 7.46678C5.31951 7.80018 4.93637 8.22784 4.65528 8.72118C4.2253 9.46033 4.04153 10.3171 4.13054 11.1675C4.21955 12.018 4.57672 12.8181 5.15041 13.4522C4.97086 13.9907 4.90836 14.5614 4.96711 15.1259C5.02586 15.6905 5.2045 16.2361 5.49108 16.726C5.91697 17.4667 6.56703 18.053 7.34755 18.4005C8.12808 18.7479 8.99877 18.8386 9.83415 18.6594C10.211 19.0838 10.674 19.4229 11.1924 19.6541C11.7107 19.8852 12.2724 20.0032 12.8399 20C13.6956 20.0008 14.5295 19.7296 15.2211 19.2256C15.9127 18.7217 16.4263 18.011 16.6877 17.1961C17.2439 17.0819 17.7693 16.8503 18.2289 16.5169C18.6885 16.1835 19.0716 15.7559 19.3529 15.2627C19.7778 14.5247 19.9584 13.6711 19.8689 12.8242C19.7794 11.9773 19.4243 11.1803 18.8545 10.5474ZM12.8399 18.9528C12.139 18.9539 11.4601 18.7082 10.9223 18.2589L11.0169 18.2053L14.2024 16.3665C14.2817 16.32 14.3475 16.2537 14.3934 16.1741C14.4393 16.0944 14.4637 16.0042 14.4642 15.9123V11.421L15.8109 12.2001C15.8175 12.2035 15.8233 12.2084 15.8277 12.2144C15.8321 12.2204 15.835 12.2274 15.8362 12.2348V15.9565C15.8345 16.7507 15.5183 17.5118 14.9567 18.0734C14.3952 18.6349 13.634 18.9511 12.8399 18.9528ZM6.39941 16.2025C6.04793 15.5956 5.92173 14.8842 6.04301 14.1934L6.13768 14.2502L9.32635 16.089C9.40525 16.1353 9.49507 16.1597 9.58655 16.1597C9.67803 16.1597 9.76785 16.1353 9.84675 16.089L13.7419 13.8433V15.3982C13.7416 15.4063 13.7394 15.4142 13.7356 15.4213C13.7317 15.4284 13.7264 15.4345 13.7198 15.4392L10.4933 17.3001C9.8047 17.6968 8.98685 17.804 8.21929 17.5982C7.45173 17.3924 6.7972 16.8905 6.39941 16.2025ZM5.56048 9.26372C5.9144 8.6529 6.47304 8.187 7.13748 7.94852V11.7333C7.13628 11.8248 7.15964 11.9148 7.20513 11.9942C7.25062 12.0735 7.31656 12.1392 7.39608 12.1843L11.2723 14.4205L9.92561 15.1995C9.91833 15.2034 9.9102 15.2054 9.90195 15.2054C9.8937 15.2054 9.88557 15.2034 9.87828 15.1995L6.65808 13.3418C5.97079 12.9435 5.46938 12.2889 5.26366 11.5216C5.05794 10.7543 5.16467 9.93676 5.56048 9.24798V9.26372ZM16.6247 11.8342L12.7358 9.57598L14.0794 8.79998C14.0867 8.79611 14.0948 8.79409 14.1031 8.79409C14.1113 8.79409 14.1195 8.79611 14.1267 8.79998L17.3469 10.6608C17.8393 10.945 18.2407 11.3633 18.5043 11.8669C18.7678 12.3706 18.8826 12.9388 18.8354 13.5053C18.7881 14.0718 18.5806 14.6131 18.2372 15.0661C17.8938 15.5191 17.4286 15.8651 16.8959 16.0637V12.2788C16.8932 12.1876 16.8667 12.0986 16.8191 12.0206C16.7715 11.9427 16.7046 11.8785 16.6247 11.8342ZM17.9651 9.81885L17.8705 9.76205L14.6881 7.90752C14.6088 7.86093 14.5184 7.83637 14.4263 7.83637C14.3343 7.83637 14.2439 7.86093 14.1645 7.90752L10.2726 10.1531V8.59825C10.2718 8.59034 10.2731 8.58236 10.2764 8.57515C10.2798 8.56793 10.285 8.56175 10.2915 8.55725L13.5117 6.69952C14.0053 6.4152 14.5696 6.27728 15.1386 6.30189C15.7077 6.3265 16.258 6.51263 16.7251 6.83851C17.1923 7.16438 17.557 7.61653 17.7766 8.14207C17.9962 8.66761 18.0616 9.24482 17.9652 9.80618L17.9651 9.81885ZM9.53761 12.5753L8.19095 11.7994C8.18421 11.7954 8.17845 11.7899 8.17407 11.7834C8.16969 11.7768 8.16681 11.7694 8.16561 11.7616V8.04945C8.16636 7.47997 8.3292 6.92246 8.63512 6.44212C8.94103 5.96177 9.37736 5.57844 9.89311 5.33694C10.4089 5.09544 10.9827 5.00576 11.5475 5.07837C12.1124 5.15098 12.6449 5.38289 13.0827 5.74698L12.9881 5.80065L9.80261 7.63932C9.72333 7.68582 9.65751 7.75214 9.61161 7.83177C9.56571 7.9114 9.54131 8.0016 9.54081 8.09352L9.53761 12.5753ZM10.2693 10.9984L12.004 9.99852L13.7419 10.9984V12.998L12.0103 13.9978L10.2725 12.998L10.2693 10.9984Z"/></svg>',
|
|
72
72
|
anthropic: '<svg viewBox="-2 -1 28 26" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M13.827 3.52h3.603L24 20h-3.603l-6.57-16.48zM6.396 3.52L0 20h3.603l1.351-3.384h6.827l1.351 3.384h3.603L10.119 3.52H6.396zm.663 10.155 2.33-5.879 2.33 5.879H7.06z"/></svg>',
|
|
73
|
+
assistantAvatar: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M0 7.472C0 4.85655 0 3.54883 0.509 2.54986C0.956728 1.67115 1.67115 0.956728 2.54986 0.509C3.54883 0 4.85655 0 7.472 0L8.528 0C11.1434 0 12.4512 0 13.4501 0.509C14.3289 0.956728 15.0433 1.67115 15.491 2.54986C16 3.54883 16 4.85655 16 7.472V8.528C16 11.1434 16 12.4512 15.491 13.4501C15.0433 14.3289 14.3289 15.0433 13.4501 15.491C12.4512 16 11.1434 16 8.528 16H7.472C4.85655 16 3.54883 16 2.54986 15.491C1.67115 15.0433 0.956728 14.3289 0.509 13.4501C0 12.4512 0 11.1434 0 8.528L0 7.472Z" fill="black" fill-opacity="0.48"/><path d="M12 12H4V4H12V12ZM5.25 5.25V10.75H10.75V5.25H5.25Z" fill="white"/></svg>',
|
|
73
74
|
figma: '<svg width="12" height="12" viewBox="0 0 200 300" xmlns="http://www.w3.org/2000/svg"><path d="M50 300c27.6 0 50-22.4 50-50v-50H50c-27.6 0-50 22.4-50 50s22.4 50 50 50z" fill="#0ACF83"/><path d="M0 150c0-27.6 22.4-50 50-50h50v100H50c-27.6 0-50-22.4-50-50z" fill="#A259FF"/><path d="M0 50C0 22.4 22.4 0 50 0h50v100H50C22.4 100 0 77.6 0 50z" fill="#F24E1E"/><path d="M100 0h50c27.6 0 50 22.4 50 50s-22.4 50-50 50h-50V0z" fill="#FF7262"/><path d="M200 150c0 27.6-22.4 50-50 50s-50-22.4-50-50 22.4-50 50-50 50 22.4 50 50z" fill="#1ABCFE"/></svg>',
|
|
74
75
|
},
|
|
75
76
|
},
|
package/package.json
CHANGED
package/types/index.ts
CHANGED