Skip to content

Commit 860f583

Browse files
author
Pavithra K
committed
Removes extra button component
1 parent 91596cb commit 860f583

File tree

3 files changed

+29
-104
lines changed

3 files changed

+29
-104
lines changed

components/vote/app.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'whatwg-fetch';
33
import SidebarItem from '../sidebar-item/sidebar-item';
44
import * as api from "./api";
55
import VoteButton from './button/button';
6-
import VoteItem from './button/new-button';
76
import Influence from './influence.jsx';
87
import GithubMark from '../../assets/github-logo.svg';
98

@@ -212,7 +211,7 @@ export default class VoteApp extends React.Component {
212211
let value = (userVote && userVote.votes) ? userVote.votes: 0;
213212
if(currencyInfo && currencyInfo.remaining + value < maximum) maximum = currencyInfo.remaining + value;
214213
return <div className="vote-app__item-button">
215-
<VoteItem
214+
<VoteButton
216215
className={"vote-app__vote-"+voteSettings.name}
217216
value={vote.votes} myValue={value}
218217
maxUp={userVote ? maximum - value : 0}
@@ -221,7 +220,7 @@ export default class VoteApp extends React.Component {
221220
isLoggedIn = {!!voteAppToken}
222221
onVote={(diffValue) => {
223222
this.vote(item.id, voteSettings.name, diffValue, voteSettings.currency, voteSettings.score);
224-
}}></VoteItem></div>;
223+
}}></VoteButton></div>;
225224
})}
226225
</div>
227226
<div className="vote-app__item-content">

components/vote/button/button.jsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import React from 'react';
1+
import React, {Component} from 'react';
2+
import "./button-style.scss";
23

3-
export default (props) => {
4-
let { value, myValue, maxDown, maxUp, color, onVote, className, isLoginActive } = props;
5-
let {voteAppToken} = localStorage;
6-
7-
let click = (e, n) => {
4+
export default class NewButton extends Component {
5+
handleClick (e, n) {
6+
const {maxUp, maxDown, onVote} = this.props;
87
onVote(Math.min(maxUp, Math.max(n, -maxDown)));
98
e.preventDefault();
109
return false;
11-
};
10+
}
1211

13-
let titleText = (n) => {
12+
titleText (n, maxUp, maxDown) {
1413
n = Math.min(maxUp, Math.max(n, -maxDown));
1514
if(n === 0)
1615
return "";
1716
return n > 0 ? "+" + n : "" + n;
18-
};
17+
}
1918

20-
let makeTriangle = (n, fn, size, minForEnabled) => {
19+
makeTriangle (n, fn, size, minForEnabled) {
20+
const {maxUp, maxDown, color} = this.props;
2121
const enabled = n !== 0 && (n > 0 ? (maxUp >= minForEnabled) : (maxDown >= minForEnabled));
22-
const className = "vote-button__upDown";
22+
const className = "vote-new-button__upDown";
2323
if(enabled) {
2424
return <a href="#"
25-
title={titleText(n)}
26-
onClick={e => click(e, n)}
25+
title={this.titleText(n, maxUp, maxDown)}
26+
onClick={e => this.handleClick(e, n)}
2727
className={className}>
2828
{fn({size: size, color: color})}
2929
</a>;
@@ -33,27 +33,27 @@ export default (props) => {
3333
{fn({size: size, color: "#eee"})}
3434
</a>;
3535
}
36-
};
37-
38-
return voteAppToken ? (<div className="vote-button" style={{color: color}}>
39-
{makeTriangle(Infinity, triangleUp, 30, 11)}
40-
{makeTriangle(10, triangleUp, 20, 2)}
41-
{makeTriangle(1, triangleUp, 15, 1)}
42-
<div className="vote-button__value" title={value + " was voted in total by all users."}>
36+
}
37+
render() {
38+
const {color, className, value, myValue, isLoggedIn} = this.props;
39+
return isLoggedIn ? (<div className="vote-new-button" style={{color: color}}>
40+
<div className="vote-new-button__arrows">
41+
{this.makeTriangle(1, triangleUp, 10, 1)}
42+
{this.makeTriangle(-1, triangleDown, 10, 1)}
43+
</div>
44+
<div className="vote-new-button__value" title={value + " was voted in total by all users."}>
4345
<span className={className}>{value}</span>
4446
</div>
45-
<div className="vote-button__my-value" title={myValue + " was voted by you."}>
47+
<div className="vote-new-button__my-value" title={myValue + " was voted by you."}>
4648
(<span className={className}>{myValue}</span>)
4749
</div>
48-
{makeTriangle(-1, triangleDown, 15, 1)}
49-
{makeTriangle(-10, triangleDown, 20, 2)}
50-
{makeTriangle(-Infinity, triangleDown, 30, 11)}
51-
</div>): (<div className="vote-button" style={{color: color}}>
52-
<div className="vote-button__value" title={value + " was voted in total by all users."}>
50+
</div>): (<div className="vote-new-button" style={{color: color}}>
51+
<div className="vote-new-button__logout-value" title={value + " was voted in total by all users."}>
5352
<span className={className}>{value}</span>
5453
</div>
5554
</div>);
56-
};
55+
}
56+
}
5757

5858
function triangleUp({color, size}) {
5959
let path = `m ${size},0 -${size},${size / 3 * 2} ${size*2},0 z`;

components/vote/button/new-button.jsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)