diff --git a/.playground/pages/index.vue b/.playground/pages/index.vue new file mode 100644 index 0000000..ff04ce0 --- /dev/null +++ b/.playground/pages/index.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/app.vue b/app.vue index c5f8626..b735add 100644 --- a/app.vue +++ b/app.vue @@ -1,4 +1,10 @@ + + diff --git a/components/icons/CircleError.vue b/components/icons/CircleError.vue new file mode 100644 index 0000000..4d84356 --- /dev/null +++ b/components/icons/CircleError.vue @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/components/icons/CircleInfo.vue b/components/icons/CircleInfo.vue new file mode 100644 index 0000000..660e8e1 --- /dev/null +++ b/components/icons/CircleInfo.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/components/icons/CircleSuccess.vue b/components/icons/CircleSuccess.vue new file mode 100644 index 0000000..8a64ee6 --- /dev/null +++ b/components/icons/CircleSuccess.vue @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/components/icons/CircleWarning.vue b/components/icons/CircleWarning.vue new file mode 100644 index 0000000..5a5aebc --- /dev/null +++ b/components/icons/CircleWarning.vue @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/components/icons/Spinner.vue b/components/icons/Spinner.vue new file mode 100644 index 0000000..cab4a3f --- /dev/null +++ b/components/icons/Spinner.vue @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/components/overlays/Message.vue b/components/overlays/Message.vue new file mode 100644 index 0000000..ccbbd21 --- /dev/null +++ b/components/overlays/Message.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/components/overlays/MessageProvider.vue b/components/overlays/MessageProvider.vue new file mode 100644 index 0000000..f4168f9 --- /dev/null +++ b/components/overlays/MessageProvider.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/composables/useMessage.ts b/composables/useMessage.ts new file mode 100644 index 0000000..a11ef93 --- /dev/null +++ b/composables/useMessage.ts @@ -0,0 +1,9 @@ +import type { MessageApi } from "../types/Message"; + +export const useMessage = () => { + const message = inject("ray-message"); + if (!message) { + throw new Error("No outer message-provider found!"); + } + return message; +}; diff --git a/nuxt.config.ts b/nuxt.config.ts index 82f5ee6..d322d64 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,6 +1,7 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ devtools: { enabled: true }, + compatibilityDate: "2024-11-15", modules: ["@nuxtjs/tailwindcss"], components: [ { @@ -8,5 +9,10 @@ export default defineNuxtConfig({ prefix: "Ray", pathPrefix: false, }, + { + path: "./components/icons", + prefix: "Icon", + pathPrefix: false, + }, ], }); diff --git a/types/Message.d.ts b/types/Message.d.ts new file mode 100644 index 0000000..1b0e13f --- /dev/null +++ b/types/Message.d.ts @@ -0,0 +1,20 @@ +export type MessageType = "success" | "warning" | "error" | "info"; + +export interface Message { + id: string; + content: string; + type: MessageType; + duration?: number; +} + +export interface MessageApi { + info: (content: string, duration?: number) => void; + success: (content: string, duration?: number) => void; + warning: (content: string, duration?: number) => void; + error: (content: string, duration?: number) => void; + destroyAll: () => void; +} + +export interface MessageProviderApi { + destroy: (id: string) => void; +}