From 849596e870619c77066a4b52ccda2ea016ce939f Mon Sep 17 00:00:00 2001 From: Sadegh Barati Date: Mon, 30 Oct 2023 22:36:00 +0330 Subject: [PATCH] feat: add `VNode` type to toast description --- .../lib/registry/default/example/InputForm.vue | 7 ++++++- .../lib/registry/default/ui/toast/Toast.vue | 18 ++++++++++++------ .../default/ui/toast/ToastDescription.vue | 2 +- .../lib/registry/default/ui/toast/Toaster.vue | 12 +++++++++--- .../src/lib/registry/default/ui/toast/index.ts | 1 + .../lib/registry/default/ui/toast/use-toast.ts | 9 +++++++-- .../registry/new-york/example/InputForm.vue | 7 ++++++- .../lib/registry/new-york/ui/toast/Toast.vue | 18 ++++++++++++------ .../new-york/ui/toast/ToastDescription.vue | 2 +- .../lib/registry/new-york/ui/toast/Toaster.vue | 12 +++++++++--- .../lib/registry/new-york/ui/toast/index.ts | 1 + .../registry/new-york/ui/toast/use-toast.ts | 9 +++++++-- 12 files changed, 72 insertions(+), 26 deletions(-) diff --git a/apps/www/src/lib/registry/default/example/InputForm.vue b/apps/www/src/lib/registry/default/example/InputForm.vue index 65e138bf..f2ec0cc1 100644 --- a/apps/www/src/lib/registry/default/example/InputForm.vue +++ b/apps/www/src/lib/registry/default/example/InputForm.vue @@ -3,6 +3,7 @@ import { useForm } from 'vee-validate' import { toTypedSchema } from '@vee-validate/zod' import * as z from 'zod' +import { h } from 'vue' import { Button } from '@/lib/registry/default/ui/button' import { FormControl, @@ -13,6 +14,7 @@ import { FormMessage, } from '@/lib/registry/default/ui/form' import { Input } from '@/lib/registry/default/ui/input' +import { toast } from '@/lib/registry/default/ui/toast/use-toast' const formSchema = toTypedSchema(z.object({ username: z.string().min(2).max(50), @@ -23,7 +25,10 @@ const { handleSubmit } = useForm({ }) const onSubmit = handleSubmit((values) => { - console.log('Form submitted!', values) + toast({ + title: 'You submitted the following values:', + description: h('pre', { class: 'mt-2 w-[340px] rounded-md bg-slate-950 p-4' }, h('code', { class: 'text-white' }, JSON.stringify(values, null, 2))), + }) }) diff --git a/apps/www/src/lib/registry/default/ui/toast/Toast.vue b/apps/www/src/lib/registry/default/ui/toast/Toast.vue index 46e3bd2b..6d13dc83 100644 --- a/apps/www/src/lib/registry/default/ui/toast/Toast.vue +++ b/apps/www/src/lib/registry/default/ui/toast/Toast.vue @@ -1,18 +1,24 @@ - + +