58 lines
2.7 KiB
Vue
58 lines
2.7 KiB
Vue
<script setup>
|
|
// One folder row of a campaign entry list (actors, items or maps), nested by the depth the
|
|
// folder stands at. Toggling it collapses what is inside; its context menu renames the
|
|
// folder, colours it, and deletes it. Note folders have their own tree (NestedNoteList),
|
|
// which loads its contents one folder at a time.
|
|
import { ShowContextMenu } from '~/services/ContextMenu';
|
|
|
|
const props = defineProps({
|
|
folder: { type: Object, required: true },
|
|
collapsed: { type: Boolean, default: false },
|
|
// The padding of the level this folder stands at, from the sidebar's `rowIndent`.
|
|
indent: { type: Object, default: () => ({}) },
|
|
menu: { type: Array, default: () => [] },
|
|
toggleLabel: { type: String, default: '' }
|
|
});
|
|
|
|
const emit = defineEmits(['toggle']);
|
|
</script>
|
|
|
|
<template>
|
|
<button
|
|
class="entry-folder-row"
|
|
:class="{ 'has-color': !!folder.color }"
|
|
:style="[indent, folder.color ? { '--entry-color': folder.color } : null]"
|
|
type="button"
|
|
:aria-expanded="(!collapsed).toString()"
|
|
:aria-label="toggleLabel"
|
|
@click="emit('toggle')"
|
|
@contextmenu.prevent="ShowContextMenu(menu)"
|
|
>
|
|
<img
|
|
class="entry-folder-arrow"
|
|
:src="collapsed ? '/icons/iconoir/regular/nav-arrow-right.svg' : '/icons/iconoir/regular/nav-arrow-down.svg'"
|
|
alt=""
|
|
aria-hidden="true"
|
|
>
|
|
<img class="entry-folder-icon" src="/icons/iconoir/regular/folder.svg" alt="" aria-hidden="true">
|
|
<span class="entry-folder-name">{{ folder.name }}</span>
|
|
</button>
|
|
</template>
|
|
|
|
<style scoped>
|
|
/* The same row box as an entry, since folders and entries share the sidebar list and its
|
|
width rules. */
|
|
.entry-folder-row {
|
|
width: 100%; min-width: 0; box-sizing: border-box; margin: 0; padding: 8px 10px; border: 1px solid transparent;
|
|
border-radius: 8px; background: transparent; color: var(--color-text); text-align: left; display: flex;
|
|
align-items: center; gap: 6px; cursor: pointer; font: inherit;
|
|
}
|
|
.entry-folder-row:hover { background: var(--color-background-soft); }
|
|
.entry-folder-row:focus-visible { outline: 1px solid var(--color-link); }
|
|
.entry-folder-row.has-color { background: color-mix(in srgb, var(--entry-color) 32%, transparent); }
|
|
.entry-folder-row.has-color:hover { background: color-mix(in srgb, var(--entry-color) 50%, transparent); }
|
|
.entry-folder-arrow { width: 12px; height: 12px; flex: 0 0 12px; filter: invert(var(--color-icon-invert)); opacity: 0.6; }
|
|
.entry-folder-icon { width: 15px; height: 15px; flex: 0 0 15px; filter: invert(var(--color-icon-invert)); }
|
|
.entry-folder-name { min-width: 0; font-weight: bold; word-break: break-word; }
|
|
</style>
|