From 7caf6c69c3fcf1b60516ce7cf3621ec85c83b9d1 Mon Sep 17 00:00:00 2001 From: Carol Soliman Date: Fri, 17 Feb 2023 13:36:18 +0100 Subject: [PATCH] refact(KtToaster): to ts --- .../pages/usage/components/toaster.vue | 53 ++-- packages/kotti-ui/source/index.ts | 14 +- .../source/kotti-toaster/KtToaster.vue | 228 +++++++++++------- .../source/kotti-toaster/constants.ts | 1 + .../kotti-ui/source/kotti-toaster/index.ts | 6 +- .../kotti-ui/source/kotti-toaster/types.ts | 34 +++ .../{utilities.js => utilities.ts} | 17 +- packages/kotti-ui/source/types/kotti.ts | 3 +- 8 files changed, 238 insertions(+), 118 deletions(-) create mode 100644 packages/kotti-ui/source/kotti-toaster/constants.ts create mode 100644 packages/kotti-ui/source/kotti-toaster/types.ts rename packages/kotti-ui/source/kotti-toaster/{utilities.js => utilities.ts} (59%) diff --git a/packages/documentation/pages/usage/components/toaster.vue b/packages/documentation/pages/usage/components/toaster.vue index 66e627f128..ee01e86505 100644 --- a/packages/documentation/pages/usage/components/toaster.vue +++ b/packages/documentation/pages/usage/components/toaster.vue @@ -9,11 +9,12 @@ Toasters can deliver messages that the user needs to pay attention to without in ![Toaster Structure](~/assets/img/toaster_structure.png) -1. Type Color: Depends on the type of toaster. There are three colors: +1. Type Color: Depends on the type of toaster. It uses the Kotti Color Tokens for success, error, warning: - - `Green-500`: for success information - - `Orange-500`: for warning message - - `Red-500`: for fail/alert message + - `var(--support-error)`: for type `error` + - `var(--support-info)`: for type `info` + - `var(--support-success)`: for type `success` + - `var(--support-warning)`: for type `warning` 2. Message: Keep the message short and easy to understand, since the toaster disappears automatically after a few seconds. @@ -26,15 +27,19 @@ Since `Kotti-UI 1.0.0`, [vue-yodify](https://github.com/3YOURMIND/vue-yodify) is
+
@@ -59,17 +64,28 @@ this.$yodify({ }) ``` +Or within Vue's setup hook + +```js +const root = getCurrentInstance() +root.$yodify({ + text: 'This was successful :)', + type: 'success', // optional, default + duration: 3000, +}) +``` + ### Attributes -| Attribute | Description | Type | Accepted values | Default | -| :--------- | :------------------------------------------ | :------- | :---------------------------- | :-------- | -| `duration` | duration after which the toaster disappears | `Number` | — | `3000` | -| `text` | text message in the toaster | `String` | — | — | -| `type` | define the type of the toaster | `String` | `success`, `error`, `warning` | `success` | +| Attribute | Description | Type | Accepted values | Default | +| :--------- | :------------------------------------------ | :------- | :------------------------------------ | :-------- | +| `duration` | duration after which the toaster disappears | `Number` | — | `3000` | +| `text` | text message in the toaster | `String` | — | — | +| `type` | define the type of the toaster | `String` | `error`, `info`, `success`, `warning` | `success` |