-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
affects: @varlet/cli, @varlet/eslint-config, @varlet/ui
- Loading branch information
Showing
22 changed files
with
816 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import context from './index' | ||
import { watch } from 'vue' | ||
import { watch, ref, Ref } from 'vue' | ||
|
||
export function useZIndex(props: any, state: string, count: number) { | ||
const zIndex: Ref<number> = ref(context.zIndex) | ||
|
||
export function useZIndex(props: any, state: string, zIndex: number) { | ||
watch(() => props[state], (newValue) => { | ||
if (newValue === true) { | ||
context.zIndex += zIndex | ||
context.zIndex += count | ||
zIndex.value = context.zIndex | ||
} | ||
}, { immediate: true }) | ||
|
||
return { zIndex } | ||
} |
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 |
---|---|---|
@@ -1,17 +1,136 @@ | ||
<template> | ||
<div class="var-dialog"></div> | ||
<var-popup | ||
class="var-dialog__popup-radius" | ||
v-model:show="popupShow" | ||
:overlay="overlay" | ||
:overlay-class="overlayClass" | ||
:lock-scroll="lockScroll" | ||
:close-on-click-overlay="popupCloseOnClickOverlay" | ||
:teleport="teleport" | ||
@open="$emit('open')" | ||
@close="$emit('close')" | ||
@opened="$emit('opened')" | ||
@closed="$emit('closed')" | ||
@click-overlay="handleClickOverlay" | ||
> | ||
<div | ||
class="var-dialog" | ||
v-bind="$attrs" | ||
> | ||
<div class="var-dialog__title"> | ||
<slot name="title">{{ title }}</slot> | ||
</div> | ||
<div | ||
class="var-dialog__message" | ||
:style="{ | ||
'text-align': messageAlign | ||
}" | ||
> | ||
<slot> | ||
{{ message }} | ||
</slot> | ||
</div> | ||
<div class="var-dialog__actions"> | ||
<var-button | ||
class="var-dialog__button" | ||
:color="cancelButtonColor" | ||
:background="cancelButtonBackground" | ||
v-if="cancelButton" | ||
@click="cancel" | ||
> | ||
{{ cancelButtonText }} | ||
</var-button> | ||
<var-button | ||
class="var-dialog__button" | ||
:color="confirmButtonColor" | ||
:background="confirmButtonBackground" | ||
v-if="confirmButton" | ||
@click="confirm" | ||
> | ||
{{ confirmButtonText }} | ||
</var-button> | ||
</div> | ||
</div> | ||
</var-popup> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import Popup from '../popup' | ||
import Button from '../button' | ||
import { props, emits } from './propsEmits' | ||
import { defineComponent, ref, Ref, watch } from 'vue' | ||
export default defineComponent({ | ||
name: 'VarDialog' | ||
name: 'VarDialog', | ||
components: { | ||
[Popup.name]: Popup, | ||
[Button.name]: Button | ||
}, | ||
inheritAttrs: false, | ||
props, | ||
emits, | ||
setup(props, { emit }) { | ||
// 需要透传到popup组件里并需要特殊处理的参数 | ||
const popupShow: Ref<boolean> = ref(false) | ||
const popupCloseOnClickOverlay: Ref<boolean> = ref(false) | ||
watch(() => props.show, (newValue) => { | ||
popupShow.value = newValue | ||
}, { immediate: true }) | ||
watch(() => props.closeOnClickOverlay, (newValue) => { | ||
if (props.beforeClose) { | ||
// 异步关闭情况下 禁止点击弹出层关闭 | ||
popupCloseOnClickOverlay.value = false | ||
return | ||
} | ||
popupCloseOnClickOverlay.value = newValue | ||
}, { immediate: true }) | ||
// 异步关闭回调 | ||
const done = () => emit('update:show', false) | ||
const handleClickOverlay = () => { | ||
emit('click-overlay') | ||
if (props.closeOnClickOverlay === false) { | ||
return | ||
} | ||
if (props.beforeClose) { | ||
props.beforeClose(done) | ||
return | ||
} | ||
emit('update:show', false) | ||
} | ||
const confirm = () => { | ||
emit('confirm') | ||
if (props.beforeClose) { | ||
props.beforeClose(done) | ||
return | ||
} | ||
emit('update:show', false) | ||
} | ||
const cancel = () => { | ||
emit('cancel') | ||
if (props.beforeClose) { | ||
props.beforeClose(done) | ||
return | ||
} | ||
emit('update:show', false) | ||
} | ||
return { | ||
popupShow, | ||
popupCloseOnClickOverlay, | ||
handleClickOverlay, | ||
confirm, | ||
cancel | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style lang="less"> | ||
.var-dialog { | ||
display: flex; | ||
} | ||
@import "./dialog"; | ||
</style> |
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,47 @@ | ||
@import "../styles/var"; | ||
|
||
@dialog-width: 270px; | ||
@dialog-padding: 20px; | ||
@dialog-border-radius: 2px; | ||
|
||
@dialog-message-padding: 26px 0; | ||
@dialog-message-line-height: 24px; | ||
|
||
@dialog-button-margin-left: 6px; | ||
|
||
.var-dialog { | ||
width: @dialog-width; | ||
padding: @dialog-padding; | ||
border-radius: 3px; | ||
|
||
&__popup-radius { | ||
border-radius: @dialog-border-radius | ||
} | ||
|
||
&__title { | ||
font-size: @font-size-lg; | ||
font-weight: 600; | ||
} | ||
|
||
&__message { | ||
padding: @dialog-message-padding; | ||
color: @color-font-md; | ||
line-height: @dialog-message-line-height; | ||
font-size: @font-size-md; | ||
} | ||
|
||
&__actions { | ||
display: flex; | ||
justify-content: flex-end; | ||
} | ||
|
||
&__button { | ||
margin-left: @dialog-button-margin-left; | ||
background-color: transparent; | ||
box-shadow: none; | ||
|
||
&:active { | ||
box-shadow: none; | ||
} | ||
} | ||
} |
Oops, something went wrong.