ToolJet/frontend/src/Editor/Components/Button.jsx

39 lines
1.1 KiB
React
Raw Normal View History

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;
2022-04-05 11:27:22 +00:00
const { backgroundColor, textColor, borderRadius, visibility, disabledState, loaderColor } = styles;
2021-04-02 09:24:51 +00:00
2021-04-30 06:31:32 +00:00
const computedStyles = {
backgroundColor,
color: textColor,
width: '100%',
borderRadius: `${borderRadius}px`,
height,
display: visibility ? '' : 'none',
'--tblr-btn-color-darker': tinycolor(backgroundColor).darken(8).toString(),
2022-04-05 11:27:22 +00:00
'--loader-color': tinycolor(loaderColor ?? '#fff').toString(),
2021-04-30 06:31:32 +00:00
};
2021-04-02 09:24:51 +00:00
2021-04-30 06:31:32 +00:00
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>
2021-04-30 06:31:32 +00:00
);
};