UNPKG

@gits-id/icon

Version:

GITS Icon Component

38 lines (37 loc) 1.18 kB
import { defineComponent as d, ref as r, watch as f, computed as u, openBlock as o, createElementBlock as m, normalizeClass as p, unref as n, normalizeStyle as _, createBlock as y, toDisplayString as v } from "vue"; import { Icon as h } from "@iconify/vue/dist/offline"; import { loadIcon as z } from "@iconify/vue"; const k = ["xxs", "xs", "sm", "md", "lg", "xl"]; const x = { key: 2 }, C = d({ __name: "Icon", props: { name: null, size: { default: "md" } }, setup(c) { const e = c, s = r(!1), t = r(); async function a() { s.value = !0, t.value = await z(e.name).catch(() => { }), s.value = !1; } f(() => e.name, a); const l = u(() => `v-icon v-icon--${e.size}`), i = u(() => k.includes(String(e.size)) ? {} : { width: e.size, height: e.size }); return a(), (I, g) => s.value ? (o(), m("span", { key: 0, class: p(n(l)), style: _(n(i)) }, null, 6)) : t.value ? (o(), y(n(h), { key: 1, icon: t.value, class: p(n(l)), style: _(n(i)) }, null, 8, ["icon", "class", "style"])) : (o(), m("span", x, v(c.name), 1)); } }); export { C as Icon, C as default };