12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <template>
- <ButtonPane class="menus" :size="size" :dire="dire">
- <div
- v-for="menu in menus"
- :key="menu.key"
- class="menu"
- :style="menuStyle"
- :class="{ active: activeKey === menu.key, dire }"
- @click="menu.onClick && menu.onClick(menu)"
- >
- <ui-icon :type="menu.icon || 'close'" class="icon"/>
- <p v-if="menu.text">{{ menu.text }}</p>
- </div>
- </ButtonPane>
- </template>
- <script setup lang="ts">
- import ButtonPane from '@/components/button-pane/index.vue'
- import UiIcon from "@/components/base/components/icon/index.vue";
- import {computed} from "vue";
- type Menu = {
- key: any,
- text?: string,
- icon?: string,
- onClick?: (menu: Menu) => void
- }
- const props = withDefaults(
- defineProps<{ menus: Menu[], activeKey?: any, dire?: 'row' | 'column', size?: number }>(),
- {dire: 'row', size: 64}
- )
- const menuStyle = computed(() => {
- const offset = props.size / 4;
- return props.dire === 'row' ? { marginRight: offset + "px" } : { marginBottom: offset + 'px' }
- })
- </script>
- <style lang="scss" scoped>
- .menu {
- width: 56px;
- display: flex;
- flex-direction: column;
- cursor: pointer;
- height: 100%;
- text-align: center;
- transition: color .3s ease;
- color: #fff;
- &.active,
- &:hover {
- color: var(--colors-primary-base);
- }
- &.active {
- background: rgba(255, 255, 255, 0.1);;
- }
- .icon {
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 20px;
- flex: 1;
- }
- p {
- line-height: 17px;
- font-size: 12px;
- }
- }
- </style>
|