@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
50 lines (47 loc) • 2.12 kB
JavaScript
import React, { forwardRef } from 'react';
import cx from 'classnames';
import { getButtonContent, getButtonCommonClassNames } from '../helpers.js';
import Button from '../ButtonComponent.js';
const getComputedClassName = ({ className, standalone, destructive, }) => cx(className, "cob-Button__ghost", {
"cob-Button__ghost--standalone": standalone,
"cob-Button__ghost--destructive": destructive,
});
const _GhostButton = forwardRef((props, ref) => {
const { children, standalone, destructive, icon, iconPosition, className, loading, disabled, rounded, size, fullWidth, ...restButtonProps } = props;
const content = getButtonContent({ children, icon, iconPosition });
const isDisabled = disabled || loading;
const buttonClassNames = getButtonCommonClassNames({
disabled: isDisabled,
rounded,
size,
fullWidth,
className,
});
return (React.createElement(Button, { ...restButtonProps, className: getComputedClassName({
className: buttonClassNames,
standalone,
destructive,
}), ref: ref, loading: loading, disabled: isDisabled }, content));
});
_GhostButton.displayName = "GhostButton";
const GhostLink = forwardRef((props, ref) => {
const { children, standalone, destructive, icon, iconPosition, className, loading, disabled, rounded, size, fullWidth, ...restLinkProps } = props;
const content = getButtonContent({ children, icon, iconPosition });
const isDisabled = disabled || loading;
const buttonClassNames = getButtonCommonClassNames({
disabled: isDisabled,
rounded,
size,
fullWidth,
className,
});
return (React.createElement(Button.Link, { ...restLinkProps, className: getComputedClassName({
className: buttonClassNames,
standalone,
destructive,
}), ref: ref, loading: loading, disabled: isDisabled }, content));
});
GhostLink.displayName = "GhostLink";
const GhostButton = Object.assign(_GhostButton, { Link: GhostLink });
export { GhostButton as default };
//# sourceMappingURL=index.js.map