|
| 1 | +<script setup lang="ts"> |
| 2 | +import IconButton from '~/components/IconButton.vue' |
| 3 | +import { |
| 4 | + detailsPanelVisible, |
| 5 | + detailsPosition, |
| 6 | + hideDetailsPanel, |
| 7 | + showDetailsPanel, |
| 8 | + toggleDetailsPosition, |
| 9 | +} from '~/composables/navigation' |
| 10 | +
|
| 11 | +function getDetailsPanelToggleRotation(action: 'show' | 'hide') { |
| 12 | + // `i-carbon:side-panel-close` is treated as "pointing right" by default. |
| 13 | + // We rotate it based on where the details panel is positioned. |
| 14 | + if (detailsPosition.value === 'right') { |
| 15 | + return action === 'hide' ? 'rotate-180' : '' |
| 16 | + } |
| 17 | + // detailsPosition === 'bottom' |
| 18 | + return action === 'hide' ? '-rotate-90' : 'rotate-90' |
| 19 | +} |
| 20 | +</script> |
| 21 | + |
| 22 | +<template> |
| 23 | + <IconButton |
| 24 | + v-tooltip.bottom="`Switch panel position (${detailsPosition === 'bottom' ? 'right' : 'bottom'})`" |
| 25 | + :title="`Switch panel position (${detailsPosition === 'bottom' ? 'right' : 'bottom'})`" |
| 26 | + icon="i-carbon-split-screen" |
| 27 | + :class="{ 'rotate-90': detailsPosition === 'right' }" |
| 28 | + @click="toggleDetailsPosition" |
| 29 | + /> |
| 30 | + <IconButton |
| 31 | + v-if="detailsPanelVisible" |
| 32 | + v-tooltip.bottom="detailsPosition === 'right' ? 'Hide Right Panel' : 'Hide Bottom Panel'" |
| 33 | + :title="detailsPosition === 'right' ? 'Hide Right Panel' : 'Hide Bottom Panel'" |
| 34 | + icon="i-carbon:side-panel-close" |
| 35 | + :class="getDetailsPanelToggleRotation('hide')" |
| 36 | + @click="hideDetailsPanel" |
| 37 | + /> |
| 38 | + <IconButton |
| 39 | + v-show="!detailsPanelVisible" |
| 40 | + v-tooltip.bottom="detailsPosition === 'right' ? 'Show Right Panel' : 'Show Bottom Panel'" |
| 41 | + :title="detailsPosition === 'right' ? 'Show Right Panel' : 'Show Bottom Panel'" |
| 42 | + icon="i-carbon:side-panel-close" |
| 43 | + :class="getDetailsPanelToggleRotation('show')" |
| 44 | + @click="showDetailsPanel" |
| 45 | + /> |
| 46 | +</template> |
0 commit comments