Skip to content

Commit 297a1ea

Browse files
authored
Merge pull request #42 from UW-Macrostrat/modules
Modules
2 parents 18c6727 + 012b5bb commit 297a1ea

File tree

17 files changed

+643
-585
lines changed

17 files changed

+643
-585
lines changed

pages/+Page.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Image, Footer } from "./index";
22
import styles from "./main.module.sass";
3-
import "./main-page.styl";
3+
import "./main-page.sass";
44
import "@macrostrat/style-system";
55
import hyper from "@macrostrat/hyper";
66
import "@macrostrat/style-system";

pages/checkin/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function Checkins({checkinID}) {
6363

6464
observations.push(
6565
h('div', {className: 'observation'}, [
66-
headerImgUrl ? h(BlankImage, { className: 'observation-img', src: headerImgUrl, onClick: () => {
66+
headerImgUrl ? h(BlankImage, { className: 'observation-image', src: headerImgUrl, onClick: () => {
6767
setOverlayBody(h('div.observation-body',headerBody));
6868
setOverlayImage(headerImgUrl);
6969
setOverlayOpen(!overlayOpen);
@@ -84,7 +84,7 @@ export function Checkins({checkinID}) {
8484

8585
observations.push(
8686
h('div', {className: 'observation'}, [
87-
observationURL ? h(BlankImage, { className: 'observation-img', src: observationURL, onClick: () => {
87+
observationURL ? h(BlankImage, { className: 'observation-image', src: observationURL, onClick: () => {
8888
setOverlayImage(imageSrc);
8989
setOverlayBody(observationBody);
9090
setOverlayOpen(!overlayOpen);
@@ -114,7 +114,7 @@ export function Checkins({checkinID}) {
114114
}),
115115
]),
116116
h('div.overlay-body', [
117-
h(BlankImage, { className: 'observation-img', src: overlayImage }),
117+
h(BlankImage, { className: 'observation-image', src: overlayImage }),
118118
overlayBody,
119119
])
120120
]);

pages/checkin/main.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ h4
142142
border-radius: 2%
143143
box-shadow: 0 0 0 1px var(--card-shadow-color)
144144

145-
.observation-img
145+
.observation-image
146146
width: 100%
147147
border-radius: 2% 2% 0 0
148148
cursor: pointer

pages/explore/+Page.client.ts

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "@macrostrat/style-system";
2222
import { LngLatCoords } from "@macrostrat/map-interface";
2323
import { set } from "react-datepicker/dist/date_utils";
2424
import { configDefinitionsBuiltInGlobal } from "vike/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn";
25+
import chroma from "chroma-js";
2526

2627
const h = hyper.styled(styles);
2728

@@ -58,6 +59,33 @@ function weaverStyle(type: object) {
5859

5960
const clusterThreshold = 1;
6061

62+
const baseColor = "#868aa2";
63+
const endColor = "#212435";
64+
const scale = chroma.scale([baseColor, endColor]).mode("hsl");
65+
66+
const _circleColor = (step) => {
67+
return scale(step / _steps.length);
68+
};
69+
70+
const circleColor = (step) => _circleColor(step).hex();
71+
const _steps = [1, 20, 100, 200, 500];
72+
73+
function steps(fn: (step: number) => any) {
74+
let res: any[] = ["step", ["coalesce", ["get", "point_count"], 0]];
75+
76+
let ix = 0;
77+
for (const step of _steps) {
78+
res.push(fn(ix), step);
79+
ix++;
80+
}
81+
res.push(fn(ix));
82+
return res;
83+
}
84+
85+
const textColor = (step) => {
86+
return chroma(baseColor).brighten(2).hex();
87+
};
88+
6189
return {
6290
sources: {
6391
weaver: {
@@ -73,27 +101,14 @@ function weaverStyle(type: object) {
73101
"source-layer": "default",
74102
filter: ['>', ['get', 'n'], clusterThreshold],
75103
paint: {
76-
"circle-radius": [
77-
"step",
78-
["get", "n"],
79-
15,
80-
100,
81-
20,
82-
750,
83-
30
84-
],
85-
'circle-color': [
86-
'step',
87-
['get', 'n'],
88-
colors.a,
89-
100,
90-
colors.b,
91-
750,
92-
colors.c
93-
],
94-
"circle-opacity": .8,
95-
"circle-stroke-width": 0.5,
96-
"circle-stroke-color": "#000",
104+
"circle-radius": steps((step) => 8 + step * 2),
105+
"circle-color": steps(circleColor),
106+
"circle-stroke-width": 3,
107+
"circle-stroke-color": steps((step) => {
108+
const c = _circleColor(step);
109+
return c.brighten(0.5).hex();
110+
}),
111+
"circle-stroke-opacity": 1,
97112
},
98113
},
99114
{
@@ -104,8 +119,11 @@ function weaverStyle(type: object) {
104119
filter: ['has', 'n'],
105120
layout: {
106121
'text-field': ['get', 'n'],
107-
'text-size': 12
108-
}
122+
'text-size': 10
123+
},
124+
paint: {
125+
"text-color": "#000"
126+
},
109127
},
110128
{
111129
id: 'unclustered-point',
@@ -114,7 +132,7 @@ function weaverStyle(type: object) {
114132
"source-layer": "default",
115133
filter: ['<=', ['get', 'n'], clusterThreshold],
116134
paint: {
117-
'circle-color': colors.a,
135+
'circle-color': baseColor,
118136
'circle-radius': 4,
119137
'circle-stroke-width': 1,
120138
'circle-stroke-color': '#fff'

pages/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useAPIResult } from "@macrostrat/ui-components";
44
import { Icon } from "@blueprintjs/core";
55
import mapboxgl from "mapbox-gl";
66
import styles from "./main.module.sass";
7+
import { useNavigate } from 'react-router-dom';
78

89
const h = hyper.styled(styles);
910

@@ -18,18 +19,17 @@ export function BlankImage({ src, className, width, height, onClick, onError, al
1819
}
1920

2021
const handleClick = (e) => {
21-
e.preventDefault();
2222
// Custom logic to navigate or do something without style transfer
2323
};
2424

2525
export function Footer() {
2626
return h("div", {className: "footer"}, [
2727
h("div", {className: "titles"}, [
28-
h("h3", {className: "footer-text a"}, [
28+
h("h3", {className: "footer-text upper"}, [
2929
"Produced by the ",
3030
h("a", {href: "https://macrostrat.org"} , "UW Macrostrat Lab")
3131
]),
32-
h("h3", {className: "footer-text b"}, [
32+
h("h3", {className: "footer-text lower"}, [
3333
"Funded by ",
3434
h("a", {href: "https://nsf.gov"}, "NSF"),
3535
" and ",

0 commit comments

Comments
 (0)