PluginProbe
Hostinger Tools / 3.0.34
Hostinger Tools v3.0.34
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / vue-frontend / src / components / Icon / Icon.vue

Icon.vue in Hostinger Tools 3.0.34, at vue-frontend/src/components/Icon/Icon.vue

55 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <script lang="ts" setup>
2 import { computed } from "vue";
3 import type { Color } from "@/types";
4 import type { IconUnion } from "@/types/enums/iconModels";
5 import { wrapInCssVar } from "@/utils/helpers";
6 import { defineAsyncComponent } from "vue";
7 import { toTitleCase } from "@/utils/helpers";
8 import { kebabToCamel } from "@/utils/services/snakeCamelService";
9
10 interface Props {
11 dimensions?: number;
12 color?: Color;
13 name: IconUnion;
14 }
15
16 const props = withDefaults(defineProps<Props>(), {
17 dimensions: 24,
18 color: "white",
19 });
20
21 const iconColor = computed(() => {
22 if (!props.color) return "";
23
24 return wrapInCssVar(props.color);
25 });
26
27 const selectedIcon = computed(() => {
28 return defineAsyncComponent(
29 () =>
30 import(
31 `@/components/Icon/Icons/${kebabToCamel(toTitleCase(props.name))}.vue`
32 )
33 );
34 });
35 </script>
36
37 <template>
38 <svg class="icon" aria-hidden="true">>
39 <g>
40 <Component :is="selectedIcon" />
41 </g>
42 </svg>
43 </template>
44
45 <style lang="scss" scoped>
46 .icon {
47 transition: 0.3s ease transform;
48 fill: currentColor;
49 color: v-bind(iconColor);
50 width: v-bind("dimensions + 'px'");
51 height: v-bind("dimensions + 'px'");
52 min-width: v-bind("dimensions + 'px'");
53 }
54 </style>
55