p5.js-web-editor/client/components/Button/index.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-01-19 18:04:44 +01:00
import React from "react";
import PropTypes from "prop-types";
import styled from 'styled-components';
2020-01-19 22:05:16 +01:00
import { remSize, prop } from '../../theme';
2020-01-19 18:04:44 +01:00
const StyledButton = styled.button`
2020-01-19 22:05:16 +01:00
background-color: ${prop('buttonColorBackground')};
color: ${prop('buttonColor')};
cursor: pointer;
border: 2px solid ${prop('buttonBorderColor')};
border-radius: 2px;
padding: ${remSize(8)} ${remSize(25)};
line-height: 1;
2020-01-19 18:04:44 +01:00
margin: 0;
2020-01-19 22:05:16 +01:00
&:hover:not(:disabled) {
color: ${prop('buttonHoverColor')};
background-color: ${prop('buttonHoverColorBackground')};
}
&:disabled {
color: ${prop('buttonDisabledColor')};
background-color: ${prop('buttonDisabledColorBackground')};
cursor: not-allowed;
}
2020-01-19 18:04:44 +01:00
`;
/**
* This text will be used for the description in the story
*/
const Button = ({ children, label, ...props }) => {
return <StyledButton aria-label={label} {...props}>{children}</StyledButton>;
}
Button.propTypes = {
/**
* The visible part of the button
*/
children: PropTypes.element.isRequired,
/**
If the button can be clicked or not
*/
2020-01-19 22:05:16 +01:00
disabled: PropTypes.bool,
2020-01-19 18:04:44 +01:00
/*
* An ARIA Label used for accessibility
*/
label: PropTypes.string.isRequired,
};
export default Button;