ToolJet/frontend/src/Editor/Components/Button.jsx
Ajith KV 2db14dd9f5
Cypress test for button widget (#2989)
* Added cypress test for button widget

* Added custom commands

* Updated common selectors

* data-cy attributes for the elements

* Updated the login end point

* Updated new login end point

* Added data-cy attribute for autosave indicator

* Updated login end point

* Updated test for auto save indicator

* Updated custom commands for skipping instruction modal
2022-05-16 15:39:10 +05:30

38 lines
1.1 KiB
JavaScript

import React from 'react';
import cx from 'classnames';
var tinycolor = require('tinycolor2');
export const Button = function Button({ height, properties, styles, fireEvent }) {
const { loadingState, text } = properties;
const { backgroundColor, textColor, borderRadius, visibility, disabledState, loaderColor } = styles;
const computedStyles = {
backgroundColor,
color: textColor,
width: '100%',
borderRadius: `${borderRadius}px`,
height,
display: visibility ? '' : 'none',
'--tblr-btn-color-darker': tinycolor(backgroundColor).darken(8).toString(),
'--loader-color': tinycolor(loaderColor ?? '#fff').toString(),
};
return (
<div className="widget-button">
<button
disabled={disabledState}
className={cx('jet-button btn btn-primary p-1 overflow-hidden', {
'btn-loading': loadingState,
})}
style={computedStyles}
onClick={(event) => {
event.stopPropagation();
fireEvent('onClick');
}}
data-cy="button-widget"
>
{text}
</button>
</div>
);
};