DashboardComponentDirectory.vue 1.9 KB

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