| 1 | <template> |
| 2 | <div class="sidebar-header flex items-center justify-between gap-4"> |
| 3 | <div class="flex grow" :class="{ 'justify-center': logoSmall }"> |
| 4 | <Logo |
| 5 | v-if="logoSmall" |
| 6 | type="small" |
| 7 | max-height="32px" |
| 8 | class="animate-[fade_calc(var(--sidebar-anim-duration)*2)_forwards_calc(var(--sidebar-anim-duration)/2)] opacity-0" |
| 9 | /> |
| 10 | <Logo |
| 11 | v-if="!logoSmall" |
| 12 | type="large" |
| 13 | max-height="28px" |
| 14 | class="animate-[fade_calc(var(--sidebar-anim-duration)*2)_forwards_calc(var(--sidebar-anim-duration)/2)] opacity-0" |
| 15 | /> |
| 16 | </div> |
| 17 | <Transition name="fade" mode="out-in"> |
| 18 | <div v-if="showPin" class="sidebar-pin flex items-center"> |
| 19 | <Icon :size="20" @click="sidebarCollapsed = !sidebarCollapsed"> |
| 20 | <span class="i-large"> |
| 21 | <Iconify v-if="sidebarCollapsed" :icon="CircleRegular" /> |
| 22 | <Iconify v-if="!sidebarCollapsed" :icon="DotCircleRegular" /> |
| 23 | </span> |
| 24 | <span class="i-small"> |
| 25 | <Iconify v-if="!sidebarCollapsed" :icon="CloseOutline" /> |
| 26 | </span> |
| 27 | </Icon> |
| 28 | </div> |
| 29 | </Transition> |
| 30 | </div> |
| 31 | </template> |
| 32 | |
| 33 | <script lang="ts" setup> |
| 34 | import { Icon as Iconify } from "@iconify/vue" |
| 35 | import { computed } from "vue" |
| 36 | import Logo from "@/app-layouts/common/Logo.vue" |
| 37 | import Icon from "@/components/common/Icon.vue" |
| 38 | import { useThemeStore } from "@/stores/theme" |
| 39 | |
| 40 | const { logoSmall } = defineProps<{ |
| 41 | logoSmall?: boolean |
| 42 | }>() |
| 43 | |
| 44 | const CircleRegular = "fa6-regular:circle" |
| 45 | const DotCircleRegular = "fa6-regular:circle-dot" |
| 46 | const CloseOutline = "carbon:chevron-left" |
| 47 | const themeStore = useThemeStore() |
| 48 | const showPin = computed<boolean>(() => !logoSmall) |
| 49 | const sidebarCollapsed = computed({ |
| 50 | get(): boolean { |
| 51 | return themeStore.sidebar.collapsed |
| 52 | }, |
| 53 | set() { |
| 54 | themeStore.toggleSidebar() |
| 55 | } |
| 56 | }) |
| 57 | </script> |
| 58 | |
| 59 | <style lang="scss" scoped> |
| 60 | @import "./variables"; |
| 61 | |
| 62 | .sidebar-header { |
| 63 | height: var(--toolbar-height); |
| 64 | min-height: var(--toolbar-height); |
| 65 | |
| 66 | .sidebar-pin { |
| 67 | height: 100%; |
| 68 | |
| 69 | :deep() { |
| 70 | .n-icon { |
| 71 | cursor: pointer; |
| 72 | |
| 73 | .i-large { |
| 74 | opacity: 0.3; |
| 75 | transition: opacity var(--sidebar-anim-ease) var(--sidebar-anim-duration); |
| 76 | } |
| 77 | |
| 78 | &:hover { |
| 79 | opacity: 1; |
| 80 | |
| 81 | .i-large { |
| 82 | opacity: 1; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | .i-large { |
| 89 | display: block; |
| 90 | } |
| 91 | .i-small { |
| 92 | display: none; |
| 93 | } |
| 94 | @media (max-width: $sidebar-bp) { |
| 95 | .i-large { |
| 96 | display: none; |
| 97 | } |
| 98 | .i-small { |
| 99 | display: block; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | &.fade-enter-from, |
| 104 | &.fade-leave-to { |
| 105 | opacity: 0; |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | .direction-rtl { |
| 111 | .sidebar-header { |
| 112 | .sidebar-pin { |
| 113 | .i-small { |
| 114 | svg { |
| 115 | transform: rotateY(180deg); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | </style> |