Address PR comments

This commit is contained in:
Dmitri
2022-10-02 17:25:01 -07:00
parent 19542da005
commit 923645b4b3
4 changed files with 23 additions and 16 deletions

View File

@@ -39,8 +39,10 @@
</Modal> </Modal>
</div> </div>
</template> </template>
<script setup> <script lang="ts" setup>
import { Modal } from '../../../../src/index'; import { Modal } from '../../../../src/index'
import type { PropType } from 'vue'
import type { ModalSize, ModalPosition } from '../../../../src/components/Modal/types'
const props = defineProps({ const props = defineProps({
children: { children: {
type: Array, type: Array,
@@ -53,7 +55,7 @@ const props = defineProps({
default: false, default: false,
}, },
position: { position: {
type: String, // 'bottom-left' | 'bottom-right' | 'bottom-center' | 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' type: String as PropType<ModalPosition>,
default: 'center', default: 'center',
}, },
show: { show: {
@@ -61,7 +63,7 @@ const props = defineProps({
default: false, default: false,
}, },
size: { size: {
type: String, // 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' type: String as PropType<ModalSize>,
default: '2xl', default: '2xl',
}, },
triggerText: { triggerText: {

View File

@@ -1,16 +1,16 @@
<template> <template>
<div class="vp-raw flex justify-between"> <div class="vp-raw flex justify-between">
<span> <span>
<ModalExample size="xs" trigger-text="XS Modal"/> <ModalExample size="xs" trigger-text="XS Modal" />
</span> </span>
<span> <span>
<ModalExample size="md" trigger-text="MD Modal"/> <ModalExample size="md" trigger-text="MD Modal" />
</span> </span>
<span> <span>
<ModalExample size="xl" trigger-text="XL Modal"/> <ModalExample size="xl" trigger-text="XL Modal" />
</span> </span>
<span> <span>
<ModalExample size="5xl" trigger-text="5XL Modal"/> <ModalExample size="5xl" trigger-text="5XL Modal" />
</span> </span>
</div> </div>
</template> </template>

View File

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<slot name="trigger" :show="showModal" :hide="hideModal" :toggle="toggleModal"></slot> <slot name="trigger" :show="showModal" :hide="hideModal" :toggle="toggleModal"/>
<div v-if="!isHidden" class="bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40"></div> <div v-if="!isHidden" class="bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40"/>
<div v-if="!isHidden" tabindex="-1" :aria-hidden="isHidden ? 'true' : 'false'" <div v-if="!isHidden" tabindex="-1" :aria-hidden="isHidden ? 'true' : 'false'"
class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full justify-center items-center flex"> class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full justify-center items-center flex">
<div class="relative p-4 w-full h-full md:h-auto" <div class="relative p-4 w-full h-full md:h-auto"
@@ -11,15 +11,15 @@
<!-- Modal header --> <!-- Modal header -->
<div class="p-4 rounded-t" <div class="p-4 rounded-t"
:class="$slots.header ? 'border-b' : ''"> :class="$slots.header ? 'border-b' : ''">
<slot name="header" :show="showModal" :hide="hideModal" :toggle="toggleModal"></slot> <slot name="header" :show="showModal" :hide="hideModal" :toggle="toggleModal"/>
</div> </div>
<!-- Modal body --> <!-- Modal body -->
<div class="p-6" :class="$slots.header ? '' : 'pt-0'"> <div class="p-6" :class="$slots.header ? '' : 'pt-0'">
<slot name="body" :show="showModal" :hide="hideModal" :toggle="toggleModal"></slot> <slot name="body" :show="showModal" :hide="hideModal" :toggle="toggleModal"/>
</div> </div>
<!-- Modal footer --> <!-- Modal footer -->
<div v-if="$slots.footer" class="p-6 rounded-b border-gray-200"> <div v-if="$slots.footer" class="p-6 rounded-b border-gray-200">
<slot name="footer" :show="showModal" :hide="hideModal" :toggle="toggleModal"/> <slot name="footer" :show="showModal" :hide="hideModal" :toggle="toggleModal"/>
</div> </div>
</div> </div>
</div> </div>
@@ -28,7 +28,8 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref } from 'vue'
import type { Ref } from 'vue' import type { PropType, Ref } from 'vue'
import type { ModalSize, ModalPosition } from './types'
const props = defineProps({ const props = defineProps({
children: { children: {
@@ -42,7 +43,7 @@ const props = defineProps({
default: false, default: false,
}, },
position: { position: {
type: String, // 'bottom-left' | 'bottom-right' | 'bottom-center' | 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' type: String as PropType<ModalPosition>,
default: 'center', default: 'center',
}, },
show: { show: {
@@ -50,7 +51,7 @@ const props = defineProps({
default: false, default: false,
}, },
size: { size: {
type: String, // 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' type: String as PropType<ModalSize>,
default: '2xl', default: '2xl',
}, },
}) })
@@ -74,9 +75,11 @@ const isHidden: Ref<boolean> = ref(!props.show)
function toggleModal() { function toggleModal() {
isHidden.value = !isHidden.value isHidden.value = !isHidden.value
} }
function hideModal() { function hideModal() {
isHidden.value = true isHidden.value = true
} }
function showModal() { function showModal() {
isHidden.value = false isHidden.value = false
} }

View File

@@ -0,0 +1,2 @@
export type ModalPosition = 'bottom-left' | 'bottom-right' | 'bottom-center' | 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right';
export type ModalSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl';