Skip to content

Commit

Permalink
弹框早期制作
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 committed May 26, 2024
1 parent c29f57f commit 4472336
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
84 changes: 84 additions & 0 deletions .vitepress/theme/components/ModalComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<script setup>
import { ref } from 'vue'
const showModal = ref(false)
</script>

<template>
<button class="modal-button" @click="showModal = true">懒汉下载</button>

<ClientOnly>
<Teleport to="body">
<Transition name="modal">
<div v-show="showModal" class="modal-mask">
<div class="modal-container">
<slot>内容和标题</slot>
<div class="modal-footer">
<button class="modal-button" @click="showModal = false">
关闭
</button>
</div>
</div>
</div>
</Transition>
</Teleport>
</ClientOnly>
</template>

<style scoped>
.modal-mask {
position: fixed;
z-index: 200;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
transition: opacity 0.3s ease;
}
.modal-container {
width: 300px;
margin: auto;
padding: 20px 30px;
background-color: var(--vp-c-bg);
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
transition: all 0.3s ease;
}
.modal-footer {
margin-top: 8px;
text-align: right;
}
.modal-button {
border: none;
border-radius: 6px;
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
color: #fff;
transition: all 0.2s ease-in-out;
margin: 1rem auto;
background-color: #2196f3;
box-shadow: 0 4px #1062ad;
}
.modal-button:active {
transform: translateY(5px);
box-shadow: 0 0 #999;
}
.modal-enter-from,
.modal-leave-to {
opacity: 0;
}
.modal-enter-from .modal-container,
.modal-leave-to .modal-container {
transform: scale(1.1);
}
</style>
4 changes: 3 additions & 1 deletion .vitepress/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import DefaultTheme from 'vitepress/theme'
import { h } from 'vue'
import BannerComponent from './components/BannerComponent.vue'
import ButtonComponent from './components/ButtonComponent.vue'
import ModalComponent from './components/ModalComponent.vue'

export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('ButtonComponent', ButtonComponent)
app.component('ButtonComponent', ButtonComponent),
app.component('ModalComponent', ModalComponent)
},
Layout() {
return h(DefaultTheme.Layout, null, {
Expand Down
10 changes: 5 additions & 5 deletions modpacks/index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup>
import ButtonComponent from '../.vitepress/theme/components/ButtonComponent.vue';

</script># xxx汉化下载
# xxx汉化下载
<div style="display: flex">
<img src="" style="width:50%" alt="图片1">
<img src="" style="width:50%" alt="图片2">
</div>

<div style="display: flex;">
<ButtonComponent link="">立即下载</ButtonComponent>
<ButtonComponent buttonClass='button2' link="">懒汉下载</ButtonComponent>
<ModalComponent>
<template v-slot>
</template>
</ModalComponent>
</div>

## 其他
Expand Down

0 comments on commit 4472336

Please sign in to comment.