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