Skip to content

Commit 52bb39f

Browse files
committed
feat: add play with model to homepage
1 parent fc75a37 commit 52bb39f

File tree

18 files changed

+125
-127
lines changed

18 files changed

+125
-127
lines changed

src/components/button/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import './style.scss';
44

55
const Button = (props) => {
66
const {
7-
onClick, buttonStyle = 'primary', children,
7+
onClick, buttonStyle = 'primary', children, className = '',
88
} = props;
99

10-
return <button type="button" onClick={onClick} className={`button animated-button button button-${buttonStyle}`}>{children}</button>;
10+
return <button type="button" onClick={onClick} className={`button animated-button button button-${buttonStyle} ${className}`}>{children}</button>;
1111
};
1212

1313
export default Button;

src/screens/home/component.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';
22
import { useLocation } from 'react-router-dom';
33

44
import {
5-
BlogPost, HeroSection, HistoricalData, HowItWorks, MiniMap, Video,
5+
BlogPost, HeroSection, HistoricalData, HowItWorks, MiniMap, PlayWithModel, Video,
66
} from './components';
77

88
import './style.scss';
@@ -20,12 +20,12 @@ const Home = () => {
2020
}, [location.search]);
2121

2222
return (
23-
<div className="container" id="home-container">
23+
<div className="container">
2424
<HeroSection />
2525
<div className="home-content">
2626
<MiniMap />
2727
<BlogPost />
28-
<div className="page-container" style={{ height: '200px' }}>1st section</div>
28+
<PlayWithModel />
2929
<div className="home-content-section">
3030
<HistoricalData />
3131
<Video />

src/screens/home/components/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import HeroSection from './hero-section';
33
import HistoricalData from './historical-data';
44
import HowItWorks from './how-does-it-work';
55
import MiniMap from './mini-map';
6+
import PlayWithModel from './play-with-model';
67
import Video from './video';
78

89
export {
9-
BlogPost, HeroSection, HistoricalData, HowItWorks, MiniMap, Video,
10+
BlogPost, HeroSection, HistoricalData, HowItWorks, MiniMap, PlayWithModel, Video,
1011
};

src/screens/home/components/mini-map/style.scss

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
width: 100%;
88
padding: 0;
99
margin-bottom: 24px;
10+
box-shadow: none;
1011

1112
#map {
1213
height: 500px;

src/screens/home/components/play-with-model/component.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
SelectionBar,
88
} from './components';
99

10-
import { Loading } from '../../components';
10+
import { Loading } from '../../../../components';
1111

12-
import { DATA_MODES } from '../../constants';
12+
import { DATA_MODES } from '../../../../constants';
1313

1414
export const DEFAULT_MODEL_VERSION = 2024;
1515

@@ -102,12 +102,12 @@ const PlayWithModel = (props) => {
102102
}, [county, dataMode, predictions, rangerDistrict, selectedState]);
103103

104104
return (
105-
<div>
105+
<div className="page-container">
106106
<Loading visible={isLoading} />
107107
{fetchErrorText.length > 0 && fetchErrorText.map((t) => <p>{t}</p>)}
108108
<OverviewText />
109109
<SelectionBar />
110-
<div className="container" id="play-with-model-inputs-container">
110+
<div className="play-with-model-inputs-container">
111111
<PlayWithModelInputs
112112
modelInputs={modelInputs}
113113
runModel={runModel}

src/screens/home/components/play-with-model/components/overview-text/component.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ import React from 'react';
22
import ReactTooltip from 'react-tooltip';
33
import './style.scss';
44

5-
import questionIcon from '../../../../assets/icons/help-circle.png';
5+
import questionIcon from '../../../../../../assets/icons/help-circle.png';
66

77
const helpText = `Pick a year, state and<br />
88
county/ranger district to<br />
99
prepopulate the fields based<br />
1010
on historical data.`;
1111

1212
const OverviewText = (_props) => (
13-
<div className="container" id="overview-text">
14-
<h1 id="title">
13+
<div className="play-with-model-overview-text">
14+
<h1 className="home-content-section-title">
1515
Play with the Model
1616
</h1>
1717
<div>
18-
<img id="icon"
18+
<img className="play-with-model-icon"
1919
data-tip={helpText}
2020
src={questionIcon}
2121
alt="Help"
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
#overview-text {
2-
display: flex;
3-
justify-content: center;
4-
margin-top: 50px;
5-
margin-bottom: 50px;
6-
}
1+
.play-with-model {
2+
&-overview-text {
3+
display: flex;
4+
margin-bottom: 20px;
5+
}
76

8-
#title {
9-
font-family: 'Inter';
10-
font-size: 44px;
11-
letter-spacing: 1;
12-
margin-right: 21px;
13-
}
14-
15-
#icon {
16-
width: 36px;
17-
height: 36px;
18-
margin-top: 8px;
19-
}
7+
&-icon {
8+
width: 24px;
9+
height: 24px;
10+
margin-top: 2px;
11+
margin-left: 6px;
12+
}
13+
}

src/screens/home/components/play-with-model/components/play-with-model-inputs/component.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
22

3-
import './style.scss';
3+
import trapIcon from '../../../../../../assets/icons/trap.png';
4+
import cleridsIcon from '../../../../../../assets/icons/clerids.png';
5+
import endobrevIcon from '../../../../../../assets/icons/endobrev.png';
6+
import { ChoiceInput } from '../../../../../../components/input-components';
7+
import { Button } from '../../../../../../components';
48

5-
import trapIcon from '../../../../assets/icons/trap.png';
6-
import cleridsIcon from '../../../../assets/icons/clerids.png';
7-
import endobrevIcon from '../../../../assets/icons/endobrev.png';
8-
import { ChoiceInput } from '../../../../components/input-components';
9+
import './style.scss';
910

1011
const PlayWithModelInputs = (props) => {
1112
const {
@@ -182,9 +183,9 @@ const PlayWithModelInputs = (props) => {
182183
firstOptionText="Year"
183184
/>
184185
</div>
185-
<button className="animated-button" id="run-button" type="button" onClick={runModel}>
186+
<Button className="run-button" onClick={runModel}>
186187
Run
187-
</button>
188+
</Button>
188189
</div>
189190
</div>
190191
);

src/screens/home/components/play-with-model/components/play-with-model-inputs/style.scss

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
#play-with-model-inputs-container {
2-
display: flex;
1+
.play-with-model-inputs-container {
32
justify-content: space-between;
4-
padding: 36px 47px 39px 61px;
53
border-radius: 26px;
6-
box-shadow: 0 35px 90px -10px rgba(0, 0, 0, 0.06);
7-
background-color: #ffffff;
8-
margin-top: 58px;
9-
margin-bottom: 100px;
104
}
115

126
.change-fields-container {
@@ -21,7 +15,7 @@
2115
margin-bottom: 37px;
2216

2317
.input-description {
24-
font-size: 22px;
18+
font-size: 18px;
2519
font-weight: 600;
2620
line-height: 1.4;
2721
text-align: left;
@@ -31,8 +25,7 @@
3125
.required-text {
3226
color: #ff0000;
3327
float: right;
34-
margin-right: 20px;
35-
margin-top: 7px;
28+
margin-top: 10px;
3629
}
3730
}
3831

@@ -128,23 +121,14 @@ span.required-text {
128121
}
129122
}
130123

131-
#run-button {
124+
.run-button {
132125
width: 129px;
133-
padding: 11px 20px;
134-
margin-top: 25px;
135-
margin-bottom: 10px;
136-
border-radius: 6px;
137-
background-color: #3c4253;
138-
font-size: 20px;
139-
font-weight: 500;
140-
color: #ffffff;
141-
float: right;
142126
}
143127

144128
.actions-container {
145129
display: flex;
146130
justify-content: space-between;
147-
align-items: center;
131+
align-items: flex-end;
148132

149133
.selection-button {
150134
background-color: #f0f2f8;

src/screens/home/components/play-with-model/components/play-with-model-outputs/component.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ const PlayWithModelOutputs = (props) => {
7272
return (
7373
<div id="predictions-output">
7474
<div id="vl" />
75+
<div id="predictions-generated-title">
76+
<p>{predictionTitle()}</p>
77+
</div>
7578
<div className="predictions-generated">
76-
<div id="predictions-generated-title">
77-
<p>{predictionTitle()}</p>
78-
</div>
7979
{predictionDetails()}
8080
</div>
8181
</div>

src/screens/home/components/play-with-model/components/play-with-model-outputs/style.scss

+23-17
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,56 @@
11
#predictions-output {
2-
display: flex;
2+
width: 100%;
3+
margin-top: 30px;
34

45
#vl {
5-
border-left: 2px dashed #d7dae4;
6+
border-top: 2px dashed #d7dae4;
67
height: auto;
7-
margin-right: 30px;
8-
margin-left: 30px;
8+
padding-top: 30px;
99
}
1010

1111
#predictions-generated-title {
12-
font-size: 16px;
12+
font-size: 18px;
1313
font-weight: 600;
1414
color: #3c4253;
15-
text-align: left;
15+
text-align: center;
1616

1717
p {
1818
height: 56px;
1919
}
2020
}
2121

2222
.predictions-generated {
23-
width: 250px;
24-
margin-left: 20px;
25-
margin-right: 20px;
23+
width: 100%;
24+
padding: 0 10px;
25+
box-sizing: border-box;
26+
display: flex;
27+
justify-content: space-between;
28+
gap: 20px;
2629

27-
#prob-spots, #prob-spots-disabled,
28-
#prob-outbreak, #prob-outbreak-disabled {
30+
#prob-spots,
31+
#prob-spots-disabled,
32+
#prob-outbreak,
33+
#prob-outbreak-disabled {
2934
width: 11vw;
30-
max-width: 150px;
35+
max-width: 300px;
3136
padding: 14px 48px 14px 49px;
3237
border-radius: 12px;
3338
}
3439

35-
#prob-spots, #prob-spots-disabled {
40+
#prob-spots,
41+
#prob-spots-disabled {
3642
box-shadow: 0 18px 50px 0 rgba(255, 193, 72, 0.4);
3743
background-color: #ffc148;
38-
margin-top: 35px;
3944
}
4045

41-
#prob-outbreak, #prob-outbreak-disabled {
46+
#prob-outbreak,
47+
#prob-outbreak-disabled {
4248
box-shadow: 0 18px 50px 0 rgba(134, 204, 255, 0.4);
4349
background-color: #86ccff;
44-
margin-top: 50px;
4550
}
4651

47-
#prob-outbreak-disabled, #prob-spots-disabled {
52+
#prob-outbreak-disabled,
53+
#prob-spots-disabled {
4854
box-shadow: 0 18px 50px 0 rgba(49, 57, 85, 0.04);
4955
background-color: #c9cdd9;
5056
}

src/screens/home/components/play-with-model/components/selection-bar/component.js

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react';
22

3-
import { ChoiceInput } from '../../../../components/input-components';
3+
import { ChoiceInput } from '../../../../../../components/input-components';
4+
import { Button } from '../../../../../../components';
45

5-
import { DATA_MODES } from '../../../../constants';
6+
import { DATA_MODES } from '../../../../../../constants';
67

78
import {
89
getStateNameFromAbbreviation,
910
getStateAbbreviationFromStateName,
10-
} from '../../../../utils';
11+
} from '../../../../../../utils';
1112

1213
import './style.scss';
1314

@@ -37,22 +38,20 @@ const SelectionBar = (props) => {
3738
const countyMode = dataMode === DATA_MODES.COUNTY;
3839

3940
return (
40-
<div id="predictionbar" className="container">
41-
<div className="predictionbar-year-selection">
42-
<p className="predictionbar-year-selection-title">Year</p>
43-
<div className="predictionbar-year-selection-options">
41+
<div className="play-with-model-bar">
42+
<div className="play-with-model-bar-selection">
43+
<p className="play-with-model-bar-selection-title">Year</p>
44+
<div className="play-with-model-bar-selection-options">
4445
<ChoiceInput setValue={setPredictionYear} value={year} options={revYears} firstOptionText="Year" />
4546
</div>
4647
</div>
47-
<div id="vl1" />
48-
<div className="predictionbar-year-selection">
49-
<p className="predictionbar-year-selection-title">State</p>
50-
<div className="predictionbar-year-selection-options">
48+
<div className="play-with-model-bar-selection">
49+
<p className="play-with-model-bar-selection-title">State</p>
50+
<div className="play-with-model-bar-selection-options">
5151
<ChoiceInput value={selectedStateName} setValue={setStateAbbrev} options={statesMappedToNames} firstOptionText="State" />
5252
</div>
5353
</div>
54-
<div id="vl1" />
55-
<div className="predictionbar-year-selection">
54+
<div className="play-with-model-bar-selection">
5655
<div id="mode-selection">
5756
<button
5857
type="button"
@@ -62,7 +61,6 @@ const SelectionBar = (props) => {
6261
>
6362
County
6463
</button>
65-
<div id="vl2" />
6664
<button
6765
type="button"
6866
id="mode-btn"
@@ -82,14 +80,12 @@ const SelectionBar = (props) => {
8280
/>
8381
</div>
8482
</div>
85-
<button
86-
type="button"
87-
id="reset-current-data-button"
88-
className="animated-button"
83+
<Button
84+
className="reset-current-data-button"
8985
onClick={clearAllSelections}
9086
>
9187
Clear
92-
</button>
88+
</Button>
9389
</div>
9490
);
9591
};

0 commit comments

Comments
 (0)