|
1 | | - |
| 1 | + |
2 | 2 |
|
3 | | - |
4 | | - |
5 | | - |
| 3 | + |
| 4 | + |
| 5 | + |
6 | 6 |
|
7 | | -# @dafcoe/vue-swappable-card |
8 | | -Easy to use, customisable swappable card library built using Vue3. |
| 7 | +# @dafcoe/vue-notification |
| 8 | +Easy to use, customisable notification/toast library built using Vue3. |
9 | 9 |
|
10 | 10 | ## Installation |
11 | 11 | Install the package as a project dependency using `yarn` or `npm`: |
12 | 12 | ``` |
13 | | -$ yarn add @dafcoe/vue-swappable-card |
| 13 | +$ yarn add @dafcoe/vue-notification |
14 | 14 |
|
15 | 15 | --- or --- |
16 | 16 |
|
17 | | -$ npm install --save @dafcoe/vue-swappable-card |
| 17 | +$ npm install --save @dafcoe/vue-notification |
18 | 18 | ``` |
19 | 19 |
|
20 | 20 | ## Usage |
21 | | -Import `VueSwappableCard` component, either globally (on your main.js / main.ts file) or locally (on your component): |
| 21 | +Import `VueNotificationList` component, either globally (on your main.js / main.ts file) or locally (on your component): |
22 | 22 | ```js |
23 | 23 | // Globally |
24 | | -import VueSwappableCard from '@dafcoe/vue-swappable-card' |
| 24 | +import VueNotificationList from '@dafcoe/vue-notification' |
25 | 25 | const app = createApp(App) |
26 | | -app.use(VueSwappableCard).mount('#app') |
| 26 | +app.use(VueNotificationList).mount('#app') |
27 | 27 |
|
28 | 28 | // Locally |
29 | | -import { |
30 | | - VueSwappableCard, |
31 | | -} from '@dafcoe/vue-swappable-card' |
| 29 | +import { VueNotificationList } from '@dafcoe/vue-notification' |
32 | 30 | ``` |
33 | 31 |
|
34 | 32 | Import default styles (optional - you can define your own styling): |
35 | 33 | ```js |
36 | | -import '@dafcoe/vue-swappable-card/dist/vue-swappable-card.css' |
| 34 | +import '@dafcoe/vue-notification/dist/vue-notification.css' |
37 | 35 | ``` |
38 | 36 |
|
39 | 37 | Use it in the template as follows: |
40 | 38 | ```html |
41 | | -<vue-swappable-card> |
42 | | - <template #content-primary> |
43 | | - <h1>Face A</h1> |
44 | | - <div> |
45 | | - <p>Lorem ipsum dolor sit amet...</p> |
46 | | - </div> |
47 | | - </template> |
48 | | - <template #content-secondary> |
49 | | - <h1>Face B</h1> |
50 | | - <div> |
51 | | - <p>Lorem ipsum dolor sit amet...</p> |
52 | | - </div> |
53 | | - </template> |
54 | | -</vue-swappable-card> |
| 39 | +<vue-notification-list></vue-notification-list> |
55 | 40 | ``` |
56 | 41 |
|
57 | 42 | ## Options |
58 | | -#### Direction |
59 | | -By default, the swap direction is from bottom to top. You can use "from-top", "from-bottom", "from-left" or "from-right" on `direction` prop: |
| 43 | +#### Position |
| 44 | +By default, the notification list is displayed on bottom right corner of the screen. You can customize this using "top-left", "top-right", "bottom-left" or "bottom-right" on `position` prop: |
60 | 45 | ```html |
61 | | -<vue-swappable-card direction="from-top|from-bottom|from-left|from-right"> |
62 | | - ... |
63 | | -</vue-wappable-card> |
| 46 | +<vue-notification-list position="top-left|top-right|bottom-left|bottom-right"></vue-notification-list> |
64 | 47 | ``` |
65 | 48 |
|
66 | | -#### Event |
67 | | -By default, the card swaps when overing it. You can use "over" or "click" on `event` prop: |
68 | | -```html |
69 | | -<vue-swappable-card direction="over|click"> |
70 | | - ... |
71 | | -</vue-wappable-card> |
| 49 | +## Pushing Notifications |
| 50 | +To push a notification, you have call `setNotification` from `vue-notification.store`, passing a notification object: |
| 51 | +```javascript |
| 52 | +import { useNotificationStore } from '@dafcoe/vue-notification/vue-notification.store' |
| 53 | +... |
| 54 | +const { setNotification } = useNotificationStore() |
| 55 | +setNotification(notificationA) |
| 56 | +setNotification(notificationB) |
72 | 57 | ``` |
73 | | - |
74 | | -#### Swapped |
75 | | -By default, the primary content / front face is shown as main content/face. You can change this using `swapped` prop: |
76 | | -```html |
77 | | -<vue-swappable-card swapped> |
78 | | - ... |
79 | | -</vue-wappable-card> |
| 58 | +A notification object has the following properties: |
| 59 | +```json |
| 60 | +{ |
| 61 | + "message": string, |
| 62 | + "type": string ("info"|"warning"|"alert"|"success"), |
| 63 | + "showIcon": boolean, |
| 64 | + "dismiss": { |
| 65 | + "manually": boolean, |
| 66 | + "automatically": boolean |
| 67 | + }, |
| 68 | + "duration": number, |
| 69 | + "showDurationProgress": boolean, |
| 70 | + "appearance": string ("light"|"dark"|"glass") |
| 71 | +} |
80 | 72 | ``` |
| 73 | +Please check the [demo](https://dafcoe.github.io/vue-notification) page to easily see all propreties in action. |
81 | 74 |
|
82 | 75 | ## License |
83 | 76 | [MIT License](https://opensource.org/licenses/MIT) © [Daf Coe](mailto:dafcoe@gmail.com) |
0 commit comments