@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
77 lines (76 loc) • 2.58 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import classnames from "classnames";
import { forwardRef } from "react";
import ButtonComponent from "../ButtonComponent.js";
import { getButtonCommonClassNames, getButtonContent } from "../helpers.js";
const getComputedClassName = ({ className, selected, primary, destructive })=>classnames(className, "cob-Button__default", {
"cob-Button__default--selected": selected,
"cob-Button__default--primary": primary,
"cob-Button__default--destructive": destructive
});
const _DefaultButton = /*#__PURE__*/ forwardRef((props, ref)=>{
const { children, selected, primary, 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 /*#__PURE__*/ jsx(ButtonComponent, {
...restButtonProps,
className: getComputedClassName({
className: buttonClassNames,
selected,
primary,
destructive
}),
ref: ref,
loading: loading,
disabled: isDisabled,
children: content
});
});
_DefaultButton.displayName = "DefaultButton";
const DefaultLink = /*#__PURE__*/ forwardRef((props, ref)=>{
const { children, selected, primary, 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 /*#__PURE__*/ jsx(ButtonComponent.Link, {
...restLinkProps,
className: getComputedClassName({
className: buttonClassNames,
selected,
primary,
destructive
}),
ref: ref,
loading: loading,
disabled: isDisabled,
children: content
});
});
DefaultLink.displayName = "DefaultLink";
const DefaultButton = Object.assign(_DefaultButton, {
Link: DefaultLink
});
const Buttons_DefaultButton = DefaultButton;
export default Buttons_DefaultButton;
//# sourceMappingURL=index.js.map