vue-toastflow 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +179 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ <!-- readme-top -->
2
+
3
+ <p align="center">
4
+ <img src="../../images/banner.png" alt="Toastflow banner" width="900" />
5
+ </p>
6
+
7
+ <h1 align="center">Toastflow</h1>
8
+ <p align="center">
9
+ Framework-agnostic toast engine with a Vue 3 renderer. Typed core, smooth stack animations, CSS-first theming, and full control over layout and behavior.
10
+ </p>
11
+
12
+ ---
13
+
14
+ ## Preview
15
+
16
+ <p align="center">
17
+ <img src="../../images/showcase.png" alt="Toastflow showcase" width="850" />
18
+ </p>
19
+
20
+ ## Usage (Vue.js 3 Composition API)
21
+
22
+ ### Quick start
23
+
24
+ ```ts
25
+ // main.ts
26
+ import {createApp} from "vue";
27
+ import App from "./App.vue";
28
+ import {createToastflow, ToastContainer} from "vue-toastflow";
29
+
30
+ const app = createApp(App);
31
+
32
+ app.use(
33
+ createToastflow({
34
+ // optional global defaults
35
+ position: "top-right",
36
+ duration: 5000,
37
+ }),
38
+ );
39
+
40
+ // register globally or import locally where you render it
41
+ app.component("ToastContainer", ToastContainer);
42
+
43
+ // call toast.* only after the plugin is installed
44
+ app.mount("#app");
45
+ ```
46
+
47
+ Render a container and fire toasts anywhere:
48
+
49
+ ```vue
50
+ <!-- App.vue -->
51
+ <template>
52
+ <ToastContainer/>
53
+ <RouterView/>
54
+ </template>
55
+ ```
56
+
57
+ ```ts
58
+ import {toast} from "vue-toastflow";
59
+
60
+ toast.success({title: "Saved", description: "Your changes are live."});
61
+ toast.warning({description: "Low balance"});
62
+
63
+ const id = toast.error({title: "Oops", description: "Check console."});
64
+ toast.update(id, {description: "Fixed. All good now."});
65
+ toast.dismiss(id);
66
+ ```
67
+
68
+ ### Async flows
69
+
70
+ ```ts
71
+ const run = toast.loading(
72
+ () => fetch("/api/save").then((r) => r.json()),
73
+ {
74
+ loading: {title: "Saving", description: "Hang tight."},
75
+ success: (data) => ({
76
+ title: "Saved",
77
+ description: `Stored item ${data.id}.`,
78
+ }),
79
+ error: (err) => ({
80
+ title: "Error",
81
+ description: err instanceof Error ? err.message : "Please try again.",
82
+ }),
83
+ },
84
+ );
85
+
86
+ await run;
87
+ console.log(run.toastId);
88
+ ```
89
+
90
+ ### HTML content
91
+
92
+ ```ts
93
+ toast.info({
94
+ title: "<strong>New version</strong>",
95
+ description: "Release notes are <a href='/changelog'>here</a>.",
96
+ supportHtml: true,
97
+ });
98
+ ```
99
+
100
+ ### Headless rendering
101
+
102
+ ```vue
103
+
104
+ <ToastContainer
105
+ v-slot="{
106
+ toast,
107
+ dismiss,
108
+ bumpAnimationClass,
109
+ clearAllAnimationClass,
110
+ updateAnimationClass,
111
+ }"
112
+ >
113
+ <div
114
+ class="my-toast"
115
+ :class="[
116
+ toast.type,
117
+ bumpAnimationClass,
118
+ toast.phase === 'clear-all' && clearAllAnimationClass,
119
+ updateAnimationClass
120
+ ]"
121
+ @click="toast.closeOnClick && dismiss(toast.id)"
122
+ >
123
+ <header>
124
+ <strong>{{ toast.title }}</strong>
125
+ <button @click.stop="dismiss(toast.id)">x</button>
126
+ </header>
127
+ <p v-if="toast.description">{{ toast.description }}</p>
128
+ <small v-if="toast.showCreatedAt">
129
+ Sent at {{ toast.createdAtFormatter(toast.createdAt) }}
130
+ </small>
131
+ </div>
132
+ </ToastContainer>
133
+ ```
134
+
135
+ ## Configuration
136
+
137
+ Pass any [types.ts](../../packages/core/src/types.ts) fields to `createToastflow`; per-toast options override them:
138
+
139
+ - `position`: "top-right" (default), "top-left", "top-center", "bottom-*"
140
+ - `duration`: `5000` ms by default; `Infinity` or `0` disables auto-dismiss (progress bar auto-hides when disabled)
141
+ - `maxVisible`: `5` per stack; eviction respects `order`
142
+ - `order`: "newest" (default) or "oldest" per stack
143
+ - `preventDuplicates`: `false` by default; matches by position + type + title + description
144
+ - `progressBar`, `pauseOnHover`, `pauseStrategy` ("resume" | "reset")
145
+ - `animation`: class names for enter/leave/move (`name`), bump, clearAll, update (defaults use `Toastflow__*`)
146
+ - `closeButton` (`true`), `closeOnClick` (`false`)
147
+ - `offset` (`16px`), `gap` (`8px`), `width` (`350px`), `zIndex` (`9999`)
148
+ - `supportHtml`: `false` (opt-in)
149
+ - `showCreatedAt` and `createdAtFormatter` for timestamps
150
+ - lifecycle hooks: `onMount`, `onUnmount`, `onClick`, `onClose`
151
+
152
+ ## Theming
153
+
154
+ - CSS variables live in [styles.css](../../packages/vue/src/styles.css) and are auto-imported with the Vue package.
155
+ - Key
156
+ variables: `--tf-toast-bg`, `--tf-toast-color`, `--tf-toast-border-color`, `--tf-toast-radius`, `--tf-toast-padding`, `--tf-toast-icon-size`, `--tf-toast-progress-height`,
157
+ plus per-type colors like `--success-bg` and `--error-text`.
158
+ - Animations are pure CSS class names; override them via the `animation` config or by redefining the `Toastflow__*`
159
+ keyframes. **Animations are implemented using [TransitionGroup](https://vuejs.org/guide/built-ins/transition-group).**
160
+
161
+ ## Events and store access
162
+
163
+ - `toast.subscribeEvents(listener)` gets `duplicate`, `timer-reset`, and `update` events.
164
+ - `toast.getState()` returns the current snapshot; helper
165
+ methods: `toast.show`, `toast.success`, `toast.error`, `toast.warning`, `toast.info`, `toast.loading`, `toast.update`, `toast.dismiss`, `toast.dismissAll`, `toast.pause`, `toast.resume`, `toast.getConfig`.
166
+
167
+ ## Contributing
168
+
169
+ Contributions are welcome! Fork the repo, create a branch, and open a PR. For bigger changes, open an issue first.
170
+
171
+ 1. Fork the project
172
+ 2. Create your branch
173
+ 3. Commit your changes
174
+ 4. Push to the branch
175
+ 5. Open a Pull Request
176
+
177
+ ## License
178
+
179
+ MIT - see [LICENSE](../../LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-toastflow",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "src/index.ts",
5
5
  "module": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -12,7 +12,7 @@
12
12
  "vue": "^3.4.0"
13
13
  },
14
14
  "dependencies": {
15
- "toastflow-core": "workspace:*"
15
+ "toastflow-core": "^0.0.1"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@vitejs/plugin-vue": "^6.0.2",