Skip to content

Commit ed5c523

Browse files
author
Pavithra K
committed
Have all user info and actions in one place
1 parent 5f9f942 commit ed5c523

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

components/vote/app-style.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,34 @@
6565
}
6666
}
6767

68+
&__userinfo {
69+
outline: none;
70+
border: none;
71+
background: getColor(elephant);
72+
color: white;
73+
cursor: pointer;
74+
border-radius: 3px;
75+
font-size: 13px;
76+
display: inline-block;
77+
padding: 3px 10px;
78+
79+
img {
80+
height: 25px;
81+
vertical-align: middle;
82+
margin-right: 10px;
83+
}
84+
}
85+
6886
&__self-info {
6987
margin-top: 10px;
7088
}
7189

90+
&__button-area {
91+
margin: 5px 0;
92+
}
93+
7294
&__update-button {
73-
float: right;
95+
7496
}
7597

7698
h1 {

components/vote/app.jsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,11 @@ export default class VoteApp extends React.Component {
188188
<Influence className="vote-app__influence-section" type="golden"/>
189189
</div>
190190
<div className="vote-app__user-section">
191-
{this.renderSelf()}
191+
{this.renderSelf(inProgress)}
192192
</div>
193193
</div>
194194
</div>
195195
{ listInfo && <div>
196-
{voteAppToken && <button className="vote-app__update-button" disabled={inProgress} onClick={() => {
197-
this.updateSelf();
198-
this.updateList();
199-
}}>Update</button>}
200196
<h1>{listInfo.displayName}</h1>
201197
<div>{listInfo.description}</div>
202198
<ul className="vote-app__items-list">
@@ -265,7 +261,7 @@ export default class VoteApp extends React.Component {
265261
);
266262
}
267263

268-
renderSelf() {
264+
renderSelf (inProgress) {
269265
let { listInfo, selfInfo, isFetchingSelf } = this.state;
270266
if(!selfInfo) {
271267
if(isFetchingSelf) {
@@ -276,17 +272,27 @@ export default class VoteApp extends React.Component {
276272
}}>Login with Github <img src={GithubMark}/> </button></div>;
277273
} else {
278274
return <div className="vote-app__self-info">
279-
You are logged in as {selfInfo.login}. <button onClick={() => {
280-
delete window.localStorage.voteAppToken;
281-
window.location.reload();
282-
}}>Log out</button>
275+
<div className="vote-app__userinfo" >
276+
<img alt={selfInfo.login} src={selfInfo.avatar} />
277+
{selfInfo.login}
278+
</div>
283279
{ listInfo && <ul className="vote-app__currency-list">
284280
{ selfInfo.currencies
285281
.filter(currency => listInfo.possibleVotes.some(voteSettings => voteSettings.currency === currency.name))
286282
.map(currency => <li className={"vote-app__currency-" + currency.name} title={`${currency.description}\nYou used ${currency.used} of a total of ${currency.value} ${currency.displayName}.`}>
287283
{currency.remaining} {currency.displayName}
288284
</li>) }
289285
</ul> }
286+
<div className="vote-app__button-area">
287+
<button className="vote-app__logout-button" onClick={() => {
288+
delete window.localStorage.voteAppToken;
289+
window.location.reload();
290+
}}>Logout</button>
291+
<button className="vote-app__update-button" disabled={inProgress} onClick={() => {
292+
this.updateSelf();
293+
this.updateList();
294+
}}>Update</button>
295+
</div>
290296
</div>;
291297
}
292298
}

0 commit comments

Comments
 (0)