Skip to content

Commit 55d23b0

Browse files
committed
Merge branch 'dashboard-update' into develop
2 parents 60d27b1 + 7157c2e commit 55d23b0

File tree

9 files changed

+179
-110
lines changed

9 files changed

+179
-110
lines changed

.exchange-rates.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1520038805,"base":"USD","rates":{"AED":3.673014,"AFN":69.475,"ALL":107.5,"AMD":480.77,"ANG":1.784194,"AOA":215.1155,"ARS":20.264,"AUD":1.2889,"AWG":1.786505,"AZN":1.68825,"BAM":1.58875,"BBD":2,"BDT":82.977763,"BGN":1.58816,"BHD":0.377075,"BIF":1775,"BMD":1,"BND":1.321966,"BOB":6.910011,"BRL":3.2528,"BSD":1,"BTC":0.00009030383,"BTN":65.19905,"BWP":9.578914,"BYN":1.965596,"BZD":2.009098,"CAD":1.288544,"CDF":1615,"CHF":0.938145,"CLF":0.0225,"CLP":598.8,"CNH":6.330917,"CNY":6.3484,"COP":2867,"CRC":569.71,"CUC":1,"CUP":25.5,"CVE":89.7375,"CZK":20.5919,"DJF":177.075,"DKK":6.04549,"DOP":49.13,"DZD":114.04071,"EGP":17.641,"ERN":14.996667,"ETB":27.56,"EUR":0.81179,"FJD":2.021996,"FKP":0.7246,"GBP":0.7246,"GEL":2.463723,"GGP":0.7246,"GHS":4.46,"GIP":0.7246,"GMD":47.2,"GNF":9000,"GTQ":7.373907,"GYD":206.445,"HKD":7.830598,"HNL":23.601015,"HRK":6.038184,"HTG":64.297808,"HUF":254.66,"IDR":13730.326709,"ILS":3.442442,"IMP":0.7246,"INR":65.1967,"IQD":1183,"IRR":37302.484098,"ISK":100.59,"JEP":0.7246,"JMD":127.1499,"JOD":0.709001,"JPY":105.75296581,"KES":101.3855,"KGS":68.035298,"KHR":4002,"KMF":399.45,"KPW":900,"KRW":1079.65,"KWD":0.299888,"KYD":0.832789,"KZT":322.647036,"LAK":8305,"LBP":1512.5,"LKR":155.13,"LRD":130.5,"LSL":11.91,"LYD":1.33,"MAD":9.2,"MDL":16.695982,"MGA":3117.5,"MKD":49.983876,"MMK":1339.7,"MNT":2390.948643,"MOP":8.06072,"MRO":356,"MRU":35.3,"MUR":33.04,"MVR":15.460011,"MWK":725.725,"MXN":18.812575,"MYR":3.930279,"MZN":61.855,"NAD":11.915,"NGN":360.5,"NIO":31.085,"NOK":7.796875,"NPR":104.297226,"NZD":1.382,"OMR":0.384918,"PAB":1,"PEN":3.2565,"PGK":3.195,"PHP":51.939,"PKR":110.65,"PLN":3.4003,"PYG":5550.4,"QAR":3.641996,"RON":3.782471,"RSD":95.696456,"RUB":56.815,"RWF":856,"SAR":3.75015,"SBD":7.76394,"SCR":13.699823,"SDG":18.01,"SEK":8.2507,"SGD":1.319653,"SHP":0.7246,"SLL":7668.450022,"SOS":582,"SRD":7.468,"SSP":130.2634,"STD":19933.390132,"STN":19.985,"SVC":8.745727,"SYP":514.98999,"SZL":11.91,"THB":31.4455,"TJS":8.820764,"TMT":3.499986,"TND":2.4212,"TOP":2.217721,"TRY":3.806784,"TTD":6.73915,"TWD":29.283,"TZS":2254.1,"UAH":26.5275,"UGX":3648.3,"USD":1,"UYU":28.40176,"UZS":8180,"VEF":28960,"VND":22757.110027,"VUV":105.255077,"WST":2.5271,"XAF":532.499333,"XAG":0.06061195,"XAU":0.00075614,"XCD":2.70255,"XDR":0.689644,"XOF":532.499333,"XPD":0.00100706,"XPF":96.872315,"XPT":0.00103467,"YER":250.325,"ZAR":11.923195,"ZMW":9.74,"ZWL":322.355011}}
1+
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1520089201,"base":"USD","rates":{"AED":3.673014,"AFN":69.475,"ALL":107.5,"AMD":480.77,"ANG":1.784194,"AOA":215.1155,"ARS":20.264,"AUD":1.287333,"AWG":1.786505,"AZN":1.68825,"BAM":1.58875,"BBD":2,"BDT":82.977763,"BGN":1.58816,"BHD":0.377075,"BIF":1775,"BMD":1,"BND":1.321966,"BOB":6.910011,"BRL":3.2527,"BSD":1,"BTC":0.000087767587,"BTN":65.19905,"BWP":9.578914,"BYN":1.965596,"BZD":2.009098,"CAD":1.288544,"CDF":1615,"CHF":0.938145,"CLF":0.0225,"CLP":598.8,"CNH":6.330917,"CNY":6.3484,"COP":2867,"CRC":569.71,"CUC":1,"CUP":25.5,"CVE":89.7375,"CZK":20.5916,"DJF":177.075,"DKK":6.0457,"DOP":49.13,"DZD":114.04071,"EGP":17.641,"ERN":14.996667,"ETB":27.56,"EUR":0.81179,"FJD":2.021996,"FKP":0.7246,"GBP":0.7246,"GEL":2.463723,"GGP":0.7246,"GHS":4.46,"GIP":0.7246,"GMD":47.2,"GNF":9000,"GTQ":7.373907,"GYD":206.445,"HKD":7.83065,"HNL":23.601015,"HRK":6.038184,"HTG":64.297808,"HUF":254.66,"IDR":13730.326709,"ILS":3.442442,"IMP":0.7246,"INR":65.1967,"IQD":1183,"IRR":37302.484098,"ISK":100.59,"JEP":0.7246,"JMD":127.1499,"JOD":0.709001,"JPY":105.75296581,"KES":101.3855,"KGS":68.035298,"KHR":4002,"KMF":399.45,"KPW":900,"KRW":1079.43,"KWD":0.299888,"KYD":0.832789,"KZT":322.647036,"LAK":8305,"LBP":1512.5,"LKR":155.13,"LRD":130.5,"LSL":11.91,"LYD":1.33,"MAD":9.2,"MDL":16.695982,"MGA":3117.5,"MKD":49.983876,"MMK":1339.7,"MNT":2390.948643,"MOP":8.06072,"MRO":356,"MRU":35.3,"MUR":33.04,"MVR":15.460011,"MWK":725.725,"MXN":18.8111,"MYR":3.930279,"MZN":61.855,"NAD":11.915,"NGN":360.5,"NIO":31.085,"NOK":7.795175,"NPR":104.297226,"NZD":1.382,"OMR":0.384918,"PAB":1,"PEN":3.2565,"PGK":3.195,"PHP":51.939,"PKR":110.65,"PLN":3.40025,"PYG":5550.4,"QAR":3.641996,"RON":3.782471,"RSD":95.696456,"RUB":56.815,"RWF":856,"SAR":3.75015,"SBD":7.76394,"SCR":13.699823,"SDG":18.01,"SEK":8.2507,"SGD":1.319697,"SHP":0.7246,"SLL":7668.450022,"SOS":582,"SRD":7.468,"SSP":130.2634,"STD":19933.390132,"STN":19.985,"SVC":8.745727,"SYP":514.98999,"SZL":11.91,"THB":31.4465,"TJS":8.820764,"TMT":3.499986,"TND":2.4212,"TOP":2.217721,"TRY":3.806784,"TTD":6.73915,"TWD":29.283,"TZS":2254.1,"UAH":26.5275,"UGX":3648.3,"USD":1,"UYU":28.40176,"UZS":8180,"VEF":28960,"VND":22757.110027,"VUV":105.255077,"WST":2.5271,"XAF":532.499333,"XAG":0.06061195,"XAU":0.00075614,"XCD":2.70255,"XDR":0.689644,"XOF":532.499333,"XPD":0.00100706,"XPF":96.872315,"XPT":0.00103467,"YER":250.325,"ZAR":11.923055,"ZMW":9.74,"ZWL":322.355011}}

src/shared/components/Carousel.jsx

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* A standard carousel component.
3+
*
4+
* Currently this is a wrapper arround nuka-carousel, that improves its
5+
* responsiveness to the viewport size changes:
6+
* - Shows / hides scrolling buttons when necessary;
7+
* - Aligns the content in center when all cards can be shown at once.
8+
*/
9+
10+
/* global window */
11+
12+
import Nuka from 'nuka-carousel';
13+
import PT from 'prop-types';
14+
import React from 'react';
15+
16+
/* We have to use state component, as we need to manipulate with DOM nodes to
17+
* access nuka-carousel state. */
18+
export default class Carousel extends React.Component {
19+
constructor(props) {
20+
super(props);
21+
this.check = this.check.bind(this);
22+
this.state = {};
23+
}
24+
25+
componentDidMount() {
26+
window.addEventListener('resize', this.check);
27+
}
28+
29+
componentWillUnmount() {
30+
window.removeEventListener('resize', this.check);
31+
}
32+
33+
/**
34+
* Checks carousel state to determine, whether the left / right arrows should
35+
* be shown.
36+
*/
37+
check() {
38+
if (!this.carousel) return;
39+
const st = this.carousel.state;
40+
const showNext = st.currentSlide < st.slideCount - st.slidesToScroll;
41+
const showPrev = st.left < 0;
42+
if (showNext !== this.state.showNext
43+
|| showPrev !== this.state.showPrev) {
44+
this.setState({ showPrev, showNext });
45+
}
46+
}
47+
48+
render() {
49+
const { children, NextButton, PrevButton } = this.props;
50+
const st = this.state;
51+
const decorators = [];
52+
if (st.showNext && NextButton) {
53+
decorators.push({
54+
component: () => (
55+
<NextButton
56+
onClick={() => this.carousel && this.carousel.nextSlide()}
57+
/>
58+
),
59+
position: 'CenterRight',
60+
style: {
61+
cursor: 'pointer',
62+
marginRight: 40,
63+
},
64+
});
65+
}
66+
if (st.showPrev && PrevButton) {
67+
decorators.push({
68+
component: () => (
69+
<PrevButton
70+
onClick={() => this.carousel && this.carousel.previousSlide()}
71+
/>
72+
),
73+
position: 'CenterLeft',
74+
style: {
75+
cursor: 'pointer',
76+
marginLeft: 40,
77+
},
78+
});
79+
}
80+
return (
81+
<Nuka
82+
{...this.props}
83+
afterSlide={() => setImmediate(() => this.check())}
84+
decorators={decorators}
85+
framePadding="0 100px"
86+
ref={(node) => {
87+
this.carousel = node;
88+
if (node) this.check();
89+
}}
90+
slidesToScroll="auto"
91+
style={{
92+
display: 'flex',
93+
justifyContent: 'center',
94+
}}
95+
>{children}</Nuka>
96+
);
97+
}
98+
}
99+
100+
Carousel.defaultProps = {
101+
NextButton: null,
102+
PrevButton: null,
103+
};
104+
105+
Carousel.propTypes = {
106+
children: PT.node.isRequired,
107+
NextButton: PT.func,
108+
PrevButton: PT.func,
109+
};

src/shared/components/Dashboard/Announcement/style.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
background-size: cover;
66
border-bottom: 1px solid $tc-gray-neutral-dark;
77
display: flex;
8-
height: 480px;
8+
min-height: 480px;
99
max-width: $screen-lg;
1010
padding: 30px;
1111
position: relative;
1212
width: 100%;
13+
14+
@include xs-to-sm {
15+
flex-direction: column;
16+
}
1317
}
1418

1519
.details {
@@ -81,6 +85,11 @@
8185
.video {
8286
flex: 1;
8387
margin: 35px 30px 35px 0;
88+
89+
@include xs-to-sm {
90+
align-self: stretch;
91+
margin-bottom: 0;
92+
}
8493
}
8594

8695
.hidden {

src/shared/components/Dashboard/MemberMetrics/Earnings/Dial/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
margin: 0 auto;
77
padding: 20px 30px;
88
text-align: center;
9+
width: 300px;
910
}
1011

1112
.content {

src/shared/components/Dashboard/MemberMetrics/Earnings/index.jsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import _ from 'lodash';
2+
import Carousel from 'components/Carousel';
23
import config from 'utils/config';
34
import PT from 'prop-types';
45
import React from 'react';
56

67
import { Link } from 'topcoder-react-utils';
78

89
import Dial from './Dial';
10+
import LArrow from '../../../../../assets/images/arrow-prev.svg';
11+
import RArrow from '../../../../../assets/images/arrow-next.svg';
912

1013
import './style.scss';
1114

@@ -37,24 +40,30 @@ export default function Earnings({ finances, showEarnings }) {
3740
if (owed && paid) {
3841
return (
3942
<div styleName="container">
40-
<Dial
41-
amount={paid}
42-
show={showEarnings}
43-
title="Paid"
44-
url={PACTS_FULL_URL}
45-
/>
46-
<Dial
47-
amount={owed}
48-
show={showEarnings}
49-
title="Owed"
50-
url={PACTS_OWED_URL}
51-
/>
52-
<Dial
53-
amount={total}
54-
show={showEarnings}
55-
title="Total"
56-
url={PACTS_FULL_URL}
57-
/>
43+
<Carousel
44+
NextButton={RArrow}
45+
PrevButton={LArrow}
46+
slideWidth="300px"
47+
>
48+
<Dial
49+
amount={paid}
50+
show={showEarnings}
51+
title="Paid"
52+
url={PACTS_FULL_URL}
53+
/>
54+
<Dial
55+
amount={owed}
56+
show={showEarnings}
57+
title="Owed"
58+
url={PACTS_OWED_URL}
59+
/>
60+
<Dial
61+
amount={total}
62+
show={showEarnings}
63+
title="Total"
64+
url={PACTS_FULL_URL}
65+
/>
66+
</Carousel>
5867
</div>
5968
);
6069
}

src/shared/components/Dashboard/MemberMetrics/Records/index.jsx

Lines changed: 25 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import _ from 'lodash';
2-
import Carousel from 'nuka-carousel';
2+
import Carousel from 'components/Carousel';
33
import PT from 'prop-types';
44
import React from 'react';
55

66
import Dial from './Dial';
77
import LArrow from '../../../../../assets/images/arrow-prev.svg';
88
import RArrow from '../../../../../assets/images/arrow-next.svg';
99

10+
import './style.scss';
11+
1012
/**
1113
* Transforms stats object to a more convenient array representation.
1214
* @param {Object} stats
@@ -59,95 +61,29 @@ function transformStats(stats) {
5961
return res;
6062
}
6163

62-
export default class Records extends React.Component {
63-
constructor(props) {
64-
super(props);
65-
this.state = {};
66-
}
67-
68-
check() {
69-
if (!this.carousel) return;
70-
const st = this.carousel.state;
71-
const showLeft = Boolean(st.currentSlide);
72-
const showRight = st.currentSlide < st.slideCount - st.slidesToScroll;
73-
const align = st.slideCount === 'auto'
74-
|| st.slidesToScroll >= st.slideCount;
75-
if (showLeft === this.state.showLeft
76-
&& showRight === this.state.showRight
77-
&& align === this.state.align) return;
78-
this.setState({ align, showLeft, showRight });
79-
}
80-
81-
render() {
82-
const st = this.state;
83-
const { stats } = this.props;
84-
85-
const decorators = [];
86-
if (st.showLeft) {
87-
decorators.push({
88-
component: () => (
89-
<LArrow
90-
onClick={() => this.carousel && this.carousel.previousSlide()}
91-
/>
92-
),
93-
position: 'CenterLeft',
94-
style: {
95-
cursor: 'pointer',
96-
marginLeft: 40,
97-
},
98-
});
99-
}
100-
if (st.showRight) {
101-
decorators.push({
102-
component: () => (
103-
<RArrow
104-
onClick={() => this.carousel && this.carousel.nextSlide()}
105-
/>
106-
),
107-
position: 'CenterRight',
108-
style: {
109-
cursor: 'pointer',
110-
marginRight: 40,
111-
},
112-
});
113-
}
114-
115-
return (
116-
<div
117-
style={{ display: this.state.align ? 'inline-block' : 'block' }}
64+
export default function Records({ stats }) {
65+
return (
66+
<div>
67+
<Carousel
68+
NextButton={RArrow}
69+
PrevButton={LArrow}
70+
slideWidth="200px"
11871
>
119-
<Carousel
120-
afterSlide={() => setImmediate(() => this.check())}
121-
decorators={decorators}
122-
framePadding="0 100px"
123-
ref={(node) => {
124-
this.carousel = node;
125-
if (node) this.check();
126-
}}
127-
slidesToScroll="auto"
128-
slideWidth="200px"
129-
width={
130-
this.state.align ? (
131-
(200 * this.carousel.state.slideCount) + 200
132-
) : '100%'
133-
}
134-
>
135-
{
136-
transformStats(stats).map(item => (
137-
<Dial
138-
key={`${item.track}-${item.subTrack}`}
139-
handle={stats.handle}
140-
track={item.track}
141-
subTrack={item.subTrack}
142-
metric={item.metric}
143-
value={item.value}
144-
/>
145-
))
146-
}
147-
</Carousel>
148-
</div>
149-
);
150-
}
72+
{
73+
transformStats(stats).map(item => (
74+
<Dial
75+
key={`${item.track}-${item.subTrack}`}
76+
handle={stats.handle}
77+
track={item.track}
78+
subTrack={item.subTrack}
79+
metric={item.metric}
80+
value={item.value}
81+
/>
82+
))
83+
}
84+
</Carousel>
85+
</div>
86+
);
15187
}
15288

15389
Records.propTypes = {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.container {
2+
display: flex;
3+
justify-content: center;
4+
}

src/shared/components/Dashboard/MemberMetrics/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252

5353
position: absolute;
5454
right: 25px;
55-
top: 30px;
55+
top: 10px;
5656
}

src/shared/components/Dashboard/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
background: $tc-gray-neutral-dark;
55
flex: 1;
66
padding: 20px 30px;
7+
width: 100%;
78

89
@include xs-to-sm {
910
padding: 0;

0 commit comments

Comments
 (0)