@crossed/demo
Version:
A universal & performant styling library for React Native, Next.js & React
79 lines (78 loc) • 3.08 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 colorMode_exports = {};
__export(colorMode_exports, {
ColorModeDemo: () => ColorModeDemo
});
module.exports = __toCommonJS(colorMode_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_styled = require("@crossed/styled");
var import_styled2 = require("@crossed/styled");
var import_react_native = require("react-native");
const ButtonWithoutVariant = (0, import_styled2.styled)(import_react_native.Pressable, {
className: [
"px-2 py-1",
"bg-neutral-300 text-black",
"dark:bg-neutral-800 dark:text-white"
]
});
const ButtonWithVariant = (0, import_styled2.styled)(import_react_native.Pressable, {
className: ["px-2 py-1"],
variants: {
variant: {
filled: {
className: [
"bg-neutral-300 text-black",
"dark:bg-neutral-800 dark:text-white"
]
}
}
},
defaultVariants: {
variant: "filled"
}
});
const ButtonTheme = () => {
const { theme, setTheme } = (0, import_styled.useCrossedTheme)();
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
"button",
{
className: "bg-neutral-500 dark:bg-neutral-800 px-2 py-1 text-black dark:text-white",
onClick: () => setTheme(theme === "dark" ? "light" : "dark"),
children: [
"Change theme: ",
theme
]
}
);
};
const ColorModeDemo = () => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.CrossedTheme, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-center gap-2", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-row gap-2", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonWithoutVariant, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { children: "Button without variant" }) }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonWithVariant, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { children: "Button with variant" }) })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonTheme, {})
] }) });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ColorModeDemo
});
//# sourceMappingURL=colorMode.js.map