Button.jsx 633 B

12345678910111213141516171819202122232425
  1. import React from "react";
  2. const ALLOWED_STYLE_TAGS = ["color", "backgroundColor"];
  3. export const Button = props => {
  4. const style = {};
  5. // Add allowed style tags from props, e.g. props.color becomes style={color: props.color}
  6. for (const tag of ALLOWED_STYLE_TAGS) {
  7. if (typeof props[tag] !== "undefined") {
  8. style[tag] = props[tag];
  9. }
  10. }
  11. // remove border if bg is set to something custom
  12. if (style.backgroundColor) {
  13. style.border = "0";
  14. }
  15. return (<button onClick={props.onClick}
  16. className={props.className || "ASRouterButton secondary"}
  17. style={style}>
  18. {props.children}
  19. </button>);
  20. };