UNPKG

@tomiaa/live2d

Version:
47 lines (46 loc) 1.68 kB
import { createNamespacs as r } from "@tomiaa/utils"; import { loadingSvg as o, collapseSvg as p, switchPersonSvg as m, switchClothingSvg as u, expandSvg as L } from "../icons.js"; const c = r("live2d"); class E { /** * 创建 Loading 图标 */ static createLoading(t) { const e = document.createElement("i"); return e.innerHTML = o, e.classList.add(c.e("loading")), t.appendChild(e), e; } /** * 创建控制栏 */ static createControls(t, e, s, l) { const n = document.createElement("div"); n.classList.add(c.e("control")); const i = document.createElement("i"); i.innerHTML = p, i.setAttribute("data-tip", "收起"), i.addEventListener("click", l), n.appendChild(i); const a = document.createElement("i"); a.innerHTML = m, a.setAttribute("data-tip", "切换人物"), a.addEventListener("click", e), n.appendChild(a); const d = document.createElement("i"); return d.innerHTML = u, d.setAttribute("data-tip", "更换服装"), d.addEventListener("click", s), n.appendChild(d), t.appendChild(n), { elControl: n, elSwitchPerson: a, elSwitchClothing: d, elCollapse: i }; } /** * 创建展开按钮(收起后显示的图标,创建在 body 上) */ static createExpandButton(t) { const e = document.createElement("div"); return e.classList.add(c.e("expand")), e.innerHTML = L, e.setAttribute("data-tip", "展开"), e.addEventListener("click", t), document.body.appendChild(e), e; } /** * 更新切换服装按钮显示状态 */ static updateSwitchClothingVisibility(t, e) { t && (t.style.display = e ? "block" : "none"); } } export { E as UICreator };