Skip to content

Commit 7fcb616

Browse files
authored
Merge pull request #197 from UW-Macrostrat/gbdb-example
Examples for GBDB integraton
2 parents 30c7e19 + acca997 commit 7fcb616

File tree

18 files changed

+1417
-38
lines changed

18 files changed

+1417
-38
lines changed

.storybook/preview-head.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<meta name="darkreader-lock" />
2+
<script>
3+
// Forward React DevTools hook to iframe contexts
4+
if (window.parent !== window) {
5+
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ =
6+
window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
7+
}
8+
</script>
29
<!--<style>-->
310
<!-- .sbdocs.sbdocs-wrapper {-->
411
<!-- background-color: var(&#45;&#45;background-color) !important;-->

packages/column-creator/stories/column-creator.stories.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import h from "@macrostrat/hyper";
22

33
import { BasicUnitComponent, Column } from "@macrostrat/column-views";
44
import { ColumnAxisType } from "@macrostrat/column-components";
5-
import { FlexRow } from "@macrostrat/ui-components";
65
import { ColumnCreator } from "../src";
76

87
export default {

packages/column-views/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.4.3] - 2026-01-06
8+
9+
- Fix error with unit notes for height-based columns
10+
711
## [2.4.2] - 2025-12-19
812

913
Update minimum versions of dependencies

packages/column-views/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/column-views",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Data views for Macrostrat stratigraphic columns",
55
"type": "module",
66
"source": "src/index.ts",

packages/column-views/src/correlation-chart/stories/correlation-chart.stories.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Meta } from "@storybook/react-vite";
22
import "@macrostrat/style-system";
3-
import { useArgs } from "storybook/preview-api";
4-
import { useCallback } from "react";
3+
import { useCorrelationLine } from "./utils";
54
import {
65
ColumnCorrelationMap,
76
ColumnCorrelationProvider,
@@ -18,7 +17,6 @@ import styles from "./stories.module.sass";
1817
import { CorrelationChart, CorrelationChartProps } from "../main";
1918
import { ErrorBoundary, useAsyncMemo } from "@macrostrat/ui-components";
2019
import { OverlaysProvider } from "@blueprintjs/core";
21-
import { parseLineFromString, stringifyLine } from "../hash-string";
2220
import { EnvironmentColoredUnitComponent } from "../../units";
2321
import { scaleLinear, scalePow } from "d3-scale";
2422

@@ -179,27 +177,6 @@ export default {
179177
},
180178
} as Meta<typeof CorrelationStoryUI>;
181179

182-
function useCorrelationLine() {
183-
const [{ focusedLine, selectedUnit }, updateArgs] = useArgs();
184-
const setFocusedLine = (line) => {
185-
updateArgs({ focusedLine: stringifyLine(line) });
186-
};
187-
188-
const setSelectedUnit = useCallback(
189-
(selectedUnit) => {
190-
updateArgs({ selectedUnit });
191-
},
192-
[updateArgs],
193-
);
194-
195-
return {
196-
focusedLine: parseLineFromString(focusedLine),
197-
setFocusedLine,
198-
selectedUnit,
199-
setSelectedUnit,
200-
};
201-
}
202-
203180
function Template(args) {
204181
return h(CorrelationStoryUI, {
205182
...args,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useArgs } from "storybook/preview-api";
2+
import { useCallback } from "react";
3+
import { parseLineFromString, stringifyLine } from "../hash-string";
4+
5+
export function useCorrelationLine() {
6+
const [{ focusedLine, selectedUnit }, updateArgs] = useArgs();
7+
const setFocusedLine = (line) => {
8+
updateArgs({ focusedLine: stringifyLine(line) });
9+
};
10+
11+
const setSelectedUnit = useCallback(
12+
(selectedUnit) => {
13+
updateArgs({ selectedUnit });
14+
},
15+
[updateArgs],
16+
);
17+
18+
return {
19+
focusedLine: parseLineFromString(focusedLine),
20+
setFocusedLine,
21+
selectedUnit,
22+
setSelectedUnit,
23+
};
24+
}

packages/column-views/src/maps/_shared/styles.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
33
import type { Style } from "mapbox-gl";
44

55
export function buildColumnsStyle(color: string): Style {
6-
const columnColor = color ?? getCSSVariable("--text-subtle-color", "black");
6+
let columnColor = color ?? getCSSVariable("--text-subtle-color", "black");
7+
const columnSelectedColor = getCSSVariable("--selection-color", "purple");
8+
9+
// If color is in the geojson properties, use that
10+
columnColor = ["coalesce", ["get", "color"], columnColor];
11+
712
return {
813
sources: {
914
columns: buildGeoJSONSource(),
@@ -42,7 +47,12 @@ export function buildColumnsStyle(color: string): Style {
4247
source: "columns",
4348
paint: {
4449
"circle-radius": 4,
45-
"circle-color": columnColor,
50+
"circle-color": [
51+
"case",
52+
["boolean", ["feature-state", "selected"], false],
53+
columnSelectedColor,
54+
columnColor,
55+
],
4656
"circle-opacity": [
4757
"case",
4858
["boolean", ["feature-state", "selected"], false],

packages/column-views/src/maps/column-navigation/mapbox/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ function ColumnsLayer({ enabled = true }) {
210210
const center = geoCentroid(columnGeometry);
211211

212212
const isInitialRender = initialRenderRef.current;
213+
213214
map.easeTo({ center }, { duration: isInitialRender ? 0 : 500 });
214215
if (isInitialRender) {
215216
initialRenderRef.current = false;

packages/column-views/src/prepare-units/composite-scale.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,15 @@ export function createCompositeScale(
307307
const scale: CompositeColumnScale = (age) => {
308308
for (const s of scales) {
309309
const domain = s.domain();
310-
if (age >= domain[0] && age <= domain[domain.length - 1]) {
310+
if (
311+
domain[0] < domain[domain.length - 1] &&
312+
age >= domain[0] &&
313+
age <= domain[domain.length - 1]
314+
) {
315+
// Age axes
316+
return s(age);
317+
} else if (age <= domain[0] && age >= domain[domain.length - 1]) {
318+
// Normal axes like height
311319
return s(age);
312320
}
313321
}

packages/column-views/src/prepare-units/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function preprocessUnits<T extends UnitLong = UnitLong>(
3838
while (columns.includes(col)) {
3939
col++;
4040
}
41-
d.column = col;
41+
d.column ??= col;
4242
}
4343

4444
// If unit overlaps the edges of a section, set the clip positions
@@ -102,7 +102,7 @@ function extendDivision(
102102
return {
103103
...unit,
104104
bottomOverlap,
105-
column,
105+
column: unit.column ?? column,
106106
overlappingUnits: overlappingUnits.map((d) => d.unit_id),
107107
};
108108
}

0 commit comments

Comments
 (0)