generated from Seekra/repository-template
Ensure unit of the size prop in the icon component
This commit is contained in:
@@ -16,6 +16,7 @@ limitations under the License.
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { ensureUnit } from '@/utils/cssDimensions';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: {
|
name: {
|
||||||
@@ -34,8 +35,10 @@ const icons = import.meta.glob('@/assets/icons/*.svg', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const Icon = computed(() => icons[`/src/assets/icons/${props.name}.svg`])
|
const Icon = computed(() => icons[`/src/assets/icons/${props.name}.svg`])
|
||||||
|
|
||||||
|
const size = computed(() => ensureUnit(props.size))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<img :src="Icon" :style="{ height: `${props.size}px`, width: `${props.size}px` }" />
|
<img :src="Icon" :style="{ height: `${size}`, width: `${size}` }" />
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user