Skip to content

Commit c600054

Browse files
authored
Merge pull request #46 from UW-Macrostrat/touchup
Styling Updates
2 parents 08e5e99 + 9c8ab37 commit c600054

File tree

18 files changed

+1592
-208
lines changed

18 files changed

+1592
-208
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@macrostrat-web/utility-functions": "workspace:*",
5555
"@macrostrat/color-utils": "^1.0.0",
5656
"@macrostrat/corelle": "^2.0.1",
57+
"@macrostrat/data-components": "latest",
5758
"@macrostrat/form-components": "^0.1.2",
5859
"@macrostrat/hyper": "^3.0.6",
5960
"@macrostrat/map-interface": "^1.2.2",

pages/checkin/index.ts

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { MapAreaContainer, MapView, MapMarker } from "@macrostrat/map-interface"
1313
import 'mapbox-gl/dist/mapbox-gl.css';
1414
import { MapPosition } from "@macrostrat/mapbox-utils";
1515
import { PanelCard } from "@macrostrat/map-interface";
16+
import { LithologyList } from "@macrostrat/data-components";
1617

1718
const h = hyper.styled(styles);
1819

@@ -63,19 +64,15 @@ export function Checkins({checkinID}) {
6364

6465
observations.push(
6566
h('div', {className: 'observation'}, [
66-
headerImgUrl ? h(BlankImage, { className: 'observation-image', src: headerImgUrl, onClick: () => {
67-
setOverlayBody(h('div.observation-body',headerBody));
68-
setOverlayImage(headerImgUrl);
69-
setOverlayOpen(!overlayOpen);
70-
}
71-
}) : null,
67+
headerImgUrl ? h('a', {href: "/photo/" + checkin.photo},
68+
h(BlankImage, { className: 'observation-image', src: headerImgUrl})
69+
) : null,
7270
h("div.observation-body", headerBody),
7371
])
7472
);
7573

7674
// add observations
7775
checkin.observations.forEach(observation => {
78-
console.log("obs", observation.photo, observation);
7976
if(Object.keys(observation.rocks).length != 0) {
8077
// if photo exists
8178
const imageSrc = apiURL + "protected/image/" + checkin.person_id + "/thumb_large/" + observation.photo;
@@ -84,11 +81,9 @@ export function Checkins({checkinID}) {
8481

8582
observations.push(
8683
h('div', {className: 'observation'}, [
87-
observationURL ? h(BlankImage, { className: 'observation-image', src: observationURL, onClick: () => {
88-
setOverlayImage(imageSrc);
89-
setOverlayBody(observationBody);
90-
setOverlayOpen(!overlayOpen);
91-
}}) : null,
84+
observationURL ? h('a', {href: "/photo/" + observation.photo},
85+
h(BlankImage, { className: 'observation-image', src: observationURL})
86+
) : null,
9287
observationBody,
9388
])
9489
);
@@ -125,7 +120,6 @@ export function Checkins({checkinID}) {
125120
h('div', { className: showMap ? 'hide' : 'main'}, [
126121
h('div', { className: "checkin-head" }, [
127122
h('h1', checkin.notes),
128-
h(DarkModeButton, { className: 'dark-mode-button', showText: true }),
129123
]),
130124
h(BlankImage, { className: "location-img", src: "https://api.mapbox.com/styles/v1/jczaplewski/cje04mr9l3mo82spihpralr4i/static/geojson(%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B" + checkin.lng + "%2C" + checkin.lat + "%5D%7D)/" + checkin.lng + "," + checkin.lat + ",5,0/1200x400?access_token=" + SETTINGS.mapboxAccessToken }),
131125
h('div', { className: 'stop-header', onClick: () => { setShowMap(true); console.log("center", center) } }, [
@@ -168,22 +162,75 @@ function observationFooter(observation) {
168162
let liths = [];
169163
for(var j = 0; j < rocks.liths.length; j++) {
170164
liths.push(h('p', { className: "observation-detail liths"}, rocks.liths[j].name));
165+
}
166+
167+
function rgbaStringToHex(rgba: string): string {
168+
// Split the input string by commas and trim whitespace
169+
const values = rgba.split(',').map(value => value.trim());
170+
171+
// Extract r, g, b values and ignore alpha
172+
const r = parseInt(values[0], 10);
173+
const g = parseInt(values[1], 10);
174+
const b = parseInt(values[2], 10);
175+
176+
// Convert r, g, b to two-digit hex values
177+
const red = r.toString(16).padStart(2, '0');
178+
const green = g.toString(16).padStart(2, '0');
179+
const blue = b.toString(16).padStart(2, '0');
180+
181+
// Return the HEX string without alpha
182+
return `#${red}${green}${blue}`;
171183
}
172184

173-
// observation body
174185
let obsAge = observation.age_est ? observation.age_est.name + " (" + observation.age_est.b_age + " - " + observation?.age_est?.t_age + ")" : null;
186+
187+
let lithologies = [];
188+
rocks.liths.forEach(lith => {
189+
if(!lith.color.includes("#")) {
190+
lithologies.push({
191+
name: lith.name,
192+
color: rgbaStringToHex(lith.color)});
193+
} else {
194+
lithologies.push(lith);
195+
}
196+
});
197+
198+
if (rocks.strat_name?.strat_name_long) {
199+
lithologies.push({
200+
name: rocks.strat_name?.strat_name_long,
201+
})
202+
}
203+
204+
if(rocks.map_unit?.unit_name) {
205+
lithologies.push({
206+
name: rocks.map_unit?.unit_name
207+
})
208+
}
209+
210+
if(obsAge) {
211+
lithologies.push({
212+
name: obsAge
213+
})
214+
}
215+
if(rocks.interval.name) {
216+
lithologies.push({
217+
name: rocks.interval.name
218+
})
219+
}
220+
if(observation.orientation.feature?.name) {
221+
lithologies.push({
222+
name: observation.orientation.feature?.name
223+
})
224+
}
225+
226+
// observation body
175227
return h('div', {className: 'observation-body'}, [
176228
observation.lat && rocks.strat_name?.strat_name_long ? h('h4', {className: 'observation-header'}, [
177229
rocks.strat_name?.strat_name_long,
178230
observation.lat ? LngLatCoords(LngLatProps) : null,
179231
]) : null,
180232
h('div', {className: 'observation-details'}, [
181-
rocks.strat_name?.strat_name_long ? h('p', {className: 'observation-detail'}, rocks.strat_name?.strat_name_long) : null,
182-
rocks.map_unit?.unit_name ? h('p', {className: 'observation-detail'}, rocks.map_unit?.unit_name) : null,
183-
obsAge ? h('p', {className: 'observation-detail'}, obsAge) : null,
184-
rocks.interval.name ? h('p', {className: 'observation-detail interval'}, rocks.interval.name) : null,
185-
liths,
186-
observation.orientation.feature?.name ? h('p', {className: 'observation-detail'}, observation.orientation.feature?.name) : null,
233+
h(LithologyList, { lithologies }),
187234
h('p', {className: "notes"}, rocks.notes),
188235
]),
189236
]);
@@ -221,7 +268,6 @@ function Map({center, showMap, setShowMap}) {
221268
setShowMap(!showMap);
222269
}}),
223270
h(PanelCard, {className: "banner-button", onClick: () => {
224-
console.log("clicked");
225271
setStyle(style == whiteStyle ? sateliteStyle : whiteStyle);
226272
setStyleText(styleText == whiteText ? sateliteText : whiteText);
227273
}}, styleText),

pages/checkin/main.sass

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,13 @@ h1, p
105105
.marker
106106
height: 15px
107107

108-
.edited
109-
color: grey
110-
111108
h4
112109
padding: 0
113110
margin: 0
114111

115112
.checkin-head
116113
padding: 30px 0
117114
width: 100%
118-
display: grid
119-
grid-template-columns: 80% 20%
120-
121-
h1
122-
padding-right: 15px
123115

124116
.loading
125117
height: 75vh
@@ -139,12 +131,10 @@ h4
139131
flex: 0 0 calc(33.33% - 10px)
140132
margin: 5px
141133
text-align: center
142-
border-radius: 2%
143134
box-shadow: 0 0 0 1px var(--card-shadow-color)
144135

145136
.observation-image
146137
width: 100%
147-
border-radius: 2% 2% 0 0
148138
cursor: pointer
149139

150140
.overlay
@@ -159,13 +149,11 @@ h4
159149
.overlay-body
160150
margin: 0 30%
161151
width: 40%
162-
border-radius: 2%
163152
box-shadow: 0 0 0 1px var(--card-shadow-color)
164153
margin: 5vh 30%
165154

166155
img
167156
width: 100%
168-
border-radius: 2% 2% 0 0
169157

170158
.observation-body
171159
padding: 3px
@@ -210,9 +198,6 @@ h4
210198
position: absolute
211199
right: 15px
212200

213-
.map-container
214-
height: 95vh
215-
216201
.hide
217202
display: none
218203

pages/colors.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ $colors: (
1616
translucent-background: rgba(255, 255, 255, 0.5),
1717
interval-background: rgba(176, 81, 165, .5),
1818
liths-background: rgba(255, 213, 0, 0.5),
19+
button-background: #fff,
1920
);
2021

2122
$dark-background: #141a1e;
@@ -37,4 +38,5 @@ $dark-colors: (
3738
translucent-background: rgba(20, 26,30, 0.5),
3839
interval-background: rgba(79, 174, 90, .5),
3940
liths-background: rgba(0, 42, 255, 0.5),
41+
button-background: #1c2127,
4042
);

0 commit comments

Comments
 (0)