This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up the render method logic into functions
* Adds two components to represent a link and button. * Removes nested if/else statements in favor of smalled named functions
- Loading branch information
1 parent
c43ae0d
commit 5cd9f0d
Showing
3 changed files
with
120 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
|
||
const propTypes = { | ||
children: React.PropTypes.any, | ||
className: React.PropTypes.string, | ||
clickHandler: React.PropTypes.func, | ||
disabled: React.PropTypes.bool, | ||
label: React.PropTypes.string, | ||
type: React.PropTypes.string | ||
}; | ||
|
||
const button = ({ className, label, clickHandler, disabled, type, children }) => | ||
<button | ||
className={ className } | ||
aria-label={ label } | ||
onClick={ clickHandler } | ||
disabled={ disabled } | ||
type={type} | ||
> | ||
{ children } | ||
</button>; | ||
|
||
button.propTypes = propTypes; | ||
|
||
export default button; |
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,28 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
|
||
const propTypes = { | ||
children: React.PropTypes.any, | ||
className: React.PropTypes.string, | ||
clickHandler: React.PropTypes.func, | ||
href: React.PropTypes.string, | ||
label: React.PropTypes.string | ||
}; | ||
const defaultPropTypes = { | ||
href: '#' | ||
}; | ||
|
||
const Link = ({ className, label, href, clickHandler, children }) => | ||
<a | ||
className={ classnames(className, 'action-link') } | ||
title={ label } | ||
onClick={ clickHandler } | ||
href={ href } | ||
> | ||
{ children } | ||
</a>; | ||
|
||
Link.propTypes = propTypes; | ||
Link.defaultPropTypes = defaultPropTypes; | ||
|
||
export default Link; |