aboutsummaryrefslogtreecommitdiffstats
path: root/components/editor/EditorSidebarItem.vue
blob: 4696bb106d65973a926aa87d26cc5ee407f6a088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<script setup lang="ts">
import { computed, toRefs } from 'vue';

const props = defineProps<{
  item: EditorItem;
}>();

const { item } = toRefs(props);

const route = useRoute();

const setSelectedItem = () => {
  navigateTo({ path: `/item/${item.value.id}` })
};

const selected = computed(() => {
  return route.path.startsWith('/item') && route.params.id === item.value.id;
});
</script>

<template>
  <div id="item-container" @click.stop="setSelectedItem" :class="{ selected: selected }">
    <span id="item-title">
      <font-awesome-icon class="item-icon" :icon="['fas', 'cube']" />
      <span id="item-name">
        <span id="item-display-id">{{ item.id }}</span>
        <code id="item-display-type">{{ item.type }}</code>
      </span>
    </span>
  </div>
</template>

<style scoped>
#item-container {
  cursor: pointer;
  padding: 0.3rem 1rem;
  transition: background-color 0.3s;

  #item-title {
    display: flex;
    align-items: center;
    margin: 0;
    gap: 0.6rem;
    font-size: 0.8rem;

    #item-name {
      display: flex;
      flex-direction: column;
      align-items: left;

      #item-display-type {
        font-size: 0.6rem;
        color: var(--color-text-mute);
      }
    }
  }
}

.selected {
  background-color: var(--color-primary-mute) !important;
}

#item-container:hover {
  background-color: var(--color-hover);
}
</style>