geoiq-frontend-ui-kit
Version:
This project is a UI kit for GeoIQ's frontend. It's built with React, TypeScript, and Vite.
58 lines (57 loc) • 1.96 kB
JavaScript
import { ImageOff as p } from "lucide-react";
import t, { useState as g } from "react";
import { cn as o } from "./index88.es.js";
function E({
items: a,
value: r,
onSelect: i,
columns: u = 3,
emptyMessage: n,
className: d
}) {
const [m, f] = g(/* @__PURE__ */ new Set());
return a.length ? /* @__PURE__ */ t.createElement(
"div",
{
className: o("grid gap-2", d),
style: { gridTemplateColumns: `repeat(${u}, 1fr)` }
},
a.map((e, h) => {
const s = r !== void 0 && r === e.value, l = `${e.value}-${h}`, c = e.thumbnail && m.has(l);
return /* @__PURE__ */ t.createElement(
"button",
{
key: l,
type: "button",
title: e.label,
"aria-pressed": s,
onClick: () => i(e.value),
className: o(
"flex items-center justify-center rounded-lg border p-2 text-xs transition-colors",
s ? "border-rest-p1 bg-rest-p1 text-white" : "border-neutral-1 bg-white text-light-2 hover:border-rest-p1"
)
},
e.thumbnail && !c ? /* @__PURE__ */ t.createElement(
"img",
{
src: e.thumbnail,
alt: e.label ?? "",
className: "h-10 w-full object-contain",
onError: () => f((b) => new Set(b).add(l))
}
) : c ? /* @__PURE__ */ t.createElement(
"span",
{
title: "Failed to load",
className: "flex h-10 w-full items-center justify-center text-light-4"
},
/* @__PURE__ */ t.createElement(p, { className: "h-5 w-5" })
) : e.icon ? /* @__PURE__ */ t.createElement("span", { className: "flex h-5 w-5 items-center justify-center [&_svg]:h-5 [&_svg]:w-5" }, e.icon) : e.label
);
})
) : n ? /* @__PURE__ */ t.createElement("p", { className: "text-xs italic text-light-4" }, n) : null;
}
export {
E as SwatchGrid
};
//# sourceMappingURL=index38.es.js.map