-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(overlay): move to script setup (#3065)
- Loading branch information
Showing
17 changed files
with
200 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Overlay from './overlay.taro.vue' | ||
import type { ComponentPublicInstance } from 'vue' | ||
import { withInstall } from '@/packages/utils' | ||
|
||
withInstall(Overlay) | ||
|
||
export type { OverlayProps } from './overlay.taro.vue' | ||
|
||
export type OverlayInstance = ComponentPublicInstance & InstanceType<typeof Overlay> | ||
|
||
export { Overlay, Overlay as default } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Overlay from './overlay.vue' | ||
import type { ComponentPublicInstance } from 'vue' | ||
import { withInstall } from '@/packages/utils' | ||
|
||
withInstall(Overlay) | ||
|
||
export type { OverlayProps } from './overlay.vue' | ||
|
||
export type OverlayInstance = ComponentPublicInstance & InstanceType<typeof Overlay> | ||
|
||
export { Overlay, Overlay as default } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<template> | ||
<Transition name="overlay-fade"> | ||
<view v-show="visible" :class="classes" :style="style" :catch-move="lockScroll" @click="onClick"> | ||
<slot></slot> | ||
</view> | ||
</Transition> | ||
</template> | ||
<script setup lang="ts"> | ||
import { CSSProperties, computed } from 'vue' | ||
defineOptions({ | ||
name: 'NutOverlay' | ||
}) | ||
export type OverlayProps = Partial<{ | ||
visible: boolean | ||
zIndex: string | number | ||
duration: string | number | ||
lockScroll: boolean | ||
overlayClass: string | ||
overlayStyle: CSSProperties | ||
closeOnClickOverlay: boolean | ||
}> | ||
const props = withDefaults(defineProps<OverlayProps>(), { | ||
visible: false, | ||
zIndex: 2000, | ||
duration: 0.3, | ||
lockScroll: true, | ||
overlayClass: '', | ||
closeOnClickOverlay: true | ||
}) | ||
const emit = defineEmits(['click', 'update:visible']) | ||
const classes = computed(() => { | ||
const prefixCls = 'nut-overlay' | ||
return { | ||
[prefixCls]: true, | ||
[props.overlayClass]: true | ||
} | ||
}) | ||
const style = computed(() => { | ||
return { | ||
transitionDuration: `${props.duration}s`, | ||
zIndex: props.zIndex, | ||
...props.overlayStyle | ||
} | ||
}) | ||
const onClick = (e: MouseEvent) => { | ||
emit('click', e) | ||
if (props.closeOnClickOverlay) { | ||
emit('update:visible', false) | ||
} | ||
} | ||
</script> |
Oops, something went wrong.