Skip to content

Commit cb1f2f6

Browse files
authored
Refactor dashboards (#1288)
1 parent c9bfe21 commit cb1f2f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+13415
-796
lines changed

jest.config.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
module.exports = {
2-
projects: [
3-
{
4-
displayName: "mapseed-platform-test",
5-
testURL: "http://localhost/",
6-
moduleNameMapper: {
7-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
8-
"<rootDir>/__mocks__/file-mock.js",
9-
"\\.(css|less|scss)$": "<rootDir>/__mocks__/style-mock.js",
10-
"^config$": "<rootDir>/__mocks__/config-mock.js",
11-
},
12-
setupFiles: ["<rootDir>/jest-setup.js"],
13-
snapshotSerializers: ["enzyme-to-json/serializer"],
14-
testMatch: ["**/*.test.js"],
15-
},
16-
],
2+
displayName: "mapseed-platform-test",
3+
testURL: "http://localhost/",
4+
moduleNameMapper: {
5+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
6+
"<rootDir>/__mocks__/file-mock.js",
7+
"\\.(css|less|scss)$": "<rootDir>/__mocks__/style-mock.js",
8+
"^config$": "<rootDir>/__mocks__/config-mock.js",
9+
},
10+
setupFiles: ["<rootDir>/jest-setup.js"],
11+
snapshotSerializers: ["enzyme-to-json/serializer"],
12+
testMatch: ["**/*.test.js"],
1713
};

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"build-deploy": "npm run build && npm run deploy",
2929
"type-check": "tsc --noEmit",
3030
"type-check:watch": "npm run type-check -- --watch",
31-
"test": "npm run eslint && npm run prettier && npm run type-check",
31+
"test": "npm run eslint && ./node_modules/.bin/jest && npm run prettier && npm run type-check",
3232
"eslint": "eslint src scripts --ext .js,.ts,.tsx",
3333
"eslint:fix": "eslint --fix src scripts --ext .js,.ts,.tsx",
3434
"test:watch": "jest --watch --verbose --config ./jest.watch.config.js",
@@ -56,6 +56,7 @@
5656
"@turf/helpers": "^6.1.4",
5757
"@types/d3-geo": "^1.11.1",
5858
"@types/geojson": "^7946.0.7",
59+
"@types/moment-timezone": "^0.5.12",
5960
"@types/mapbox-gl": "^0.51.11",
6061
"@types/prop-types": "^15.7.1",
6162
"@types/react": "^16.8.13",
@@ -93,6 +94,7 @@
9394
"react": "^16.8.6",
9495
"react-datetime": "~2.14.0",
9596
"react-dom": "~16.8.6",
97+
"react-draggable": "^3.3.0",
9698
"react-i18next": "~7.5.1",
9799
"react-jss": "^8.6.1",
98100
"react-map-gl": "^5.0.7",

src/base/static/components/app.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,13 @@ class App extends React.Component<Props, State> {
530530
<Route
531531
exact
532532
path="/dashboard"
533-
render={() => {
533+
render={props => {
534534
return (
535535
<React.Suspense fallback={<Fallback />}>
536536
<SiteHeader {...headerProps} />
537537
<DashboardTemplate
538-
datasetDownloadConfig={
539-
this.props.appConfig.dataset_download
540-
}
541538
apiRoot={this.props.appConfig.api_root}
539+
{...props.match}
542540
/>
543541
</React.Suspense>
544542
);

src/base/static/components/atoms/buttons.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import { TwitterIcon, FacebookIcon } from "./icons";
1010
import { FontAwesomeIcon } from "./imagery";
1111
import { SmallText } from "./typography";
1212

13-
import { CHARCOAL, OFF_WHITE, getReadableColor } from "../../utils/color";
13+
import {
14+
CHARCOAL,
15+
OFF_WHITE,
16+
getReadableColor,
17+
lighten,
18+
} from "../../utils/color";
1419
import { LegacyIcon } from "./feedback";
1520

1621
import "./buttons.scss";
@@ -197,6 +202,15 @@ const Button = styled(props => {
197202
styles.border = "3px solid rgba(0, 0, 0, 0.05)";
198203
} else if (props.variant === "outlined") {
199204
styles.border = `3px solid ${props.theme.brand.primary}`;
205+
} else if (props.variant === "badge") {
206+
styles.backgroundColor = props.color;
207+
styles.height = "32px";
208+
styles.display = "flex";
209+
styles.alignItems = "center";
210+
styles.paddingLeft = "16px";
211+
styles.paddingRight = "16px";
212+
styles.borderRadius = "16px";
213+
styles["&:hover"].backgroundColor = lighten(props.color, 10);
200214
}
201215

202216
if (props.color === "primary") {

src/base/static/components/atoms/imagery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const FontAwesomeIcon = styled(props => (
2121
fontFamily: "Font Awesome 5 Free",
2222
fontSize: props.fontSize,
2323
color: props.color,
24+
textShadow: props.textShadow,
2425

2526
"&:hover": {
2627
color: props.hoverColor,
@@ -42,6 +43,7 @@ FontAwesomeIcon.defaultProps = {
4243
content: "fa fa-globe",
4344
color: "#000",
4445
hoverColor: "#555",
46+
textShadow: "initial",
4547
};
4648

4749
const SiteLogo = styled(props => {

src/base/static/components/atoms/input.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ CheckboxInput.propTypes = {
120120
onChange: PropTypes.func.isRequired,
121121
};
122122

123+
const RadioInput = props => {
124+
return (
125+
<input
126+
type="radio"
127+
id={props.id}
128+
name={props.name}
129+
value={props.value}
130+
onChange={props.onChange}
131+
checked={props.checked}
132+
/>
133+
);
134+
};
135+
136+
RadioInput.propTypes = {
137+
checked: PropTypes.bool.isRequired,
138+
id: PropTypes.string,
139+
name: PropTypes.string,
140+
onChange: PropTypes.func.isRequired,
141+
value: PropTypes.string.isRequired,
142+
};
143+
123144
const NumberInput = props => {
124145
return (
125146
<input
@@ -194,6 +215,7 @@ RangeInput.propTypes = {
194215

195216
export {
196217
CheckboxInput,
218+
RadioInput,
197219
DatetimeInput,
198220
NumberInput,
199221
TextInput,

src/base/static/components/atoms/layout.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import PropTypes from "prop-types";
22
import styled from "@emotion/styled";
33
import { RegularTitle } from "./typography";
44

5+
const Badge = styled("span")(props => ({
6+
display: "flex",
7+
alignItems: "center",
8+
backgroundColor: props.color,
9+
borderRadius: "16px",
10+
padding: "0 12px 0 12px",
11+
height: "32px",
12+
boxSizing: "border-box",
13+
14+
"&:hover": {
15+
backgroundColor: props.hoverColor,
16+
},
17+
}));
18+
519
const HorizontalRule = styled("hr")(props => {
620
const styles = {
721
marginTop: "12px",
@@ -93,6 +107,7 @@ const modalStyles = {
93107
};
94108

95109
export {
110+
Badge,
96111
HorizontalRule,
97112
ModalWrapper,
98113
ModalHeading,

src/base/static/components/atoms/typography.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import classNames from "classnames";
44
import styled from "@emotion/styled";
55
import moment from "moment";
66
import { Link } from "react-router-dom";
7+
import { darken } from "@material-ui/core/styles/colorManipulator";
78

89
import "./typography.scss";
910

@@ -211,6 +212,28 @@ const MicroText = styled("span")(props => {
211212
return textHandler(props, styles);
212213
});
213214

215+
const DashboardText = styled("p")(props => ({
216+
margin: 0,
217+
padding: 0,
218+
textAlign: props.textAlign,
219+
fontFamily: props.weight === "bold" ? "PTSansBold" : "PTSans",
220+
fontSize: props.fontSize,
221+
color: props.color,
222+
textTransform: props.textTransform,
223+
marginTop: "4px",
224+
marginBottom: "4px",
225+
textOverflow: "ellipsis",
226+
overflow: "hidden",
227+
}));
228+
229+
DashboardText.defaultProps = {
230+
color: "#222",
231+
textAlign: "center",
232+
weight: "regular",
233+
textTransform: "none",
234+
fontSize: "1rem",
235+
};
236+
214237
const ExternalLink = styled("a")({
215238
textDecoration: "none",
216239
wordBreak: "break-all",
@@ -249,6 +272,22 @@ Time.propTypes = {
249272
time: PropTypes.string.isRequired,
250273
};
251274

275+
// TODO: Dynamic badge border radius and padding to match content.
276+
const Badge = styled("span")(props => ({
277+
backgroundColor: props.color,
278+
color: darken(props.color, 0.8),
279+
padding: "2px 12px 2px 12px",
280+
borderRadius: "14px",
281+
}));
282+
283+
Badge.defaultProps = {
284+
color: "#bbb",
285+
};
286+
287+
Badge.propTypes = {
288+
color: PropTypes.string.isRequired,
289+
};
290+
252291
export {
253292
ExternalLink,
254293
InternalLink,
@@ -271,5 +310,7 @@ export {
271310
RegularText,
272311
SmallText,
273312
MicroText,
313+
DashboardText,
274314
Time,
315+
Badge,
275316
};

0 commit comments

Comments
 (0)