-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#34 Add ArrowButton common component.
- Loading branch information
Jose Nunes
committed
Aug 3, 2018
1 parent
90e0759
commit eb22850
Showing
8 changed files
with
103 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import Icon from '../Icon'; | ||
|
||
import colors from '../../../assets/colors'; | ||
import styles from './ArrowButton.module.css'; | ||
|
||
const Text = ({ text, direction }) => ( | ||
<span | ||
className={` | ||
${styles.text} | ||
${direction === 'r' ? styles.r : styles.l} | ||
`} | ||
> | ||
{text} | ||
</span> | ||
); | ||
|
||
const IconRenderer = ({ arrowIcon }) => ( | ||
<Icon icon={arrowIcon} color={colors.text} spin={false} /> | ||
); | ||
|
||
const ArrowButton = ({ action, text, direction }) => { | ||
const arrowIcon = direction === 'r' ? 'arrowRight' : 'arrowLeft'; | ||
|
||
const renderButton = () => { | ||
if (direction === 'r') { | ||
return ( | ||
<React.Fragment> | ||
<Text text={text} direction={direction} /> | ||
<IconRenderer arrowIcon={arrowIcon} /> | ||
</React.Fragment> | ||
); | ||
} | ||
return ( | ||
<React.Fragment> | ||
<IconRenderer arrowIcon={arrowIcon} /> | ||
<Text text={text} direction={direction} /> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className={styles.root} onClick={action}> | ||
{renderButton()} | ||
</div> | ||
); | ||
}; | ||
|
||
ArrowButton.defaultProps = { | ||
direction: 'r', | ||
}; | ||
|
||
ArrowButton.propTypes = { | ||
action: PropTypes.func.isRequired, | ||
text: PropTypes.string.isRequired, | ||
direction: PropTypes.string, | ||
}; | ||
|
||
export default ArrowButton; |
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,29 @@ | ||
@import "../../../assets/styles/config.css"; | ||
|
||
.root { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
color: var(--text); | ||
cursor: pointer; | ||
|
||
& .text { | ||
font-size: 1.5rem; | ||
font-weight: 600; | ||
text-transform: uppercase; | ||
|
||
&.l { | ||
margin-left: 1rem; | ||
} | ||
|
||
&.r { | ||
margin-right: 1rem; | ||
} | ||
} | ||
|
||
&:hover { | ||
& .text { | ||
text-decoration: underline; | ||
} | ||
} | ||
} |
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 @@ | ||
export { default } from './ArrowButton'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/works/2018-08-01-this-new-work-will-test-the-worksingle-layout.md
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