DashboardComponentDirectory.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <button
  3. class="directory-button"
  4. :class="component.cssClass"
  5. @click="navigateToDirectory"
  6. >
  7. <!-- eslint-disable vue/no-v-html -- intentional: directory icons from config (HTML entities / markup) -->
  8. <span
  9. class="icon"
  10. v-html="unicodeIcon"
  11. />
  12. <!-- eslint-enable vue/no-v-html -->
  13. <span class="title">{{ component.title }}</span>
  14. </button>
  15. </template>
  16. <script setup>
  17. import { useRouter } from 'vue-router'
  18. import { computed } from 'vue'
  19. const router = useRouter()
  20. const props = defineProps({
  21. component: {
  22. type: Object,
  23. required: true
  24. }
  25. })
  26. function getUnicodeIcon (icon) {
  27. if (icon === '' || !icon) {
  28. return '&#x1f4c1;' // Default folder icon
  29. } else {
  30. return unescape(icon)
  31. }
  32. }
  33. const unicodeIcon = computed(() => {
  34. return getUnicodeIcon(props.component.icon)
  35. })
  36. function navigateToDirectory () {
  37. const params = { title: props.component.title }
  38. if (props.component.entityType && props.component.entityKey) {
  39. params.entityType = props.component.entityType
  40. params.entityKey = props.component.entityKey
  41. }
  42. router.push({ name: 'Dashboard', params })
  43. }
  44. </script>
  45. <style>
  46. @layer components {
  47. .directory-button {
  48. display: flex;
  49. flex-direction: column;
  50. flex-grow: 1;
  51. justify-content: center;
  52. padding: 0.5em;
  53. box-shadow: 0 0 .6em #aaa;
  54. background-color: #fff;
  55. border-radius: .7em;
  56. border: 1px solid #ccc;
  57. cursor: pointer;
  58. transition: all 0.2s ease;
  59. font-size: .85em;
  60. }
  61. .directory-button:hover {
  62. background-color: #f5f5f5;
  63. border-color: #999;
  64. }
  65. .directory-button .icon {
  66. font-size: 3em;
  67. flex-grow: 1;
  68. align-content: center;
  69. }
  70. .directory-button .title {
  71. font-weight: 500;
  72. padding: 0.2em;
  73. }
  74. @media (prefers-color-scheme: dark) {
  75. .directory-button {
  76. box-shadow: 0 0 .6em #000;
  77. background-color: #111;
  78. border-color: #000;
  79. color: #fff;
  80. }
  81. .directory-button:hover {
  82. background-color: #222;
  83. border-color: #000;
  84. box-shadow: 0 0 6px #444;
  85. color: #fff;
  86. }
  87. }
  88. }
  89. </style>