Ensure unit of the size prop in the icon component

This commit is contained in:
2026-05-23 16:30:43 +02:00
committed by Gitea
parent 1679800272
commit 534734ce9a
+4 -1
View File
@@ -16,6 +16,7 @@ limitations under the License.
<script setup>
import { computed } from 'vue';
import { ensureUnit } from '@/utils/cssDimensions';
const props = defineProps({
name: {
@@ -34,8 +35,10 @@ const icons = import.meta.glob('@/assets/icons/*.svg', {
})
const Icon = computed(() => icons[`/src/assets/icons/${props.name}.svg`])
const size = computed(() => ensureUnit(props.size))
</script>
<template>
<img :src="Icon" :style="{ height: `${props.size}px`, width: `${props.size}px` }" />
<img :src="Icon" :style="{ height: `${size}`, width: `${size}` }" />
</template>