@playbooks/ui
Version:
An interface library for Playbooks.
103 lines (102 loc) • 3.46 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { useUI } from "./context.es.js";
import { Span } from "./html.es.js";
const Badge = ({
name = "Badge",
type = "",
size = "sm",
tailwind,
className,
children,
...props
}) => {
const context = useUI();
const base = context?.theme?.badge({ size });
const computed = { ...base, ...props, tailwind, className, name };
switch (type) {
case "draft":
case "free":
return /* @__PURE__ */ jsx(DraftBadge, { ...computed, children });
case "info":
case "warning":
case "scheduled":
return /* @__PURE__ */ jsx(WarningBadge, { ...computed, children });
case "pending":
case "running":
case "seed":
case "testing":
return /* @__PURE__ */ jsx(PendingBadge, { ...computed, children });
case "active":
case "complete":
case "succeeded":
case "verified":
return /* @__PURE__ */ jsx(SuccessBadge, { ...computed, children });
case "closed":
case "finished":
case "inactive":
case "paid":
case "won":
return /* @__PURE__ */ jsx(FinishedBadge, { ...computed, children });
case "canceled":
case "denied":
case "disabled":
case "errored":
case "refunded":
case "stopped":
return /* @__PURE__ */ jsx(ErrorBadge, { ...computed, children });
default:
return /* @__PURE__ */ jsx(DefaultBadge, { ...computed, children });
}
};
const DraftBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.draftBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const PendingBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.pendingBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const WarningBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.warningBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const SuccessBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.successBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const FinishedBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.finishedBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const ErrorBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.errorBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
const DefaultBadge = ({ tailwind, className, children, ...props }) => {
const context = useUI();
const base = context?.theme?.outlineBadge();
const computed = { ...base, ...props, tailwind, className };
return /* @__PURE__ */ jsx(Span, { ...computed, children });
};
export {
Badge,
DefaultBadge,
DraftBadge,
ErrorBadge,
FinishedBadge,
PendingBadge,
SuccessBadge,
WarningBadge
};