mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
* 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
38 lines
1.1 KiB
JavaScript
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>
|
|
);
|
|
};
|