Add BxIconRaw tyoe

This commit is contained in:
redphx
2024-12-23 06:26:16 +07:00
parent 03b7c7358e
commit fc5219705c
8 changed files with 35 additions and 18 deletions

View File

@@ -83,3 +83,5 @@ export const BxIcon = {
UPLOAD: iconUpload,
AUDIO: iconSpeakerHigh,
} as const;
export type BxIconRaw = (typeof BxIcon)[keyof typeof BxIcon];

View File

@@ -1,4 +1,4 @@
import type { BxIcon } from "@utils/bx-icon";
import type { BxIconRaw } from "@utils/bx-icon";
import { setNearby } from "./navigation-utils";
import type { NavigationNearbyElements } from "@/modules/ui/dialog/navigation-dialog";
import type { PresetRecord, AllPresets } from "@/types/presets";
@@ -43,7 +43,7 @@ export type BxButtonOptions = Partial<{
style: ButtonStyle;
url: string;
classes: string[];
icon: typeof BxIcon;
icon: BxIconRaw;
label: string;
secondaryText: HTMLElement | string;
title: string;
@@ -149,8 +149,8 @@ function createElement<T extends keyof HTMLElementTagNameMap>(elmName: T, props?
const domParser = new DOMParser();
export function createSvgIcon(icon: typeof BxIcon) {
return domParser.parseFromString(icon.toString(), 'image/svg+xml').documentElement;
export function createSvgIcon(icon: BxIconRaw) {
return domParser.parseFromString(icon, 'image/svg+xml').documentElement;
}
const ButtonStyleIndices = Object.keys(ButtonStyleClass).map(i => parseInt(i));