Highlight the active search term in names/classnames (grid + table), add zebra striping and a left accent bar on selected table rows, fade the results list when switching grid/table or on first load, and swap the broken-icon fallback for a cleaner placeholder.
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import type { SyntheticEvent } from "react";
|
|
|
|
import type { FurniItem } from "./studio-types";
|
|
|
|
export function getFurniImageUrl(item: FurniItem) {
|
|
if (item.iconUrl) return item.iconUrl;
|
|
const base = item.classname.includes("*")
|
|
? item.classname.substring(0, item.classname.indexOf("*"))
|
|
: item.classname;
|
|
return `https://images.habbo.com/dcr/hof_furni/${item.revision}/${encodeURIComponent(base)}_icon.png`;
|
|
}
|
|
|
|
export function getFurniIconUrl(classname: string, revision: number) {
|
|
const iconName = classname.replace(/\*/g, "_");
|
|
return `https://images.habbo.com/dcr/hof_furni/${revision}/${encodeURIComponent(iconName)}_icon.png`;
|
|
}
|
|
|
|
export function handleImgError(
|
|
e: SyntheticEvent<HTMLImageElement>,
|
|
item: FurniItem,
|
|
) {
|
|
const img = e.target as HTMLImageElement;
|
|
const iconName = item.classname.replace(/\*/g, "_");
|
|
if (!img.dataset.fallback) {
|
|
img.dataset.fallback = "1";
|
|
img.src = getFurniIconUrl(item.classname, item.revision);
|
|
} else if (img.dataset.fallback === "1") {
|
|
img.dataset.fallback = "2";
|
|
img.src = `/swf/dcr/hof_furni/icons/${encodeURIComponent(iconName)}_icon.png`;
|
|
} else {
|
|
img.src =
|
|
'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="%2399a0aa" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2.5"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>';
|
|
}
|
|
}
|
|
|
|
export const TYPE_LABELS: Record<string, string> = {
|
|
flooritem: "Floor",
|
|
wallitem: "Wall",
|
|
};
|