UNPKG

@crossed/demo

Version:

A universal & performant styling library for React Native, Next.js & React

62 lines (61 loc) 2.12 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { merge } from "@crossed/styled"; import { createList } from "@crossed/primitive"; import { YBox } from "@crossed/ui"; import { Fragment, useId } from "react"; const List = createList({ Root: ({ children, ...props }) => { const id = useId(); return /* @__PURE__ */ jsx( "ul", { ...props, className: merge( "flex flex-col border border-neutral-800 rounded-md", props.className ), children: Array.isArray(children) ? children.map((c, i) => { return /* @__PURE__ */ jsxs(Fragment, { children: [ c, i + 1 !== children.length && /* @__PURE__ */ jsx("div", { className: "border-t border-neutral-800" }) ] }, `${id}-${i}`); }) : children } ); }, Item: (props) => { return /* @__PURE__ */ jsx("li", { ...props, className: merge("px-3 py-2", props.className) }); }, SubTitle: (props) => { return /* @__PURE__ */ jsx( "div", { ...props, className: merge("text-sm text-neutral-500", props.className) } ); }, Title: (props) => { return /* @__PURE__ */ jsx("div", { ...props, className: merge("font-bold", props.className) }); } }); const CreateListWithSeparatorDemo = () => { return /* @__PURE__ */ jsx(YBox, { space: "md", children: /* @__PURE__ */ jsxs(List, { children: [ /* @__PURE__ */ jsxs(List.Item, { children: [ /* @__PURE__ */ jsx(List.Title, { children: "Number 1" }), /* @__PURE__ */ jsx(List.SubTitle, { children: "Description Number 1" }) ] }), /* @__PURE__ */ jsxs(List.Item, { children: [ /* @__PURE__ */ jsx(List.Title, { children: "Number 2" }), /* @__PURE__ */ jsx(List.SubTitle, { children: "Description 2" }) ] }), /* @__PURE__ */ jsxs(List.Item, { children: [ /* @__PURE__ */ jsx(List.Title, { children: "Number 3" }), /* @__PURE__ */ jsx(List.SubTitle, { children: "Number 3 have description" }) ] }) ] }) }); }; export { CreateListWithSeparatorDemo }; //# sourceMappingURL=separator.js.map