perf: improve modal component style

pull/609/head^2
Ryan Wang 2022-09-11 17:10:25 +08:00
parent 8e3578f445
commit e4bbc68c23
11 changed files with 76 additions and 67 deletions

View File

@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { IconArrowLeft, IconArrowRight } from "@/icons/icons";
import { VButton } from "../../components/button"; import { VButton } from "../../components/button";
import { VModal } from "../../components/modal"; import { VModal } from "../../components/modal";
import { VSpace } from "../../components/space"; import { VSpace } from "../../components/space";
@ -13,7 +14,7 @@ function initState() {
} }
</script> </script>
<template> <template>
<Story :init-state="initState" title="Modal"> <Story :init-state="initState" title="Modal" class="h-full">
<template #default="{ state }"> <template #default="{ state }">
<VButton type="secondary" @click="state.visible = true">打开</VButton> <VButton type="secondary" @click="state.visible = true">打开</VButton>
<VModal <VModal
@ -21,7 +22,17 @@ function initState() {
:fullscreen="state.fullscreen" :fullscreen="state.fullscreen"
:title="state.title" :title="state.title"
:width="state.width" :width="state.width"
:mount-to-body="true"
> >
<template #actions>
<span>
<IconArrowLeft role="button" />
</span>
<span>
<IconArrowRight role="button" />
</span>
</template>
<div class="flex flex-col"> <div class="flex flex-col">
<img class="w-full" src="https://ryanc.cc/avatar" /> <img class="w-full" src="https://ryanc.cc/avatar" />
<img class="w-full" src="https://ryanc.cc/avatar" /> <img class="w-full" src="https://ryanc.cc/avatar" />
@ -38,11 +49,5 @@ function initState() {
</template> </template>
</VModal> </VModal>
</template> </template>
<template #controls="{ state }">
<HstCheckbox v-model="state.visible" title="Visible" />
<HstText v-model="state.title" title="Title" />
<HstNumber v-model="state.width" title="Width" />
<HstCheckbox v-model="state.fullscreen" title="Fullscreen" />
</template>
</Story> </Story>
</template> </template>

View File

@ -97,14 +97,14 @@ watch(
:style="contentStyles" :style="contentStyles"
class="modal-content transform transition-all" class="modal-content transform transition-all"
> >
<div v-if="$slots.header || title" class="modal-header"> <div v-if="$slots.header || title" class="modal-header group">
<slot name="header"> <slot name="header">
<div class="modal-header-title">{{ title }}</div> <div class="modal-header-title">{{ title }}</div>
<div class="modal-header-actions flex flex-row"> <div class="modal-header-actions">
<slot name="actions"></slot> <slot name="actions"></slot>
<div class="modal-header-action" @click="handleClose()"> <span class="bg-gray-50" @click="handleClose()">
<IconClose /> <IconClose />
</div> </span>
</div> </div>
</slot> </slot>
</div> </div>
@ -159,25 +159,33 @@ watch(
.modal-header { .modal-header {
@apply flex @apply flex
justify-between justify-between
border-b; border-b
items-center
select-none;
padding: 10px 16px;
.modal-header-title { .modal-header-title {
@apply self-center @apply text-base
text-base font-medium;
font-bold;
padding: 12px 16px;
} }
.modal-header-actions { .modal-header-actions {
@apply self-center @apply flex
h-full; flex-row
.modal-header-action { gap-2;
@apply cursor-pointer; span {
padding: 12px 16px; @apply cursor-pointer
rounded-full
&:hover { w-7
@apply bg-gray-100; h-7
} inline-flex
items-center
justify-center
hover:bg-gray-100
select-none
text-gray-600
hover:text-gray-900
group-hover:hidden;
} }
} }
} }

View File

@ -182,12 +182,12 @@ onMounted(() => {
@close="onDetailModalClose" @close="onDetailModalClose"
> >
<template #actions> <template #actions>
<div class="modal-header-action" @click="handleSelectPrevious"> <span @click="handleSelectPrevious">
<IconArrowLeft /> <IconArrowLeft />
</div> </span>
<div class="modal-header-action" @click="handleSelectNext"> <span @click="handleSelectNext">
<IconArrowRight /> <IconArrowRight />
</div> </span>
</template> </template>
</AttachmentDetailModal> </AttachmentDetailModal>
<AttachmentUploadModal <AttachmentUploadModal

View File

@ -103,9 +103,9 @@ watch(
> >
<template #actions> <template #actions>
<FloatingDropdown> <FloatingDropdown>
<div v-tooltip="`添加存储策略`" class="modal-header-action"> <span v-tooltip="`添加存储策略`">
<IconAddCircle /> <IconAddCircle />
</div> </span>
<template #popper> <template #popper>
<div class="w-72 p-4"> <div class="w-72 p-4">
<ul class="space-y-1"> <ul class="space-y-1">

View File

@ -82,11 +82,11 @@ watch(
> >
<template #actions> <template #actions>
<FloatingDropdown> <FloatingDropdown>
<div v-tooltip="`选择存储策略`" class="modal-header-action"> <span v-tooltip="`选择存储策略`">
<span class="text-sm"> <span class="text-sm">
{{ selectedPolicy?.spec.displayName || "无存储策略" }} {{ selectedPolicy?.spec.displayName || "无存储策略" }}
</span> </span>
</div> </span>
<template #popper> <template #popper>
<div class="w-72 p-4"> <div class="w-72 p-4">
<ul class="space-y-1"> <ul class="space-y-1">

View File

@ -179,27 +179,22 @@ await handleFetchAttachments();
@close="selectedAttachment = undefined" @close="selectedAttachment = undefined"
> >
<template #actions> <template #actions>
<div <span
v-if="selectedAttachment && selectedAttachments.has(selectedAttachment)" v-if="selectedAttachment && selectedAttachments.has(selectedAttachment)"
class="modal-header-action"
@click="handleSelect(selectedAttachment)" @click="handleSelect(selectedAttachment)"
> >
<IconCheckboxFill /> <IconCheckboxFill />
</div> </span>
<div <span v-else @click="handleSelect(selectedAttachment)">
v-else
class="modal-header-action"
@click="handleSelect(selectedAttachment)"
>
<IconCheckboxCircle /> <IconCheckboxCircle />
</div> </span>
<div class="modal-header-action" @click="handleSelectPrevious"> <span @click="handleSelectPrevious">
<IconArrowLeft /> <IconArrowLeft />
</div> </span>
<div class="modal-header-action" @click="handleSelectNext"> <span @click="handleSelectNext">
<IconArrowRight /> <IconArrowRight />
</div> </span>
</template> </template>
</AttachmentDetailModal> </AttachmentDetailModal>
</template> </template>

View File

@ -201,12 +201,12 @@ const handleSelectUser = (user?: User) => {
@close="onSettingModalClose" @close="onSettingModalClose"
> >
<template #actions> <template #actions>
<div class="modal-header-action" @click="handleSelectPrevious"> <span @click="handleSelectPrevious">
<IconArrowLeft /> <IconArrowLeft />
</div> </span>
<div class="modal-header-action" @click="handleSelectNext"> <span @click="handleSelectNext">
<IconArrowRight /> <IconArrowRight />
</div> </span>
</template> </template>
</SinglePageSettingModal> </SinglePageSettingModal>
<VCard :body-class="['!p-0']" class="rounded-none border-none shadow-none"> <VCard :body-class="['!p-0']" class="rounded-none border-none shadow-none">

View File

@ -330,12 +330,12 @@ function handleContributorFilterItemChange(user?: User) {
@close="onSettingModalClose" @close="onSettingModalClose"
> >
<template #actions> <template #actions>
<div class="modal-header-action" @click="handleSelectPrevious"> <span @click="handleSelectPrevious">
<IconArrowLeft /> <IconArrowLeft />
</div> </span>
<div class="modal-header-action" @click="handleSelectNext"> <span @click="handleSelectNext">
<IconArrowRight /> <IconArrowRight />
</div> </span>
</template> </template>
</PostSettingModal> </PostSettingModal>
<VPageHeader title="文章"> <VPageHeader title="文章">

View File

@ -34,13 +34,14 @@ const onVisibleChange = (visible: boolean) => {
@update:visible="onVisibleChange" @update:visible="onVisibleChange"
> >
<template #actions> <template #actions>
<a <span>
class="modal-header-action" <a
href="https://halo.run/archives/halo-154-released.html" href="https://halo.run/archives/halo-154-released.html"
target="_blank" target="_blank"
> >
<IconLink /> <IconLink />
</a> </a>
</span>
</template> </template>
<div class="flex h-full items-center justify-center"> <div class="flex h-full items-center justify-center">
<iframe <iframe

View File

@ -137,12 +137,12 @@ watch(
@update:visible="onVisibleChange" @update:visible="onVisibleChange"
> >
<template #actions> <template #actions>
<div class="modal-header-action" @click="emit('previous')"> <span @click="emit('previous')">
<IconArrowLeft /> <IconArrowLeft />
</div> </span>
<div class="modal-header-action" @click="emit('next')"> <span @click="emit('next')">
<IconArrowRight /> <IconArrowRight />
</div> </span>
</template> </template>
<FormKit <FormKit
id="tag-form" id="tag-form"

View File

@ -187,10 +187,10 @@ const handleRawModeChange = () => {
@update:visible="onVisibleChange" @update:visible="onVisibleChange"
> >
<template #actions> <template #actions>
<div class="modal-header-action" @click="handleRawModeChange"> <span @click="handleRawModeChange">
<IconCodeBoxLine v-if="!rawMode" /> <IconCodeBoxLine v-if="!rawMode" />
<IconEye v-else /> <IconEye v-else />
</div> </span>
</template> </template>
<VCodemirror v-show="rawMode" v-model="raw" height="50vh" language="yaml" /> <VCodemirror v-show="rawMode" v-model="raw" height="50vh" language="yaml" />