-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: edit PTab component design & separate folder tab compnent (#4784)
* fix: edit PTab component design & separate folder tab compnent Signed-off-by: samuel.park <[email protected]> * chore: small fix Signed-off-by: samuel.park <[email protected]> * chore: apply review Signed-off-by: samuel.park <[email protected]> --------- Signed-off-by: samuel.park <[email protected]>
- Loading branch information
1 parent
a014097
commit 2ddfee4
Showing
7 changed files
with
180 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
packages/mirinae/src/navigation/tabs/tab/components/FolderTab.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<script setup lang="ts"> | ||
import { reactive, ref, toRef } from 'vue'; | ||
import { onClickOutside } from '@vueuse/core'; | ||
import PI from '@/foundation/icons/PI.vue'; | ||
import { useContextMenuFixedStyle } from '@/hooks'; | ||
import PContextMenu from '@/inputs/context-menu/PContextMenu.vue'; | ||
import type { MenuItem } from '@/inputs/context-menu/type'; | ||
import type { TabItem } from '@/navigation/tabs/tab/type'; | ||
interface Props { | ||
tab: TabItem; | ||
activeTab: string; | ||
selectedFolderTab?: string; | ||
selectedContextMenuItem?: MenuItem; | ||
visibleSubMenu?: boolean; | ||
} | ||
const props = defineProps<Props>(); | ||
const emit = defineEmits<{(e: 'select-tab'): void; | ||
(e: 'select-tab-menu', value: MenuItem, idx?: number): void; | ||
}>(); | ||
const folderTabRef = ref<HTMLElement | null>(null); | ||
const contextMenuRef = ref<HTMLElement | null>(null); | ||
const state = reactive({ | ||
visible: props.visibleSubMenu, | ||
}); | ||
const handleSelectTab = () => { | ||
if (state.visible) { | ||
state.visible = false; | ||
} else { | ||
state.visible = true; | ||
} | ||
emit('select-tab'); | ||
}; | ||
const handleSelectTabMenu = (menu: MenuItem) => { | ||
state.visible = false; | ||
emit('select-tab-menu', menu); | ||
}; | ||
const { | ||
contextMenuStyle, | ||
} = useContextMenuFixedStyle({ | ||
useFixedMenuStyle: true, | ||
visibleMenu: toRef(state, 'visible'), | ||
targetRef: folderTabRef, | ||
position: 'left', | ||
menuRef: contextMenuRef, | ||
multiSelectable: false, | ||
}); | ||
onClickOutside(folderTabRef, () => { | ||
state.visible = false; | ||
}); | ||
</script> | ||
<template> | ||
<li ref="folderTabRef" | ||
:class="{'folder-tab': true, active: props.tab.subItems?.some((subItem) => activeTab === subItem.name)}" | ||
role="tab" | ||
@keydown.enter="handleSelectTab" | ||
@click="handleSelectTab" | ||
> | ||
<div class="content-wrapper"> | ||
<span class="label"> | ||
{{ tab.label }} | ||
</span> | ||
<p-i class="sub-item-dropdown-icon" | ||
:name="state.visible ? 'ic_chevron-up' : 'ic_chevron-down'" | ||
width="1.25rem" | ||
height="1.25rem" | ||
color="inherit" | ||
/> | ||
</div> | ||
<p-context-menu v-if="state.visible" | ||
ref="contextMenuRef" | ||
class="sub-item-menu" | ||
:style="contextMenuStyle" | ||
:menu="props.tab?.subItems || []" | ||
:selected="props.selectedContextMenuItem ? [props.selectedContextMenuItem]: undefined" | ||
@select="handleSelectTabMenu" | ||
/> | ||
</li> | ||
</template> | ||
<style lang="postcss"> | ||
.folder-tab { | ||
&.active { | ||
@apply text-primary border-primary; | ||
} | ||
.content-wrapper { | ||
@apply flex items-center justify-center w-full h-full; | ||
.label { | ||
@apply w-full text-label-md block truncate; | ||
} | ||
.sub-item-dropdown-icon { | ||
min-width: 1.25rem; | ||
margin-left: 0.25rem; | ||
} | ||
.sub-item-menu { | ||
position: absolute; | ||
top: 100%; | ||
left: 0; | ||
z-index: 100; | ||
width: max-content; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters