@hugeicons/vue
Version:
HugeIcons Pro Vue Component Library https://hugeicons.com
84 lines (75 loc) • 2.06 kB
JavaScript
import { defineComponent, computed } from 'vue';
var _sfc_main = defineComponent({
name: 'HugeiconsIcon',
inheritAttrs: false,
props: {
icon: {
type: Array ,
required: true
},
size: {
type: [Number, String],
default: 24,
validator(value) {
const size = typeof value === 'string' ? parseInt(value, 10) : value;
return !isNaN(size) && size > 0;
}
},
strokeWidth: {
type: Number,
default: undefined
},
absoluteStrokeWidth: {
type: Boolean,
default: false
},
altIcon: {
type: Array ,
default: undefined
},
showAlt: {
type: Boolean,
default: false
},
color: {
type: String,
default: 'currentColor'
}
},
setup(props) {
const computedSize = computed(() => {
const size = typeof props.size === 'string' ? parseInt(props.size, 10) : props.size;
return !isNaN(size) && size > 0 ? size : 24;
});
const calculatedStrokeWidth = computed(() => {
if (props.strokeWidth === undefined) return undefined;
return props.absoluteStrokeWidth
? (props.strokeWidth * 24) / computedSize.value
: props.strokeWidth;
});
const currentIcon = computed(() => {
return props.altIcon && props.showAlt ? props.altIcon : props.icon;
});
const transformAttrs = (attrs, strokeWidth) => {
const result = {};
for (const [key, value] of Object.entries(attrs)) {
const kebabKey = key.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
result[kebabKey] = value;
}
// Add stroke properties to child elements if strokeWidth is defined
if (strokeWidth !== undefined) {
result['stroke-width'] = strokeWidth;
result['stroke'] = 'currentColor';
}
return result;
};
return {
computedSize,
calculatedStrokeWidth,
transformAttrs,
currentIcon
};
}
});
export { _sfc_main as default };
//# sourceMappingURL=HugeiconsIcon.vue2.js.map