-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(button): differentiate primary and secondary
- Loading branch information
Showing
17 changed files
with
108 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { string } from 'prop-types'; | ||
import { string, func } from 'prop-types'; | ||
import { omit } from 'lodash'; | ||
|
||
import styles from './Button.scss'; | ||
|
||
export default class Button extends React.PureComponent { | ||
class Button extends React.PureComponent { | ||
render() { | ||
return ( // eslint-disable-next-line react/button-has-type | ||
<button | ||
{...this.props} | ||
ref={this.registerRef} | ||
{...omit(this.props, 'forwardedRef')} | ||
ref={this.props.forwardedRef} | ||
className={classNames(styles.button, this.props.className)} | ||
/> | ||
); | ||
} | ||
|
||
registerRef = (el) => { | ||
this.button = el; | ||
} | ||
|
||
focus = () => { | ||
this.button.focus(); | ||
} | ||
|
||
blur = () => { | ||
this.button.blur(); | ||
} | ||
} | ||
|
||
Button.propTypes = { | ||
className: string, | ||
type: string | ||
type: string, | ||
forwardedRef: func | ||
}; | ||
|
||
Button.defaultProps = { | ||
className: null, | ||
type: 'button' | ||
type: 'button', | ||
forwardedRef: null | ||
}; | ||
|
||
export default React.forwardRef((props, ref) => { | ||
return <Button {...props} forwardedRef={ref} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/renderer/shared/components/Forms/PrimaryButton/PrimaryButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { string, func } from 'prop-types'; | ||
import { omit } from 'lodash'; | ||
|
||
import Button from '../Button'; | ||
import styles from './PrimaryButton.scss'; | ||
|
||
class PrimaryButton extends React.PureComponent { | ||
render() { | ||
return ( | ||
<Button | ||
{...omit(this.props, 'forwardedRef')} | ||
ref={this.props.forwardedRef} | ||
className={classNames(styles.primaryButton, this.props.className)} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
PrimaryButton.propTypes = { | ||
className: string, | ||
forwardedRef: func | ||
}; | ||
|
||
PrimaryButton.defaultProps = { | ||
className: null, | ||
forwardedRef: null | ||
}; | ||
|
||
export default React.forwardRef((props, ref) => { | ||
return <PrimaryButton {...props} forwardedRef={ref} />; | ||
}); |
Oops, something went wrong.