@crossed/demo
Version:
A universal & performant styling library for React Native, Next.js & React
123 lines (122 loc) • 5.11 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var group_exports = {};
__export(group_exports, {
CreateButtonGroupDemo: () => CreateButtonGroupDemo
});
module.exports = __toCommonJS(group_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_primitive = require("@crossed/primitive");
var import_styled = require("@crossed/styled");
var import_ui = require("@crossed/ui");
var import_react_native = require("react-native");
var import_react = require("react");
const Group = (0, import_styled.styled)(import_react_native.View, {
className: ["flex"],
variants: {
orientation: {
horizontal: { className: ["flex-row"] },
vertical: { className: ["flex-col"] }
}
},
defaultVariants: {
orientation: "horizontal"
}
});
const Root = (0, import_styled.styled)(import_react_native.Pressable, {
"className": [
"flex flex-row items-center gap-2",
"bg-blue-500",
"rounded",
"px-3 py-2"
],
":hover": {
className: ["bg-blue-400"]
},
":focus": { className: ["z-10"] },
"variants": {
grouped: { true: { className: ["rounded-none"] } },
first: { true: { className: ["rounded-l"] } },
last: { true: { className: ["rounded-r"] } },
orientation: { horizontal: { className: [] }, vertical: { className: [] } }
},
"compoundVariants": [
{
orientation: "vertical",
first: true,
className: ["rounded-none rounded-t"]
},
{
orientation: "vertical",
last: true,
className: ["rounded-none rounded-b"]
}
]
});
const TextButton = (0, import_styled.styled)(import_react_native.Text, {
className: ["text-white", "text-base"]
});
const Element = (0, import_styled.styled)(import_react_native.View, {
className: ["flex"]
});
const Button = (0, import_primitive.createButton)({
Group,
Root: (0, import_react.forwardRef)((props, ref) => {
const { grouped, orientation } = (0, import_primitive.useButtonGroupContext)();
const getItems = (0, import_primitive.useButtonGroupCollection)();
const index = getItems().findIndex(({ id }) => id === props.id);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
Root,
{
grouped,
first: index === 0,
last: index === getItems().length - 1,
orientation,
...props,
ref
}
);
}),
Text: TextButton,
Element
});
const CreateButtonGroupDemo = () => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.YBox, { className: "gap-4 items-center", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button.Group, { orientation: "horizontal", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button.Group, { orientation: "vertical", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Element, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.UilBitcoinCircle, {}) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Text, { children: "text button" })
] })
] });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CreateButtonGroupDemo
});
//# sourceMappingURL=group.js.map