UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

20 lines (17 loc) 1.29 kB
import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; import { forwardRef } from 'react'; import '../../Icon/index.js'; import LoadingIcon from '../../Icon/__generated__/LoadingIcon.js'; const InnerButton = ({ children, loading, }) => (jsxs(Fragment, { children: [loading && jsx(LoadingIcon, { className: "cobalt-button__loading-icon" }), children] })); const ButtonBase = forwardRef((props, ref) => { const { disabled, loading, children, ...restProps } = props; return (jsx("button", { ref: ref, "aria-disabled": disabled || loading, "aria-busy": loading, disabled: disabled || loading, ...restProps, children: jsx(InnerButton, { loading: loading, children: children }) })); }); ButtonBase.displayName = "ButtonBase"; const ButtonLinkBase = forwardRef((props, ref) => { const { disabled, target, rel, loading, children, ...restProps } = props; return (jsx("a", { ref: ref, "aria-disabled": disabled || loading, "aria-busy": loading, "data-disabled": disabled || loading, target: target, rel: target === "_blank" && !rel ? "noopener noreferrer" : rel, ...restProps, children: jsx(InnerButton, { loading: loading, children: children }) })); }); ButtonLinkBase.displayName = "ButtonLinkBase"; export { ButtonBase, ButtonLinkBase }; //# sourceMappingURL=ButtonComponent.js.map