@livestorm/ui-vue 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -93
- package/dist/{UiTimelineItem.vue_vue_type_style_index_0_lang-B0UKmlqE.mjs → UiTimelineItem.vue_vue_type_style_index_0_lang-BtG5oABt.mjs} +1595 -1594
- package/dist/components.mjs +1 -1
- package/dist/i18n-Cktw9hIu.mjs +49 -0
- package/dist/index.mjs +1 -1
- package/dist/integrations.mjs +10 -4
- package/dist/layouts.mjs +1 -1
- package/dist/types/src/components/Toast/ToastMessage.vue.d.ts +4 -4
- package/dist/types/src/components/UiBanner/UiBanner.vue.d.ts +2 -2
- package/dist/types/src/components/UiButton/UiButton.vue.d.ts +1 -1
- package/dist/types/src/components/UiButtonGroup/UiButtonGroup.vue.d.ts +1 -1
- package/dist/types/src/components/UiColorField/UiColorField.vue.d.ts +2 -2
- package/dist/types/src/components/UiColorPicker/UiColorPicker.vue.d.ts +2 -2
- package/dist/types/src/components/UiDropdown/UiDropdownTrigger.vue.d.ts +1 -1
- package/dist/types/src/components/UiFieldWrapper/UiFieldWrapper.vue.d.ts +1 -1
- package/dist/types/src/components/UiForm/UiFormField.vue.d.ts +1 -1
- package/dist/types/src/components/UiInputCheckbox/UiInputCheckbox.vue.d.ts +5 -5
- package/dist/types/src/components/UiInputSelect/UiInputSelect.vue.d.ts +3 -3
- package/dist/types/src/components/UiInputTextarea/UiInputTextarea.vue.d.ts +3 -3
- package/dist/types/src/components/UiTextField/UiTextField.vue.d.ts +5 -5
- package/dist/types/src/composables/useButtonStyles.d.ts +1 -1
- package/dist/types/src/integrations/index.d.ts +1 -0
- package/dist/types/src/utils/i18n.d.ts +51 -0
- package/dist/ui-vue.css +1 -1
- package/dist/{useThemeAndModes-DY5SDC0a.mjs → useThemeAndModes-CUK56j0z.mjs} +20 -21
- package/dist/utils.mjs +55 -55
- package/integrations.d.ts +1 -0
- package/package.json +26 -19
- package/src/components/UiBanner/UiBanner.vue +4 -2
- package/src/components/UiDialog/UiDialogContent.vue +12 -4
- package/src/components/UiSideMenu/UiSideMenu.vue +4 -3
- package/src/composables/useThemeAndModes.ts +8 -4
- package/src/css/body.css +15 -7
- package/src/css/fonts.css +10 -0
- package/src/integrations/index.js +1 -0
- package/src/utils/clipboard.js +5 -2
- package/src/utils/i18n.ts +113 -0
package/README.md
CHANGED
|
@@ -11,37 +11,44 @@
|
|
|
11
11
|
A modern, strongly-typed Vue 3 component library for Livestorm’s design system.
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://main--65bcc25b1bd5ef5d8b1a8505.chromatic.com/"><strong>Browse the components →</strong></a>
|
|
16
|
+
</p>
|
|
14
17
|
|
|
15
18
|
## Table of Contents
|
|
16
19
|
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
20
|
+
- [Requirements](#requirements)
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Tailwind CSS setup](#tailwind-css-setup)
|
|
23
|
+
- [App setup](#app-setup)
|
|
24
|
+
- [Using components](#using-components)
|
|
25
|
+
- [Entry points](#entry-points)
|
|
23
26
|
- [Contributing](#contributing)
|
|
24
|
-
- [License](#license)
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
`ui-vue` provides a suite of reusable, accessible, and well-tested Vue 3 components, following Livestorm’s design system. It is built with Vue.js, TypeScript, Vitest, and Storybook.
|
|
30
|
+
## Requirements
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
- **Vue 3.5+**, a peer dependency provided by your app.
|
|
33
|
+
- **vue-router 5+**, an optional peer dependency. Everything works without it — install it only if you use one of these router-aware features:
|
|
34
|
+
- the `to` prop on `UiButton`, `UiListItem`, `UiActionBarItem` and `UiSideMenu` items, which renders a `<router-link>` (each also accepts a plain `href` link instead);
|
|
35
|
+
- the `confirmTo` action of toasts (`confirmHref` is the plain-link alternative);
|
|
36
|
+
- the logo link of `UiPageHeader` when `showLogo` is enabled;
|
|
37
|
+
- the `@livestorm/ui-vue/utils` entry point: its `useRouteQueryModel` helper is built on the router, so importing this entry requires vue-router to be installed.
|
|
38
|
+
- **Tailwind CSS 4**, since components are styled with Tailwind utility classes.
|
|
39
|
+
- **The Inter font**, which components are designed for. The package never loads it for you: self-host it, or import the optional Google Fonts shortcut once (`import '@livestorm/ui-vue/fonts'`). Without Inter, components fall back to the system font stack.
|
|
33
40
|
|
|
34
|
-
|
|
41
|
+
Installing the package also pulls in `@livestorm/ui-tokens` (design tokens) and `@livestorm/ui-icons` (icon utilities).
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
## Installation
|
|
37
44
|
|
|
38
45
|
```bash
|
|
39
46
|
pnpm add @livestorm/ui-vue
|
|
40
47
|
```
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
## Tailwind CSS setup
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
Components use Tailwind utility classes (including the `i-ls-*` icon classes), so your app needs to run Tailwind and scan the library. In your Tailwind entry CSS:
|
|
45
52
|
|
|
46
53
|
```css
|
|
47
54
|
@import "tailwindcss";
|
|
@@ -52,58 +59,20 @@ The library is Tailwind CSS 4 based: components use Tailwind utility classes (in
|
|
|
52
59
|
@source "../node_modules/@livestorm/ui-vue/dist";
|
|
53
60
|
```
|
|
54
61
|
|
|
62
|
+
> [!WARNING]
|
|
63
|
+
> Components rely on the design-token utilities these two imports produce (`bg-actions-primary-idle`, `i-ls-*`, ...). Those class names live in the component code, not in the shipped stylesheet, so if your own theme resets the token namespace (for example `--color-*: initial` in an `@theme`), Tailwind silently stops generating them and components render unstyled — no error, no warning. Keep the Livestorm token imports alongside your palette instead of resetting all colors.
|
|
64
|
+
|
|
55
65
|
Then import the library base styles once (body defaults, transitions, animations):
|
|
56
66
|
|
|
57
67
|
```ts
|
|
58
68
|
import '@livestorm/ui-vue/style'
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
The
|
|
62
|
-
|
|
63
|
-
### Local Import
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
import { UiButton } from '@livestorm/ui-vue'
|
|
67
|
-
|
|
68
|
-
export default {
|
|
69
|
-
components: { UiButton }
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Example
|
|
74
|
-
|
|
75
|
-
```vue
|
|
76
|
-
<template>
|
|
77
|
-
<UiButton variant="primary">Click me</UiButton>
|
|
78
|
-
</template>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Importing Components
|
|
82
|
-
|
|
83
|
-
All components are available as named exports. Example:
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
import { UiInput, UiInputSelect } from '@livestorm/ui-vue'
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Or import a specific component directly:
|
|
71
|
+
The body defaults ship inside `@layer base`, so anything your app declares — layered or not — takes precedence over them.
|
|
90
72
|
|
|
91
|
-
|
|
92
|
-
import UiDialog from '@livestorm/ui-vue/src/components/UiDialog'
|
|
93
|
-
```
|
|
73
|
+
## App setup
|
|
94
74
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
import { registerComponents } from '@livestorm/ui-vue/components-vite'
|
|
99
|
-
|
|
100
|
-
registerComponents(app) // registers UiButton, UiTag, ...
|
|
101
|
-
registerComponents(app, 'Ls') // optional custom prefix: LsButton, LsTag, ...
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### App setup
|
|
105
|
-
|
|
106
|
-
No runtime plugin is required: beyond the Tailwind CSS setup above, create the app and use components.
|
|
75
|
+
No runtime plugin is required. Create your app, import components, done:
|
|
107
76
|
|
|
108
77
|
```ts
|
|
109
78
|
import { createApp } from 'vue'
|
|
@@ -118,9 +87,12 @@ registerComponents(app) // optional: register all Ui* components globally
|
|
|
118
87
|
app.mount('#app')
|
|
119
88
|
```
|
|
120
89
|
|
|
121
|
-
|
|
90
|
+
Server-side rendering works out of the box: pages render with a desktop layout on the server, then adapt to the real screen size as soon as they load in the browser. No configuration and no hydration warnings. Overlay components (dialogs, dropdowns, menus, popovers, tooltips) render through client-only teleports and hydrate with no extra setup.
|
|
122
91
|
|
|
123
|
-
|
|
92
|
+
<details>
|
|
93
|
+
<summary>Optional: customizing the responsive breakpoints</summary>
|
|
94
|
+
|
|
95
|
+
Layout components read the viewport from a shared helper with sensible defaults. Install the responsive plugin only if you want to override the breakpoint flags, or read `$responsive` in your own templates:
|
|
124
96
|
|
|
125
97
|
```ts
|
|
126
98
|
import Responsive from '@livestorm/ui-vue/responsive'
|
|
@@ -132,54 +104,68 @@ app.use(Responsive, {
|
|
|
132
104
|
})
|
|
133
105
|
```
|
|
134
106
|
|
|
135
|
-
|
|
107
|
+
</details>
|
|
136
108
|
|
|
137
|
-
|
|
109
|
+
<details>
|
|
110
|
+
<summary>Optional: plugging your own translations</summary>
|
|
138
111
|
|
|
139
|
-
|
|
112
|
+
Components render a few built-in labels themselves (the dialog and banner close buttons, the "Copied!" tooltip, the side menu's "More"). Out of the box they come in English or French, picked from `<html lang>`. An app running [i18next](https://www.i18next.com/) with Livestorm's keys keeps control automatically; any other i18n stack can take over with a translator function:
|
|
140
113
|
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
pnpm dev:storybook
|
|
114
|
+
```ts
|
|
115
|
+
import { setTranslator } from '@livestorm/ui-vue/integrations'
|
|
144
116
|
|
|
117
|
+
setTranslator((key) => myI18n.t(`ui-vue.${key}`))
|
|
145
118
|
```
|
|
146
119
|
|
|
147
|
-
|
|
120
|
+
On an SSR server rendering a locale per request, provide the translator on the app instance instead — `setTranslator` is process-wide state shared by concurrent requests:
|
|
148
121
|
|
|
149
|
-
|
|
122
|
+
```ts
|
|
123
|
+
import { UI_VUE_TRANSLATOR } from '@livestorm/ui-vue/integrations'
|
|
150
124
|
|
|
151
|
-
|
|
125
|
+
app.provide(UI_VUE_TRANSLATOR, (key) => myI18n.t(`ui-vue.${key}`))
|
|
126
|
+
```
|
|
152
127
|
|
|
153
|
-
|
|
154
|
-
# Run all tests just one time
|
|
155
|
-
pnpm test:vitest
|
|
156
|
-
# or watch mode (preferred for debugging)
|
|
157
|
-
pnpm test:vitest:watch
|
|
158
|
-
# regenerate snapshots
|
|
159
|
-
pnpm test:vitest:updateSnapshots
|
|
128
|
+
Return the key itself (or `null`) to fall back to the built-in labels. The keys used: `general_close`, `general_dialog_title`, `general_misc_copied-text`, `room_bottom-bar_controls-label_more`.
|
|
160
129
|
|
|
130
|
+
</details>
|
|
131
|
+
|
|
132
|
+
Every component is a named export:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { UiButton, UiTextField, UiInputSelect } from '@livestorm/ui-vue'
|
|
161
136
|
```
|
|
162
137
|
|
|
163
|
-
|
|
164
|
-
>
|
|
138
|
+
```vue
|
|
139
|
+
<template>
|
|
140
|
+
<UiButton variant="cta" color="primary" icon="i-ls-check">
|
|
141
|
+
Click me
|
|
142
|
+
</UiButton>
|
|
143
|
+
</template>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Props, variants and events for each component are documented in the [hosted Storybook](https://main--65bcc25b1bd5ef5d8b1a8505.chromatic.com/), where every story is interactive. TypeScript definitions ship with the package, so editors autocomplete props and catch mistakes.
|
|
147
|
+
|
|
148
|
+
If you registered components globally with `registerComponents(app)`, you can use `<UiButton>` in any template without importing it. A custom prefix is supported too:
|
|
165
149
|
|
|
166
|
-
|
|
150
|
+
```ts
|
|
151
|
+
registerComponents(app, 'Ls') // <LsButton>, <LsTextField>, ...
|
|
152
|
+
```
|
|
167
153
|
|
|
168
|
-
|
|
169
|
-
- Runs automatically on every pull request that modifies packages/ui-vue.
|
|
170
|
-
- Installs dependencies, builds required packages, and runs all Vitest tests with coverage.
|
|
171
|
-
- Posts test results as a GitHub Check, including whether tests passed or failed.
|
|
172
|
-
- Ensures code quality before any code is merged.
|
|
154
|
+
## Entry points
|
|
173
155
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
156
|
+
| Import | Contents |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `@livestorm/ui-vue` | All components and utilities |
|
|
159
|
+
| `@livestorm/ui-vue/style` | Base stylesheet (import once) |
|
|
160
|
+
| `@livestorm/ui-vue/fonts` | Optional: loads Inter from Google Fonts (skip it if you self-host) |
|
|
161
|
+
| `@livestorm/ui-vue/components-vite` | `registerComponents` for global registration |
|
|
162
|
+
| `@livestorm/ui-vue/integrations` | Toast helpers (`openToast`, ...) |
|
|
163
|
+
| `@livestorm/ui-vue/layouts` | Layout components such as the toast container |
|
|
164
|
+
| `@livestorm/ui-vue/utils` | Helpers (`useCopyToClipboard`, `useRouteQueryModel`, ...) — the one entry that requires `vue-router` |
|
|
165
|
+
| `@livestorm/ui-vue/responsive` | Optional responsive plugin |
|
|
180
166
|
|
|
181
|
-
|
|
167
|
+
The package ships prebuilt ES modules, so no special bundler configuration is needed. The original sources are included as well, if your setup prefers to compile the components itself.
|
|
182
168
|
|
|
183
169
|
## Contributing
|
|
184
170
|
|
|
185
|
-
See CONTRIBUTING.md for
|
|
171
|
+
This package lives in Livestorm's [entropy](https://github.com/livestorm/entropy) monorepo, under `packages/ui-vue`. See that directory's `CONTRIBUTING.md` for architecture, conventions and the release process.
|