@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
48 lines (47 loc) • 1.51 kB
JavaScript
import { jsx, jsxs } from "react/jsx-runtime";
import { forwardRef } from "react";
import { LoadingIcon } from "../Icon/index.js";
const isLinkProps = (props)=>"href" in props && !!props.href;
const _Button = /*#__PURE__*/ forwardRef((props, ref)=>{
const { disabled, loading, children, ...restProps } = props;
return /*#__PURE__*/ jsxs("button", {
ref: ref,
"aria-disabled": disabled,
"aria-busy": loading,
disabled: disabled,
...restProps,
children: [
loading && /*#__PURE__*/ jsx(LoadingIcon, {
className: "cob-Button__loading-icon"
}),
children
]
});
});
_Button.displayName = "button";
const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
const { disabled, target, rel, loading, children, ...restProps } = props;
return /*#__PURE__*/ jsxs("a", {
"aria-disabled": disabled,
"data-disabled": disabled,
"aria-busy": loading,
target: target,
rel: target && !rel ? "noopener noreferrer" : rel,
ref: ref,
...restProps,
children: [
loading && /*#__PURE__*/ jsx(LoadingIcon, {
className: "cob-Button__loading-icon"
}),
children
]
});
});
Link.displayName = "link";
const Button = Object.assign(_Button, {
Link: Link
});
const ButtonComponent = Button;
export default ButtonComponent;
export { isLinkProps };
//# sourceMappingURL=ButtonComponent.js.map