main
vue 61 lines 1.25 KB
Raw
1 <template>
2 <div class="icon" :class="{ boxed }" :style="`--size:${boxSize}px`">
3 <div v-if="boxed" class="bg"></div>
4 <Icon v-if="$slots.default" :size="iconFinalSize">
5 <slot></slot>
6 </Icon>
7 <Icon v-else :size="iconFinalSize" :name="iconName"></Icon>
8 </div>
9 </template>
10
11 <script setup lang="ts">
12 import { computed } from "vue"
13 import Icon from "@/components/common/Icon.vue"
14 import { useThemeStore } from "@/stores/theme"
15
16 const {
17 boxSize = 40,
18 iconSize = 28,
19 boxed = false,
20 iconName,
21 color
22 } = defineProps<{
23 boxSize?: number
24 iconSize?: number
25 iconName?: string
26 boxed?: boolean
27 color?: string
28 }>()
29
30 const style = computed(() => useThemeStore().style)
31
32 const iconColor = computed(() => color || style.value["primary-color"])
33 const iconBoxedSize = computed(() => (boxSize / 100) * 45)
34 const iconFinalSize = computed(() => (boxed ? iconBoxedSize.value : iconSize))
35 </script>
36
37 <style scoped lang="scss">
38 .icon {
39 color: v-bind(iconColor);
40 width: var(--size);
41 display: flex;
42 align-items: center;
43 justify-content: center;
44 position: relative;
45
46 &.boxed {
47 height: var(--size);
48
49 .bg {
50 background-color: v-bind(iconColor);
51 opacity: 0.1;
52 position: absolute;
53 top: 0;
54 left: 0;
55 border-radius: 50%;
56 width: 100%;
57 height: 100%;
58 }
59 }
60 }
61 </style>