-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Reusable Components within Rewards #30
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
|
||
class ProgressBarExample extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
percentage: 0 | ||
}; | ||
|
||
this.nextStep = this.nextStep.bind(this); | ||
} | ||
|
||
nextStep() { | ||
if (this.state.percentage === 100) return; | ||
this.setState(prevState => ({ percentage: prevState.percentage + 20 })); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h2> A React Progress Bar </h2> | ||
<ProgressBar percentage={this.state.percentage} /> | ||
|
||
<div style={{ marginTop: '20px' }}> | ||
<button onClick={this.nextStep}>Next Step</button> | ||
</div> | ||
|
||
<div | ||
style={{ marginTop: '10px', color: 'blue', marginBottom: '15px' }} | ||
onClick={() => this.setState({ percentage: 0 })}> | ||
Reset | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export const ProgressBar = props => { | ||
return ( | ||
<div className="progress-bar"> | ||
<Filler percentage={props.percentage} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const Filler = props => { | ||
return <div className="filler" style={{ width: `${props.percentage}%` }} />; | ||
}; | ||
|
||
// Other React Stuff | ||
|
||
// Check out my free youtube video on how to build a thumbnail gallery in react | ||
// https://www.youtube.com/watch?v=GZ4d3HEn9zg | ||
|
||
// https://medium.com/@ItsMeDannyZ/build-an-image-slider-with-react-es6-264368de68e4 | ||
|
||
// Follow me on Github! | ||
// https://github.com/DZuz14 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import React from 'react'; | ||
import { Platform, StyleSheet, Text, View } from 'react-native'; | ||
import { Body } from '../BaseComponents'; | ||
import { View } from 'react-native'; | ||
import { Body, Caption, Title } from '../BaseComponents'; | ||
import { styles } from '../../styled/rewards'; | ||
import { ProgressBar } from '../rewards/ProgressBar'; | ||
|
||
/** | ||
* @prop | ||
* */ | ||
|
||
function RewardsHome({ transactions, user }) { | ||
return ( | ||
<View> | ||
<ProgressBar percentage="50" /> | ||
<View style={styles.getStartedContainer}> | ||
<Text> {`Welcome, ${user.name}`}</Text> | ||
<Title> {`Welcome, ${user.name}`}</Title> | ||
<Body>{user.points} total points </Body> | ||
<Text style={styles.getStartedText}> | ||
<Body style={styles.getStartedText}> | ||
{' '} | ||
{`${1000 - | ||
(parseInt(user.points) % 1000)} points to your next reward`} | ||
</Text> | ||
</Body> | ||
</View> | ||
|
||
<View style={styles.tabBarInfoContainer}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR task but this is all deprecated leftover from old versions of these designs. We can take all of this out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migrate styles into a separate stylesheet |
||
<Text style={styles.tabBarInfoText}>Your transaction history:</Text> | ||
<Caption style={styles.tabBarInfoText}> | ||
Your transaction history: | ||
</Caption> | ||
{transactions.splice(0, 3).map(transaction => { | ||
return ( | ||
<View key={transaction.id}> | ||
|
@@ -36,36 +42,4 @@ function RewardsHome({ transactions, user }) { | |
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
tabBarInfoContainer: { | ||
position: 'absolute', | ||
bottom: 150, | ||
left: 0, | ||
right: 0, | ||
...Platform.select({ | ||
ios: { | ||
shadowColor: 'black', | ||
shadowOffset: { width: 0, height: 3 }, | ||
shadowOpacity: 0.1, | ||
shadowRadius: 3 | ||
}, | ||
android: { | ||
elevation: 20 | ||
} | ||
}), | ||
alignItems: 'center', | ||
backgroundColor: '#fbfbfb', | ||
paddingVertical: 20 | ||
}, | ||
navigationFilename: { | ||
marginTop: 5 | ||
}, | ||
getStartedContainer: { | ||
alignItems: 'center', | ||
marginHorizontal: 50, | ||
paddingVertical: 20 | ||
} | ||
}); | ||
|
||
export default React.memo(RewardsHome); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
but please don't do this..