feat: toggle editor mode button

This commit is contained in:
KUN1007 2023-09-04 02:52:49 +08:00
parent fe5d2cefe1
commit 4a42f94b32
5 changed files with 108 additions and 8 deletions

View file

@ -2,6 +2,8 @@
import { ref } from 'vue'
//
import { Icon } from '@iconify/vue'
//
import SwitchButton from './SwitchButton.vue'
// css
import 'animate.css'
@ -63,6 +65,13 @@ const handelClickSettings = () => {
/>
<span>500 px</span>
</div>
<!-- 是否显示编辑器高级选项 -->
<div class="editor-advance-title">
<span> 高级选项 </span>
<!-- 切换按钮 -->
<SwitchButton />
</div>
</div>
</Transition>
</div>
@ -93,7 +102,6 @@ const handelClickSettings = () => {
}
.settings-menu {
height: 100px;
padding: 10px;
z-index: 1009;
position: absolute;
@ -104,6 +112,24 @@ const handelClickSettings = () => {
border-radius: 5px;
display: flex;
flex-direction: column;
.editor-height-title {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 17px;
}
.editor-advance-title {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 17px;
}
.editor-height {
margin-bottom: 20px;
}
}
.count {

View file

@ -0,0 +1,72 @@
<!-- KUNGalgame 通用切换按钮 -->
<script setup lang="ts">
// store
import { useKUNGalgameEditStore } from '@/store/modules/edit'
import { storeToRefs } from 'pinia'
// 使 store
const settingsStore = useKUNGalgameEditStore()
const { isShowAdvance } = storeToRefs(settingsStore)
// toolbar
const toggleEditorMode = () => {
isShowAdvance.value = !isShowAdvance.value
}
</script>
<template>
<input type="checkbox" id="switch" /><label
@click="toggleEditorMode"
for="switch"
>Toggle</label
>
</template>
<style lang="scss" scoped>
input {
height: 0;
width: 0;
visibility: hidden;
}
label {
cursor: pointer;
text-indent: -9999px;
width: 47px;
height: 24px;
background: var(--kungalgame-trans-blue-2);
display: block;
border-radius: 100px;
position: relative;
}
label:after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 20px;
height: 20px;
background: var(--kungalgame-white);
border-radius: 15px;
transition: 0.3s;
}
input:checked + label {
background: var(--kungalgame-blue-4);
}
input:checked + label:after {
left: calc(100% - 2px);
transform: translateX(-100%);
}
// centering
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>

View file

@ -10,8 +10,10 @@ interface Topic {
/**
*
* @param {number} editorHeight -
* @param {boolean} isShowAdvance -
*/
editorHeight: number
isShowAdvance: boolean
/**
*
@ -37,12 +39,14 @@ export const useKUNGalgameEditStore = defineStore({
id: 'edit',
persist: true,
state: (): Topic => ({
isSave: false,
isShowAdvance: false,
editorHeight: 300,
title: '',
content: '',
tags: [],
category: [],
isSave: false,
}),
getters: {},
actions: {

View file

@ -91,9 +91,8 @@ watch(
/*
以便能够正确地计算移动的动画 */
.list-leave-active {
/**
* 宽度为单个话题总宽度减去用户部分的宽度这里为 2 + 5 + 60 + 5 + 2 = 74px
*/
/**
这里为 2 + 5 + 60 + 5 + 2 = 74px */
width: calc(100% - 74px);
position: absolute;
}

View file

@ -33,9 +33,8 @@ const props = defineProps(['data'])
&:last-child {
margin-bottom: 0;
}
/**
* 宽度为单个话题总宽度减去用户部分的宽度这里为 2 + 5 + 60 + 5 + 2 = 74px
*/
/**
这里为 2 + 5 + 60 + 5 + 2 = 74px */
a {
width: calc(100% - 74px);
}