Skip to content

Commit 3207d16

Browse files
committed
Add new 'minimal' option to unconformityLabels
1 parent 42bfb81 commit 3207d16

File tree

10 files changed

+142
-113
lines changed

10 files changed

+142
-113
lines changed

packages/column-views/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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.2.2] - 2025-12-04
8+
9+
- Fix a bug with unit deselection
10+
- Fix a lack of updates in state management code
11+
712
## [2.2.1] - 2025-11-29
813

914
- Start unifying state management components

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.2.1",
3+
"version": "2.2.2",
44
"description": "Data views for Macrostrat stratigraphic columns",
55
"type": "module",
66
"source": "src/index.ts",

packages/column-views/src/column.module.sass

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,11 @@ body:global(.dark-mode) .column-container
137137
--unit-font-weight: 400
138138

139139
.unconformity-inner
140-
//border-left: 1.5px dotted var(--secondary-color)
141140
position: absolute
142-
top: 5px
143-
bottom: 5px
144-
left: -3px
145-
right: -2px
141+
top: 3px
142+
bottom: 3px
143+
left: 0
144+
right: 0
146145
display: flex
147146
justify-content: center
148147
align-items: center
@@ -155,6 +154,9 @@ body:global(.dark-mode) .column-container
155154
font-weight: 400
156155
color: var(--secondary-color)
157156

157+
.timescale-column .unconformity-inner
158+
border-left: 1.5px dotted var(--secondary-color)
159+
left: -3px // align with age axis
158160

159161

160162
.column-title-row

packages/column-views/src/column.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ interface BaseColumnProps extends SectionSharedProps {
6161
// Timescale properties
6262
showTimescale?: boolean;
6363
timescaleLevels?: number | [number, number];
64+
unconformityLabels?: boolean | UnconformityLabelPlacement;
6465
onMouseOver?: (
6566
unit: UnitLong | null,
6667
height: number | null,
6768
evt: MouseEvent,
6869
) => void;
6970
}
7071

72+
export type UnconformityLabelPlacement = "minimal" | "prominent" | "none";
73+
7174
export interface ColumnProps
7275
extends Padding,
7376
BaseColumnProps,
@@ -224,7 +227,7 @@ function ColumnInner(props: ColumnInnerProps) {
224227

225228
const {
226229
unitComponent = UnitComponent,
227-
unconformityLabels = true,
230+
unconformityLabels = "minimal",
228231
showLabels = true,
229232
width: _width = 300,
230233
columnWidth: _columnWidth = 150,
@@ -242,6 +245,15 @@ function ColumnInner(props: ColumnInnerProps) {
242245

243246
const { axisType } = useMacrostratColumnData();
244247

248+
// Coalesce unconformity label setting to a boolean
249+
let _timescaleUnconformityLabels = false;
250+
let _sectionUnconformityLabels = false;
251+
if (unconformityLabels === true || unconformityLabels === "prominent") {
252+
_sectionUnconformityLabels = true;
253+
} else if (unconformityLabels === "minimal") {
254+
_timescaleUnconformityLabels = true;
255+
}
256+
245257
let width = _width;
246258
let columnWidth = _columnWidth;
247259
if (columnWidth > width) {
@@ -267,15 +279,18 @@ function ColumnInner(props: ColumnInnerProps) {
267279
},
268280
h("div.column", { ref: columnRef }, [
269281
h(ageAxisComponent),
270-
h.if(_showTimescale)(CompositeTimescale, { levels: timescaleLevels }),
282+
h.if(_showTimescale)(CompositeTimescale, {
283+
levels: timescaleLevels,
284+
unconformityLabels: _timescaleUnconformityLabels,
285+
}),
271286
h(SectionsColumn, {
272287
unitComponent,
273288
showLabels,
274289
width,
275290
columnWidth,
276291
showLabelColumn,
277292
clipUnits,
278-
unconformityLabels,
293+
unconformityLabels: _sectionUnconformityLabels,
279294
maxInternalColumns,
280295
}),
281296
children,

packages/column-views/src/section.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function SectionUnits(props: SectionProps) {
199199

200200
interface CompositeTimescaleProps {
201201
levels?: [number, number] | number;
202+
unconformityLabels?: boolean;
202203
}
203204

204205
export function CompositeTimescale(props: CompositeTimescaleProps) {
@@ -215,7 +216,6 @@ export function CompositeTimescale(props: CompositeTimescaleProps) {
215216

216217
type CompositeTimescaleCoreProps = CompositeTimescaleProps & {
217218
packages: PackageScaleLayoutData[];
218-
unconformityLabels?: boolean;
219219
};
220220

221221
export function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {
@@ -316,6 +316,8 @@ function Unconformity({
316316

317317
const ageGap = Math.abs(upperAge - lowerAge);
318318

319+
let maximumFractionDigits = 0;
320+
319321
let className: string = null;
320322
if (ageGap > 1000) {
321323
className = "giga";
@@ -325,14 +327,17 @@ function Unconformity({
325327
className = "large";
326328
} else if (ageGap < 1) {
327329
className = "small";
330+
maximumFractionDigits = 2;
331+
} else {
332+
maximumFractionDigits = 1;
328333
}
329334

330335
let val: ReactNode;
331336
if (axisType === ColumnAxisType.DEPTH || axisType === ColumnAxisType.HEIGHT) {
332-
const _txt = ageGap.toLocaleString("en-US", { maximumFractionDigits: 2 });
337+
const _txt = ageGap.toLocaleString("en-US", { maximumFractionDigits });
333338
val = h(Value, { value: _txt, unit: "m" });
334339
} else {
335-
val = h(Duration, { value: ageGap });
340+
val = h(Duration, { value: ageGap, maximumFractionDigits });
336341
}
337342

338343
let prefix: ReactNode = null;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
export const sharedColumnArgTypes = {
2+
columnID: {
3+
control: {
4+
type: "number",
5+
},
6+
},
7+
selectedUnit: {
8+
control: {
9+
type: "number",
10+
},
11+
},
12+
t_age: {
13+
control: {
14+
type: "number",
15+
},
16+
},
17+
b_age: {
18+
control: {
19+
type: "number",
20+
},
21+
},
22+
unconformityLabels: {
23+
options: ["minimal", "prominent", "none"],
24+
control: { type: "radio" },
25+
},
26+
axisType: {
27+
options: ["age", "ordinal", "depth"],
28+
control: { type: "radio" },
29+
},
30+
mergeSections: {
31+
options: ["all", "overlapping", null],
32+
control: { type: "radio" },
33+
},
34+
pixelScale: {
35+
control: {
36+
type: "number",
37+
},
38+
},
39+
collapseSmallUnconformities: {
40+
control: {
41+
type: "boolean",
42+
},
43+
},
44+
minSectionHeight: {
45+
control: {
46+
type: "number",
47+
},
48+
},
49+
targetUnitHeight: {
50+
control: {
51+
type: "number",
52+
},
53+
},
54+
showLabelColumn: {
55+
control: {
56+
type: "boolean",
57+
},
58+
},
59+
maxInternalColumns: {
60+
control: {
61+
type: "number",
62+
},
63+
},
64+
};

packages/column-views/stories/column-navigation.stories.ts

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,7 @@ import {
99
EnvironmentColoredUnitComponent,
1010
} from "../src";
1111
import { useColumnSelection } from "./column-ui/utils";
12-
13-
const baseArgTypes = {
14-
columnID: {
15-
control: {
16-
type: "number",
17-
},
18-
},
19-
selectedUnit: {
20-
control: {
21-
type: "number",
22-
},
23-
},
24-
t_age: {
25-
control: {
26-
type: "number",
27-
},
28-
},
29-
b_age: {
30-
control: {
31-
type: "number",
32-
},
33-
},
34-
};
12+
import { sharedColumnArgTypes } from "./arg-types";
3513

3614
export default {
3715
title: "Column views/Column navigation",
@@ -43,45 +21,7 @@ export default {
4321
targetUnitHeight: 20,
4422
},
4523
argTypes: {
46-
...baseArgTypes,
47-
axisType: {
48-
options: ["age", "ordinal", "depth"],
49-
control: { type: "radio" },
50-
},
51-
mergeSections: {
52-
options: ["all", "overlapping", null],
53-
control: { type: "radio" },
54-
},
55-
pixelScale: {
56-
control: {
57-
type: "number",
58-
},
59-
},
60-
collapseSmallUnconformities: {
61-
control: {
62-
type: "boolean",
63-
},
64-
},
65-
minSectionHeight: {
66-
control: {
67-
type: "number",
68-
},
69-
},
70-
targetUnitHeight: {
71-
control: {
72-
type: "number",
73-
},
74-
},
75-
showLabelColumn: {
76-
control: {
77-
type: "boolean",
78-
},
79-
},
80-
maxInternalColumns: {
81-
control: {
82-
type: "number",
83-
},
84-
},
24+
...sharedColumnArgTypes,
8525
},
8626
} as Meta<typeof ColumnStoryUI>;
8727

@@ -115,7 +55,6 @@ Minimal.args = {
11555
export const eODP = Template.bind({});
11656
eODP.args = {
11757
columnID: 5576,
118-
inProcess: true,
11958
axisType: "depth",
12059
projectID: 3,
12160
pixelScale: undefined,

packages/column-views/stories/column-page.stories.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ import {
88
UnitDetailsPanelWithNavigation,
99
ReferencesField,
1010
UnitDetailsFeature,
11-
Identifier,
1211
ColumnBasicInfo,
1312
} from "../src";
1413
import { useColumnBasicInfo, useColumnUnits } from "./column-ui/utils";
1514
import styles from "./column-page.stories.module.sass";
1615
import { UnitLong } from "@macrostrat/api-types";
1716
import { useArgs } from "storybook/preview-api";
18-
import { DataField } from "@macrostrat/data-components";
19-
import { FlexRow } from "@macrostrat/ui-components";
17+
import { sharedColumnArgTypes } from "./arg-types";
2018

2119
export default {
2220
title: "Column views/Column page",
2321
component: ColumnStoryUI,
2422
args: {
2523
columnID: 494,
2624
selectedUnitID: 15160,
25+
unconformityLabels: "minimal",
26+
},
27+
argTypes: {
28+
...sharedColumnArgTypes,
2729
},
2830
} as Meta<typeof ColumnStoryUI>;
2931

@@ -62,7 +64,6 @@ function ColumnStoryUI({
6264
units,
6365
selectedUnit: selectedUnitID,
6466
onUnitSelected: setSelectedUnitID,
65-
unconformityLabels: true,
6667
keyboardNavigation: true,
6768
columnWidth: 300,
6869
showUnitPopover: false,

0 commit comments

Comments
 (0)