This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/website/stories/Button.js

51 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2021-04-02 18:45:38 +00:00
import React from "react";
import PropTypes from "prop-types";
import "./button.css";
2021-03-23 12:07:19 +00:00
/**
* Primary UI component for user interaction
*/
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
2021-04-02 18:45:38 +00:00
const mode = primary ? "storybook-button--primary" : "storybook-button--secondary";
2021-03-23 12:07:19 +00:00
return (
<button
type="button"
2021-04-02 18:45:38 +00:00
className={["storybook-button", `storybook-button--${size}`, mode].join(" ")}
2021-03-23 12:07:19 +00:00
style={backgroundColor && { backgroundColor }}
{...props}
>
{label}
</button>
);
};
Button.propTypes = {
/**
* Is this the principal call to action on the page?
*/
primary: PropTypes.bool,
/**
* What background color to use
*/
backgroundColor: PropTypes.string,
/**
* How large should the button be?
*/
2021-04-02 18:45:38 +00:00
size: PropTypes.oneOf(["small", "medium", "large"]),
2021-03-23 12:07:19 +00:00
/**
* Button contents
*/
label: PropTypes.string.isRequired,
/**
* Optional click handler
*/
onClick: PropTypes.func,
};
Button.defaultProps = {
backgroundColor: null,
primary: false,
2021-04-02 18:45:38 +00:00
size: "medium",
2021-03-23 12:07:19 +00:00
onClick: undefined,
};