shelving
Version:
Toolkit for using data in JavaScript.
12 lines (11 loc) • 752 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { notNullish } from "../../util/null.js";
import { getFlexClass } from "../style/Flex.js";
import { getClass } from "../util/css.js";
import { Clickable } from "./Clickable.js";
import { BUTTON_INPUT_CLASS, PLACEHOLDER_CLASS } from "./Input.js";
/** Return either a `<button>` or an `<a href="">` styled as an input, based on whether an `onClick` or `href` prop is provided. */
export function ButtonInput({ title, placeholder, children = title, ...props }) {
const hasChildren = notNullish(children);
return (_jsx(Clickable, { ...props, className: getClass(BUTTON_INPUT_CLASS, getFlexClass(props), hasChildren && PLACEHOLDER_CLASS), children: hasChildren ? children : placeholder }));
}