UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

56 lines (53 loc) 2.46 kB
import React, { forwardRef } from 'react'; import cx from 'classnames'; import { getButtonContent, getButtonCommonClassNames } from '../helpers.js'; import Button from '../ButtonComponent.js'; const getComputedClassName = ({ className, variant, destructive, }) => cx(className, "cob-Button__small", { "cob-Button__small--primary": variant === "primary", "cob-Button__small--destructive": destructive, "cob-Button__small--warning": variant === "warning", "cob-Button__small--secondary": variant === "secondary", "cob-Button__small--tertiary": variant === "tertiary", "cob-Button__small--business": variant === "business", "cob-Button__small--success": variant === "success", "cob-Button__small--neutral": variant === "neutral", }); const _SmallButton = forwardRef((props, ref) => { const { children, variant, 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, variant, destructive, }), ref: ref, loading: loading, disabled: isDisabled }, content)); }); _SmallButton.displayName = "SmallButton"; const SmallLink = forwardRef((props, ref) => { const { children, variant, 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, variant, destructive, }), ref: ref, loading: loading, disabled: isDisabled }, content)); }); SmallLink.displayName = "SmallLink"; const SmallButton = Object.assign(_SmallButton, { Link: SmallLink }); export { SmallButton as default }; //# sourceMappingURL=index.js.map