From e1b45636e0808aaccc738ba711582f44598c51ae Mon Sep 17 00:00:00 2001 From: Pink Cheetah Date: Sat, 6 Apr 2024 02:52:00 +0700 Subject: [PATCH] feat(components): add atom component modal --- playground/pages/button.vue | 5 + playground/pages/modal.vue | 20 +++ src/runtime/components/atoms/button.vue | 6 +- src/runtime/components/atoms/modal.vue | 155 ++++++++++++++++++++++++ src/runtime/ui-configs/index.ts | 1 + src/runtime/ui-configs/modal.ts | 37 ++++++ 6 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 playground/pages/button.vue create mode 100644 playground/pages/modal.vue create mode 100644 src/runtime/components/atoms/modal.vue create mode 100644 src/runtime/ui-configs/modal.ts diff --git a/playground/pages/button.vue b/playground/pages/button.vue new file mode 100644 index 0000000..1993b07 --- /dev/null +++ b/playground/pages/button.vue @@ -0,0 +1,5 @@ + diff --git a/playground/pages/modal.vue b/playground/pages/modal.vue new file mode 100644 index 0000000..52952b4 --- /dev/null +++ b/playground/pages/modal.vue @@ -0,0 +1,20 @@ + + + + diff --git a/src/runtime/components/atoms/button.vue b/src/runtime/components/atoms/button.vue index 955c9d7..fe02bdd 100644 --- a/src/runtime/components/atoms/button.vue +++ b/src/runtime/components/atoms/button.vue @@ -62,8 +62,8 @@ import appConfig from "#build/app.config"; import { button } from "#mei-ui/ui-configs"; const config = mergeConfig( - appConfig.ui.strategy, - appConfig.ui.button, + appConfig.meiUI.strategy, + appConfig.meiUI.button, button, ); @@ -110,7 +110,7 @@ export default defineComponent({ type: String as PropType, default: () => config.default.color, validator(value: string) { - return [...appConfig.ui.colors, ...Object.keys(config.color)].includes( + return [...appConfig.meiUI.colors, ...Object.keys(config.color)].includes( value, ); }, diff --git a/src/runtime/components/atoms/modal.vue b/src/runtime/components/atoms/modal.vue new file mode 100644 index 0000000..f9505cb --- /dev/null +++ b/src/runtime/components/atoms/modal.vue @@ -0,0 +1,155 @@ + + + diff --git a/src/runtime/ui-configs/index.ts b/src/runtime/ui-configs/index.ts index 355df3c..ca36efb 100644 --- a/src/runtime/ui-configs/index.ts +++ b/src/runtime/ui-configs/index.ts @@ -9,3 +9,4 @@ export { default as tooltip } from "./tooltip"; export { default as kbd } from "./kbd"; export { default as dropdown } from "./dropdown"; export { default as avatar } from "./avatar"; +export { default as modal } from "./modal"; diff --git a/src/runtime/ui-configs/modal.ts b/src/runtime/ui-configs/modal.ts new file mode 100644 index 0000000..181643d --- /dev/null +++ b/src/runtime/ui-configs/modal.ts @@ -0,0 +1,37 @@ +export default { + wrapper: 'relative z-50', + inner: 'fixed inset-0 overflow-y-auto', + container: 'flex min-h-full items-end sm:items-center justify-center text-center', + padding: 'p-4 sm:p-0', + margin: 'sm:my-8', + base: 'relative text-left rtl:text-right flex flex-col', + overlay: { + base: 'fixed inset-0 transition-opacity', + background: 'bg-gray-200/75 dark:bg-gray-800/75', + // Syntax for `` component https://headlessui.com/vue/transition#basic-example + transition: { + enter: 'ease-out duration-300', + enterFrom: 'opacity-0', + enterTo: 'opacity-100', + leave: 'ease-in duration-200', + leaveFrom: 'opacity-100', + leaveTo: 'opacity-0' + } + }, + background: 'bg-white dark:bg-gray-900', + ring: '', + rounded: 'rounded-lg', + shadow: 'shadow-xl', + width: 'w-full sm:max-w-lg', + height: '', + fullscreen: 'w-screen h-screen', + // Syntax for `` component https://headlessui.com/vue/transition#basic-example + transition: { + enter: 'ease-out duration-300', + enterFrom: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', + enterTo: 'opacity-100 translate-y-0 sm:scale-100', + leave: 'ease-in duration-200', + leaveFrom: 'opacity-100 translate-y-0 sm:scale-100', + leaveTo: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95' + } +}