diff options
Diffstat (limited to 'viewer/src/views/layout/top/LayoutCommand.vue')
-rw-r--r-- | viewer/src/views/layout/top/LayoutCommand.vue | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/viewer/src/views/layout/top/LayoutCommand.vue b/viewer/src/views/layout/top/LayoutCommand.vue new file mode 100644 index 0000000..8919da3 --- /dev/null +++ b/viewer/src/views/layout/top/LayoutCommand.vue | |||
@@ -0,0 +1,127 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | ||
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2022 Guillaume FOUET | ||
5 | -- 2020 Pacien TRAN-GIRARD | ||
6 | -- | ||
7 | -- This program is free software: you can redistribute it and/or modify | ||
8 | -- it under the terms of the GNU Affero General Public License as | ||
9 | -- published by the Free Software Foundation, either version 3 of the | ||
10 | -- License, or (at your option) any later version. | ||
11 | -- | ||
12 | -- This program is distributed in the hope that it will be useful, | ||
13 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | -- GNU Affero General Public License for more details. | ||
16 | -- | ||
17 | -- You should have received a copy of the GNU Affero General Public License | ||
18 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
19 | --> | ||
20 | |||
21 | <template> | ||
22 | <div | ||
23 | class="flex" | ||
24 | :class="$style.commandBtns" | ||
25 | > | ||
26 | <LdLink | ||
27 | :title="t('command.search.slider')" | ||
28 | tabindex="10" | ||
29 | @click="uiStore.toggleFullWidth()" | ||
30 | > | ||
31 | <fa-icon | ||
32 | :icon="commandToggleSearchPanelIcon" | ||
33 | size="lg" | ||
34 | /> | ||
35 | </LdLink> | ||
36 | <LayoutCommandSort :tabindex="20" /> | ||
37 | <LdLink | ||
38 | :class="{ disabled: isEntryPoint(), [$style.commandSecondary]: true }" | ||
39 | :title="t('command.back')" | ||
40 | tabindex="30" | ||
41 | @click="isEntryPoint() || router.back()" | ||
42 | > | ||
43 | <fa-icon | ||
44 | :icon="faArrowLeft" | ||
45 | size="lg" | ||
46 | /> | ||
47 | </LdLink> | ||
48 | <LdLink | ||
49 | :to="parent" | ||
50 | :class="{ disabled: isRoot }" | ||
51 | :title="t('command.parent')" | ||
52 | tabindex="40" | ||
53 | > | ||
54 | <fa-icon | ||
55 | :icon="faFolder" | ||
56 | size="xs" | ||
57 | /> | ||
58 | <fa-icon | ||
59 | :icon="faLevelUpAlt" | ||
60 | size="lg" | ||
61 | /> | ||
62 | </LdLink> | ||
63 | </div> | ||
64 | </template> | ||
65 | |||
66 | <script setup lang="ts"> | ||
67 | import { Item } from '@/@types/gallery'; | ||
68 | import LdLink from '@/components/LdLink.vue'; | ||
69 | import { useUiStore } from '@/store/uiStore'; | ||
70 | import { faAngleDoubleLeft, faArrowLeft, faFolder, faLevelUpAlt, faSearch } from '@fortawesome/free-solid-svg-icons'; | ||
71 | import { computedEager } from '@vueuse/shared'; | ||
72 | import { computed } from 'vue'; | ||
73 | import { useI18n } from 'vue-i18n'; | ||
74 | import { useRoute, useRouter } from 'vue-router'; | ||
75 | import LayoutCommandSort from './LayoutCommandSort.vue'; | ||
76 | |||
77 | const props = defineProps({ | ||
78 | currentItemPath: { type: Array<Item>, required: true }, | ||
79 | }); | ||
80 | |||
81 | const { t } = useI18n(); | ||
82 | const route = useRoute(); | ||
83 | const router = useRouter(); | ||
84 | const uiStore = useUiStore(); | ||
85 | |||
86 | const commandToggleSearchPanelIcon = computed(() => uiStore.fullWidth ? faSearch : faAngleDoubleLeft); | ||
87 | const isRoot = computedEager(() => props.currentItemPath.length <= 1 && !uiStore.searchMode); | ||
88 | const parent = computed(() => { | ||
89 | if (uiStore.searchMode) return decodeURIComponent(route.path); | ||
90 | const ln = props.currentItemPath.length; | ||
91 | if (ln > 1) return props.currentItemPath[ln - 2]; | ||
92 | return ''; | ||
93 | }); | ||
94 | |||
95 | function isEntryPoint() { | ||
96 | return history.state?.ldgallery === 'ENTRYPOINT'; // Set by MainLayout.vue | ||
97 | } | ||
98 | </script> | ||
99 | |||
100 | <style lang="scss" module> | ||
101 | @import "~@/assets/scss/theme"; | ||
102 | |||
103 | .commandBtns { | ||
104 | background-color: $command-buttons-bgcolor; | ||
105 | justify-content: space-around; | ||
106 | vertical-align: middle; | ||
107 | align-items: center; | ||
108 | flex: 0 0 $layout-left; | ||
109 | user-select: none; | ||
110 | |||
111 | > a { | ||
112 | // normalise icon active boxes | ||
113 | width: $layout-top; | ||
114 | line-height: calc($layout-top - 4px); // 4px For the focus border | ||
115 | text-align: center; | ||
116 | vertical-align: middle; | ||
117 | } | ||
118 | |||
119 | @media only screen and (max-width: $tablet) { | ||
120 | flex: 0 1; | ||
121 | |||
122 | > .commandSecondary { | ||
123 | display: none; | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | </style> | ||