Skip to content

Instantly share code, notes, and snippets.

@carl0zen
Created November 18, 2016 20:40
Show Gist options
  • Save carl0zen/b8342e24955c1ceb5be36cd3c72ac135 to your computer and use it in GitHub Desktop.
Save carl0zen/b8342e24955c1ceb5be36cd3c72ac135 to your computer and use it in GitHub Desktop.
Core UI Button Example using CSS Modules
import React from "react";
import classNames from "classnames";
import styles from "./styles";
const Button = (props) => {
const { className, children, theme, tag, ...rest } = props;
const CustomTag = `${tag}`;
return (
<CustomTag { ...rest } className={ classNames(styles.root, theme, className) }>
{ children }
</CustomTag>
);
};
Button.theme = {
secondary: styles.secondary,
primary: styles.primary
};
Button.defaultProps = {
theme: Button.theme.primary,
tag: "button"
};
Button.displayName = Button.name;
Button.propTypes = {
theme: React.PropTypes.string,
tag: React.PropTypes.string,
className: React.PropTypes.string,
children: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
React.PropTypes.arrayOf(React.PropTypes.element)
])
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment