UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

51 lines (48 loc) 2.14 kB
import { jsx } from 'react/jsx-runtime'; import cx from 'classnames'; import { forwardRef } from 'react'; import Button from '../ButtonComponent.js'; import { getButtonContent, getButtonCommonClassNames } from '../helpers.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 (jsx(Button, { ...restButtonProps, className: getComputedClassName({ className: buttonClassNames, standalone, destructive, }), ref: ref, loading: loading, disabled: isDisabled, children: 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 (jsx(Button.Link, { ...restLinkProps, className: getComputedClassName({ className: buttonClassNames, standalone, destructive, }), ref: ref, loading: loading, disabled: isDisabled, children: content })); }); GhostLink.displayName = "GhostLink"; const GhostButton = Object.assign(_GhostButton, { Link: GhostLink }); export { GhostButton as default }; //# sourceMappingURL=index.js.map