DashboardComponentDirectory.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <button @click="navigateToDirectory" :class="component.cssClass">
  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 scoped>
  37. .folder-container {
  38. display: grid;
  39. }
  40. button {
  41. display: flex;
  42. flex-direction: column;
  43. flex-grow: 1;
  44. justify-content: center;
  45. padding: 0.5em;
  46. box-shadow: 0 0 .6em #aaa;
  47. background-color: #fff;
  48. border-radius: .7em;
  49. border: 1px solid #ccc;
  50. cursor: pointer;
  51. transition: all 0.2s ease;
  52. font-size: .85em;
  53. }
  54. button:hover {
  55. background-color: #f5f5f5;
  56. border-color: #999;
  57. }
  58. button .icon {
  59. font-size: 3em;
  60. flex-grow: 1;
  61. align-content: center;
  62. }
  63. button .title {
  64. font-weight: 500;
  65. padding: 0.2em;
  66. }
  67. @media (prefers-color-scheme: dark) {
  68. button {
  69. box-shadow: 0 0 .6em #000;
  70. background-color: #111;
  71. border-color: #000;
  72. color: #fff;
  73. }
  74. button:hover {
  75. background-color: #222;
  76. border-color: #000;
  77. box-shadow: 0 0 6px #444;
  78. color: #fff;
  79. }
  80. }
  81. </style>