104 lines
2.4 KiB
Vue
104 lines
2.4 KiB
Vue
<template>
|
|
<aside class="task-sidebar">
|
|
<button
|
|
v-for="item in menus"
|
|
:key="item.key"
|
|
class="sidebar-item"
|
|
:class="{ 'is-active': item.key === modelValue }"
|
|
@click="$emit('update:modelValue', item.key)"
|
|
>
|
|
<span v-if="item.key === modelValue" class="sidebar-indicator"></span>
|
|
<img
|
|
class="sidebar-icon"
|
|
:src="item.key === modelValue ? item.iconActive : item.iconInactive"
|
|
alt=""
|
|
aria-hidden="true"
|
|
/>
|
|
<span class="sidebar-label">{{ item.label }}</span>
|
|
</button>
|
|
</aside>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import chengjiuN from '@/assets/tasks/chengjiuN.svg'
|
|
import chengjiuY from '@/assets/tasks/chengjiuY.svg'
|
|
import jiazhangN from '@/assets/tasks/jiazhangN.svg'
|
|
import richangN from '@/assets/tasks/richangN.svg'
|
|
import richangY from '@/assets/tasks/richangY.svg'
|
|
import xinshouY from '@/assets/tasks/xinshouY.svg'
|
|
|
|
export type TaskTab = 'newbie' | 'daily' | 'achievement' | 'parent'
|
|
|
|
defineProps<{ modelValue: TaskTab }>()
|
|
defineEmits<{ (e: 'update:modelValue', value: TaskTab): void }>()
|
|
|
|
const menus: Array<{ key: TaskTab; label: string; iconActive: string; iconInactive: string }> = [
|
|
{ key: 'newbie', label: '新手', iconActive: xinshouY, iconInactive: xinshouY },
|
|
{ key: 'daily', label: '日常', iconActive: richangY, iconInactive: richangN },
|
|
{ key: 'achievement', label: '成就', iconActive: chengjiuY, iconInactive: chengjiuN },
|
|
{ key: 'parent', label: '家长', iconActive: jiazhangN, iconInactive: jiazhangN },
|
|
]/
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.task-sidebar {
|
|
width: 220px;
|
|
flex-shrink: 0;
|
|
border-radius: 12px;
|
|
padding: 64px 0;
|
|
background: #f5f9fc;
|
|
border: 2px solid #fff;
|
|
}
|
|
|
|
.sidebar-item {
|
|
position: relative;
|
|
display: flex;
|
|
width: 100%;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 32px;
|
|
margin-bottom: 8px;
|
|
border: none;
|
|
background: transparent;
|
|
text-align: left;
|
|
font-size: 18px;
|
|
color: #000;
|
|
cursor: pointer;
|
|
|
|
&:hover {
|
|
background: #e5eaf5;
|
|
}
|
|
|
|
&.is-active {
|
|
background: #fff;
|
|
color: #121212;
|
|
|
|
&:hover {
|
|
background: #fff;
|
|
}
|
|
}
|
|
}
|
|
|
|
.sidebar-indicator {
|
|
position: absolute;
|
|
left: 0;
|
|
height: 64px;
|
|
width: 6px;
|
|
border-top-right-radius: 12px;
|
|
border-bottom-right-radius: 12px;
|
|
background: var(--color-brand);
|
|
}
|
|
|
|
.sidebar-icon {
|
|
height: 28px;
|
|
width: 28px;
|
|
flex-shrink: 0;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.sidebar-label {
|
|
font-size: 28px;
|
|
margin-left: 16px;
|
|
}
|
|
</style>
|