Add List component for rendering item lists

This commit is contained in:
Natxo
2026-03-31 12:16:40 +02:00
committed by GitHub
parent ccbe8e5c4a
commit fd0324135b

18
src/components/List.js Normal file
View File

@@ -0,0 +1,18 @@
import { $html, $if, $for } from "sigpro";
import { joinClass, val } from "../core/utils.js";
/** LIST */
export const List = (props) => {
const { items, header, render, keyFn, class: className } = props;
return $html(
"ul",
{
class: joinClass("list bg-base-100 rounded-box shadow-md", className),
},
[
$if(header, () => $html("li", { class: "p-4 pb-2 text-xs opacity-60 tracking-wide" }, [val(header)])),
$for(items, (item, index) => $html("li", { class: "list-row" }, [render(item, index)]), keyFn),
],
);
};