Skip to content

Commit

Permalink
Make button components derive onDark prop from theme context
Browse files Browse the repository at this point in the history
  • Loading branch information
reidmit authored and apps-manager committed Mar 4, 2019
1 parent 6bffe69 commit 46f1201
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/react/buttons/buttons.js
@@ -1,6 +1,7 @@
import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {ThemeConsumer} from '../context';

export class UIButton extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -92,15 +93,15 @@ export class UIButton extends React.Component {
}
}

const defButton = propOverrides => {
return class extends React.Component {
render() {
return <UIButton {...this.props} {...propOverrides}/>;
}
};
const defButton = kind => props => {
return (
<ThemeConsumer>
{theme => <UIButton {...props} kind={kind} onDark={theme === 'dark'}/>}
</ThemeConsumer>
);
};

export const DefaultButton = defButton();
export const PrimaryButton = defButton({kind: 'primary'});
export const DangerButton = defButton({kind: 'danger'});
export const BrandButton = defButton({kind: 'brand'});
export const DefaultButton = defButton('default');
export const PrimaryButton = defButton('primary');
export const DangerButton = defButton('danger');
export const BrandButton = defButton('brand');

0 comments on commit 46f1201

Please sign in to comment.