-
Notifications
You must be signed in to change notification settings - Fork 0
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
Google Oauth button redesigned and refactored the button component #13
base: develop
Are you sure you want to change the base?
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,13 @@ | ||
import React from 'react' | ||
import styles from './ui.module.css' | ||
import GoogleLogo from '../../../images/g.png' | ||
export default function GoogleButton({ onClick, textLabel }) { | ||
return ( | ||
<div className={styles.customBtn} onClick={onClick}> | ||
<span className={styles.icon}> | ||
<img className={styles.googleLogo} src={GoogleLogo} alt="glogo"></img> | ||
</span> | ||
<span className={styles.buttonText}>{textLabel}</span> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
import React from 'react' | ||
import styles from './labels.module.css' | ||
|
||
export default function Labels({ data, orientation }) { | ||
return ( | ||
<div | ||
className={styles.labels} | ||
style={{ | ||
flexDirection: orientation === 'horizontal' ? 'row' : 'column', | ||
justifyContent: | ||
orientation === 'horizontal' ? 'flex-start' : 'space-evenly', | ||
}}> | ||
{data.map((label, i) => ( | ||
<div key={i} className={styles.labelContainer}> | ||
<div className={styles.label} style={{ background: label.color }} /> | ||
<p className={styles.labelText}>{label.title}</p> | ||
export default class Labels extends React.Component { | ||
state = { | ||
selectedOption: 'Wpm', | ||
} | ||
|
||
toggleRadioCheck = (e) => { | ||
var option = e.target.value | ||
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. Use const |
||
this.setState({ | ||
selectedOption: option, | ||
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. Or actually no variable needed. Just do:
|
||
}) | ||
} | ||
render() { | ||
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. Add line above |
||
return ( | ||
<div | ||
className={styles.labels} | ||
style={{ | ||
flexDirection: 'row', | ||
justifyContent: 'flex-start', | ||
}}> | ||
<div className={styles.labelContainer}> | ||
<label> | ||
Wpm | ||
<input | ||
type="radio" | ||
value="Wpm" | ||
checked={this.state.selectedOption === 'Wpm'} | ||
onChange={this.toggleRadioCheck}></input> | ||
</label> | ||
<label> | ||
Accuracy | ||
<input | ||
type="radio" | ||
value="Accuracy" | ||
checked={this.state.selectedOption === 'Accuracy'} | ||
onChange={this.toggleRadioCheck}></input> | ||
</label> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
</div> | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import React from 'react' | ||
import NestedDonutChart from '../../common/charts/nestedDonutChart' | ||
import Labels from './labels' | ||
import Dropdown from './dropdown' | ||
import styles from './paragraphsCard.module.css' | ||
|
||
const labelOrientation = 'vertical', | ||
dropdownData = ['All Time', 'Weekly', 'Monthly'], | ||
const dropdownData = ['All Time', 'Weekly', 'Monthly'], | ||
labelData = [ | ||
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. Declare labelData in a separate const |
||
{ | ||
title: 'Total', | ||
|
@@ -30,7 +28,21 @@ export default function ParagraphsCard() { | |
</div> | ||
<div className={styles.chartSection}> | ||
<NestedDonutChart /> | ||
<Labels data={labelData} orientation={labelOrientation} /> | ||
<div | ||
style={{ | ||
flexDirection: 'column', | ||
justifyContent: 'flex-end', | ||
}}> | ||
{labelData.map((label, i) => ( | ||
<div key={i} className={styles.labelContainer}> | ||
<div | ||
className={styles.label} | ||
style={{ background: label.color }} | ||
/> | ||
<p className={styles.labelText}>{label.title}</p> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,17 @@ import Button from './button' | |
import Dropdown from './dropdown' | ||
import Labels from './labels' | ||
|
||
const labelOrientation = 'horizontal', | ||
dropdownOptions = ['All', 'Practise', 'Arena'], | ||
labelData = [ | ||
{ | ||
title: 'WPM', | ||
color: '#F0A500', | ||
}, | ||
{ | ||
title: 'Accuracy', | ||
color: '#EC486F', | ||
}, | ||
] | ||
const dropdownOptions = ['All', 'Practise', 'Arena'] | ||
// labelData = [ | ||
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. Why is this commented? If it's not used delete it |
||
// { | ||
// title: 'WPM', | ||
// color: '#F0A500', | ||
// }, | ||
// { | ||
// title: 'Accuracy', | ||
// color: '#EC486F', | ||
// }, | ||
// ] | ||
|
||
export default class ProgressCard extends Component { | ||
state = { | ||
|
@@ -61,7 +60,7 @@ export default class ProgressCard extends Component { | |
<div className={styles.card}> | ||
<div className={styles.header}> | ||
<Dropdown data={dropdownOptions} size="medium" /> | ||
<Labels data={labelData} orientation={labelOrientation} /> | ||
<Labels /> | ||
</div> | ||
<div className={styles.chartContainer}> | ||
<LineChart width={870} height={300} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ import { navigate } from '@reach/router' | |
import { setAuthToken } from '../../helpers/storage' | ||
import Para from './bgpara' | ||
import Logo from '../../images/Keyboard.png' | ||
import GoogleButton from '../common/ui/googeButton' | ||
import ButtonWithLoader from '../common/ui/button-with-loader' | ||
import './loginsignup.css' | ||
import { gapi } from 'gapi-script' | ||
// import authenticate from './gapi' | ||
|
||
export default class Login extends Component { | ||
state = { | ||
|
@@ -21,10 +21,6 @@ export default class Login extends Component { | |
userId: '', | ||
} | ||
|
||
// componentDidMount() { | ||
// this.onSignIn() | ||
// } | ||
|
||
handleInput = (stateName) => (e) => { | ||
e.preventDefault() | ||
this.setState({ | ||
|
@@ -119,24 +115,23 @@ export default class Login extends Component { | |
|
||
// Sign the user in, and then retrieve their ID. | ||
auth2.signIn().then((googleUser) => { | ||
console.log('chcek') | ||
console.log(googleUser) | ||
this.displayGoogelUser(googleUser) | ||
}) | ||
}) | ||
} | ||
|
||
displayGoogelUser = async (googleUser) => { | ||
if (googleUser) { | ||
var profile = googleUser.getBasicProfile() | ||
console.log('ID: ' + profile.getId()) // Don't send this directly to your server! | ||
console.log('Full Name: ' + profile.getName()) | ||
console.log('Given Name: ' + profile.getGivenName()) | ||
console.log('Family Name: ' + profile.getFamilyName()) | ||
console.log('Image URL: ' + profile.getImageUrl()) | ||
console.log('Email: ' + profile.getEmail()) | ||
// var profile = googleUser.getBasicProfile() | ||
//do not remove this comment will use it for ref | ||
// console.log('ID: ' + profile.getId()) // Don't send this directly to your server! | ||
// console.log('Full Name: ' + profile.getName()) | ||
// console.log('Given Name: ' + profile.getGivenName()) | ||
// console.log('Family Name: ' + profile.getFamilyName()) | ||
// console.log('Image URL: ' + profile.getImageUrl()) | ||
// console.log('Email: ' + profile.getEmail()) | ||
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. Delete comments |
||
var id_token = googleUser.getAuthResponse().id_token | ||
console.log(id_token) | ||
|
||
let obj = { | ||
token: id_token, | ||
} | ||
|
@@ -207,19 +202,18 @@ export default class Login extends Component { | |
onClick={this.submitForm}> | ||
Login | ||
</ButtonWithLoader> | ||
<div className="googleBtn"> | ||
<button onClick={this.onSignIn} data-theme="dark"> | ||
Sign in with google | ||
</button> | ||
</div> | ||
|
||
<div style={{ margin: '10px auto' }}>Or </div> | ||
<GoogleButton | ||
onClick={this.onSignIn} | ||
textLabel="Sign In With Google"></GoogleButton> | ||
</div> | ||
<div className="signupdiv"> | ||
New Here? | ||
<span className="signup" onClick={this.navigateToSignup}> | ||
Signup | ||
</span> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
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.
Add line above