@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
46 lines (45 loc) • 1.6 kB
JavaScript
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { forwardRef } from "react";
import { LoadingIcon } from "../../Icon/index.js";
const InnerButton = ({ children, loading })=>/*#__PURE__*/ jsxs(Fragment, {
children: [
loading && /*#__PURE__*/ jsx(LoadingIcon, {
className: "cobalt-button__loading-icon"
}),
children
]
});
const ButtonBase = /*#__PURE__*/ forwardRef((props, ref)=>{
const { disabled, loading, children, ...restProps } = props;
return /*#__PURE__*/ jsx("button", {
ref: ref,
"aria-disabled": disabled || loading,
"aria-busy": loading,
disabled: disabled || loading,
...restProps,
children: /*#__PURE__*/ jsx(InnerButton, {
loading: loading,
children: children
})
});
});
ButtonBase.displayName = "ButtonBase";
const ButtonLinkBase = /*#__PURE__*/ forwardRef((props, ref)=>{
const { disabled, target, rel, loading, children, ...restProps } = props;
return /*#__PURE__*/ jsx("a", {
ref: ref,
"aria-disabled": disabled || loading,
"aria-busy": loading,
"data-disabled": disabled || loading,
target: target,
rel: "_blank" !== target || rel ? rel : "noopener noreferrer",
...restProps,
children: /*#__PURE__*/ jsx(InnerButton, {
loading: loading,
children: children
})
});
});
ButtonLinkBase.displayName = "ButtonLinkBase";
export { ButtonBase, ButtonLinkBase };
//# sourceMappingURL=ButtonComponent.js.map