UNPKG

@zohodesk/components

Version:

In this Package, we Provide Some Basic Components to Build Web App

69 lines (67 loc) 2.04 kB
import React from 'react'; import { defaultProps } from "./props/defaultProps"; import { propTypes } from "./props/propTypes"; import cssJSLogic from "./css/cssJSLogic"; import { mergeStyle } from '@zohodesk/utils'; import style from "./css/Button.module.css"; /* Button text and children props? use children for both cases toLowerCase check needed? */ /* eslint css-modules/no-unused-class: [2, { markAsUsed: ['small','medium','large','xlarge','button_medium','button_small','primary','primaryfilled','danger','dangerfilled','plainprimary', 'plainsecondary', 'secondary', 'secondaryfilled', 'successFilled','tertiaryFilled'] }] */ export default function Button(props) { let { text, disabled, onClick, status, children, dataId, needAppearance, getRef, title, dataSelectorId, customProps, customStyle, a11y, id } = props; const finalStyle = mergeStyle(style, customStyle); const { buttonClass, loaderParentClass, loaderChildClass } = cssJSLogic({ props, style: finalStyle }); let statusLower = status.toLowerCase(); return /*#__PURE__*/React.createElement("button", { className: buttonClass, "data-id": disabled ? `${dataId}_disabled` : dataId, "data-test-id": disabled ? `${dataId}_disabled` : dataId, disabled: disabled || statusLower === 'loading', onClick: onClick, "data-title": title, type: "button", ref: getRef, "data-selector-id": dataSelectorId, ...customProps, ...a11y, id: id }, children ? children : text, statusLower !== 'none' && needAppearance && /*#__PURE__*/React.createElement("div", { className: finalStyle.overlay }, /*#__PURE__*/React.createElement("div", { className: loaderParentClass }, /*#__PURE__*/React.createElement("div", { className: loaderChildClass })))); } Button.defaultProps = defaultProps; Button.propTypes = propTypes; // if (__DOCS__) { // Button.docs = { // componentGroup: 'Form Elements', // folderName: 'Style Guide' // }; // }