1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

allow extending button style classes

This commit is contained in:
Matthias Kretschmann 2019-02-15 14:22:51 +01:00
parent 73be4ea648
commit aedfcd9ca0
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -1,8 +1,10 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import cx from 'classnames'
import styles from './Button.module.scss' import styles from './Button.module.scss'
interface ButtonProps { interface ButtonProps {
children: string children: string
className?: string
primary?: boolean primary?: boolean
link?: boolean link?: boolean
href?: string href?: string
@ -12,7 +14,14 @@ interface ButtonProps {
export default class Button extends PureComponent<ButtonProps, any> { export default class Button extends PureComponent<ButtonProps, any> {
public render() { public render() {
let classes let classes
const { primary, link, href, children, ...props } = this.props const {
primary,
link,
href,
children,
className,
...props
} = this.props
if (primary) { if (primary) {
classes = styles.buttonPrimary classes = styles.buttonPrimary
@ -23,11 +32,11 @@ export default class Button extends PureComponent<ButtonProps, any> {
} }
return href ? ( return href ? (
<a href={href} className={classes} {...props}> <a href={href} className={cx(classes, className)} {...props}>
{children} {children}
</a> </a>
) : ( ) : (
<button className={classes} {...props}> <button className={cx(classes, className)} {...props}>
{children} {children}
</button> </button>
) )