feature/tauri-js-rs
jsx 54 lines 1.13 KB
Raw
1 import React from 'react';
2 import PropTypes from 'prop-types';
3 import './button.css';
4
5 /**
6 * Primary UI component for user interaction
7 */
8 export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
9 const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
10 return (
11 <button
12 type="button"
13 className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
14 {...props}
15 >
16 {label}
17 <style jsx>{`
18 button {
19 background-color: ${backgroundColor};
20 }
21 `}</style>
22 </button>
23 );
24 };
25
26 Button.propTypes = {
27 /**
28 * Is this the principal call to action on the page?
29 */
30 primary: PropTypes.bool,
31 /**
32 * What background color to use
33 */
34 backgroundColor: PropTypes.string,
35 /**
36 * How large should the button be?
37 */
38 size: PropTypes.oneOf(['small', 'medium', 'large']),
39 /**
40 * Button contents
41 */
42 label: PropTypes.string.isRequired,
43 /**
44 * Optional click handler
45 */
46 onClick: PropTypes.func,
47 };
48
49 Button.defaultProps = {
50 backgroundColor: null,
51 primary: false,
52 size: 'medium',
53 onClick: undefined,
54 };