Skip to content

Commit 783a70a

Browse files
authored
Merge pull request #190 from UW-Macrostrat/column-updates
Column updates
2 parents 46f51a1 + 6da4863 commit 783a70a

Some content is hidden

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

42 files changed

+1134
-821
lines changed

packages/column-components/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ 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+
## [1.4.0] - 2025-12-10
8+
9+
- Major update to `Note` and note-related components
10+
- Add a `FocusableNoteColumn` mode based on the `EditableNoteColumn` component
11+
- Removed outdated note-related styles and simplified CSS scopes
12+
713
## [1.3.1] - 2025-11-28
814

915
- Update axis components

packages/column-components/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-components",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "React rendering primitives for stratigraphic columns",
55
"keywords": [
66
"geology",

packages/column-components/src/axis.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,21 @@ export function AgeAxis(props: AgeAxisProps) {
5757

5858
let tickValues: number[] = undefined;
5959

60-
let ticks = Math.max(Math.round(pixelHeight / tickSpacing), 2);
61-
if (pixelHeight < 3 * tickSpacing || scale.ticks(2).length < 2) {
62-
// Push ticks towards extrema
63-
const t0 = scale.ticks(4);
60+
let ticks = Math.round(pixelHeight / tickSpacing);
61+
if (pixelHeight < 3 * tickSpacing) {
62+
// Push ticks towards extrema (we need more than 2 to be resolved)
63+
64+
let t0: number[] = [];
65+
while (t0.length <= 2) {
66+
ticks += 1;
67+
t0 = scale.ticks(ticks);
68+
}
6469

65-
tickValues = [t0[0], t0[t0.length - 1]];
70+
tickValues = t0;
71+
if (pixelHeight < 2 * tickSpacing) {
72+
// Only show first and last ticks
73+
tickValues = [t0[0], t0[t0.length - 1]];
74+
}
6675
}
6776

6877
if (pixelHeight < minTickSpacing) {
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { hyperStyled } from "@macrostrat/hyper";
22
import styles from "./main.module.scss";
3+
import noteStyles from "./notes/notes.module.sass";
34

4-
const h = hyperStyled(styles);
5+
const styles1 = { ...styles, ...noteStyles };
6+
7+
const h = hyperStyled(styles1);
8+
9+
console.log("Styles", styles1);
510

611
export default h;

packages/column-components/src/main.module.scss

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
.column-notes .col-note-label {
2-
cursor: pointer;
3-
}
4-
.column-notes .note-editor.bp5-editable-text {
5-
user-select: none;
6-
}
7-
.column-notes .note-editor.bp5-editable-text:before {
8-
top: 0;
9-
left: 0;
10-
right: 0;
11-
bottom: 0;
12-
}
13-
.position-editor .handle {
14-
background-color: #d2e9ff;
15-
border: 1px solid #1e90ff;
16-
}
17-
.position-editor .add-span-handle {
18-
background-color: #e9f4ff;
19-
border: 1px dotted #1e90ff;
20-
}
21-
.position-editor .top-handle,
22-
.position-editor .bottom-handle,
23-
.position-editor .add-span-handle {
24-
border-radius: 3px;
25-
}
26-
.note-editor .note-connector {
27-
stroke: #1e90ff;
28-
stroke-width: 3;
29-
}
30-
.col-note-label {
31-
padding-left: 0.3em;
32-
border-left: 1px solid var(--note-color);
33-
margin: 1px 0;
34-
font-style: italic;
35-
z-index: 15;
36-
}
37-
g.height-range line {
38-
stroke: var(--note-color);
39-
stroke-width: 1.2px;
40-
}
41-
421
.column-image {
432
position: absolute;
443
top: 0;
@@ -79,32 +38,6 @@ g.height-range line {
7938
}
8039

8140
:global {
82-
g.note,
83-
g.note-editor {
84-
--note-color: var(
85-
--column-note-color,
86-
var(--column-stroke-color, var(--text-color, #000))
87-
);
88-
}
89-
g.note circle,
90-
g.note-editor circle {
91-
fill: var(--note-color);
92-
}
93-
g.note .link,
94-
g.note-editor .link {
95-
stroke: var(--note-color);
96-
stroke-width: 1;
97-
fill: none;
98-
}
99-
.new-note circle {
100-
fill: #1e90ff;
101-
}
102-
.new-note line {
103-
stroke: #1e90ff;
104-
stroke-width: 3;
105-
marker-start: url("#new_arrow_start");
106-
marker-end: url("#new_arrow_end");
107-
}
10841
#new_arrow_start,
10942
#new_arrow_end {
11043
fill: #1e90ff;

packages/column-components/src/notes/connector.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const NotePositioner = forwardRef(function (
4040
{
4141
ref,
4242
onClick,
43-
style: { margin: outerPad },
4443
},
4544
children,
4645
),

packages/column-components/src/notes/editor.ts

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const NoteTextEditor = function (props: NoteEditorProps) {
3535
interface NoteEditorProviderProps {
3636
inEditMode: boolean;
3737
noteEditor: ComponentType<NoteEditorProps>;
38-
onUpdateNote: (n: NoteData) => void;
39-
onDeleteNote: (n: NoteData) => void;
40-
onCreateNote: Function;
38+
onUpdateNote?: (n: NoteData) => void;
39+
onDeleteNote?: (n: NoteData) => void;
40+
onCreateNote?: Function;
4141
children?: React.ReactNode;
4242
}
4343

@@ -50,7 +50,7 @@ function NoteEditorProvider(props: NoteEditorProviderProps) {
5050
const deleteNote = function () {
5151
const val = editingNote;
5252
setEditingNote(null);
53-
return props.onDeleteNote(val);
53+
return props.onDeleteNote?.(val);
5454
};
5555

5656
const onCreateNote = function (pos) {
@@ -76,7 +76,7 @@ function NoteEditorProvider(props: NoteEditorProviderProps) {
7676
if (notes.includes(n)) {
7777
return;
7878
}
79-
return props.onUpdateNote(n);
79+
return props.onUpdateNote?.(n);
8080
};
8181

8282
//# Model editor provider gives us a nice store
@@ -257,22 +257,19 @@ function PositionEditorInner(props) {
257257
);
258258
}
259259

260-
const NoteEditorUnderlay = function ({ padding }) {
261-
const { width } = useContext(NoteLayoutContext);
262-
const { setEditingNote } = useContext(NoteEditorContext) as any;
260+
function NoteEditorUnderlay() {
263261
return h(NoteRect, {
264-
fill: "rgba(255,255,255,0.8)",
265262
style: { pointerEvents: "none" },
266263
className: "underlay",
267264
});
268-
};
265+
}
269266

270-
const NoteEditor = function (props) {
267+
function NoteEditor(props) {
271268
const { allowPositionEditing } = props;
272-
const { noteEditor } = useContext(NoteEditorContext) as any;
269+
const { noteEditor, setEditingNote } = useContext(NoteEditorContext) as any;
273270
const { notes, nodes, elementHeights, createNodeForNote } =
274271
useContext(NoteLayoutContext);
275-
const { editedModel } = useModelEditor();
272+
const { editedModel, model } = useModelEditor();
276273
if (editedModel == null) {
277274
return null;
278275
}
@@ -297,6 +294,8 @@ const NoteEditor = function (props) {
297294
node = newNode;
298295
}
299296

297+
const edited = editedModel === model;
298+
300299
return h(ErrorBoundary, [
301300
h("g.note-editor.note", [
302301
h(NoteEditorUnderlay),
@@ -305,15 +304,30 @@ const NoteEditor = function (props) {
305304
note: editedModel,
306305
node,
307306
}),
308-
h(NotePositioner, { offsetY: node.currentPos, noteHeight }, [
309-
h(noteEditor, {
310-
note: editedModel,
311-
key: index,
312-
}),
313-
]),
307+
h(
308+
NotePositioner,
309+
{
310+
offsetY: node.currentPos,
311+
noteHeight,
312+
onClick(evt) {
313+
if (edited) {
314+
setEditingNote(null);
315+
evt.stopPropagation();
316+
}
317+
},
318+
},
319+
[
320+
h(noteEditor, {
321+
note: editedModel,
322+
key: index,
323+
focused: true,
324+
edited,
325+
}),
326+
],
327+
),
314328
]),
315329
]);
316-
};
330+
}
317331

318332
export type { NoteData };
319333
export { NoteEditorProvider, NoteEditorContext, NoteTextEditor, NoteEditor };

packages/column-components/src/notes/height-range.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface HeightRangeAnnotationProps {
88
offsetX?: number;
99
color?: string;
1010
lineInset?: number;
11+
circleRadius?: number;
1112
}
1213

1314
function HeightRangeAnnotation(props: HeightRangeAnnotationProps) {
@@ -18,6 +19,7 @@ function HeightRangeAnnotation(props: HeightRangeAnnotationProps) {
1819
offsetX = 0,
1920
color,
2021
lineInset = 1,
22+
circleRadius = 2,
2123
...rest
2224
} = props;
2325

@@ -28,7 +30,11 @@ function HeightRangeAnnotation(props: HeightRangeAnnotationProps) {
2830
}
2931
const topHeight = bottomHeight - pxHeight;
3032

31-
const isLine = pxHeight > 2 * lineInset;
33+
/* Use a value slightly greater than the circle diameter as the cutoff
34+
to switch between line and circle, to account for a circle's greater
35+
visual weight than the equivalent line height
36+
*/
37+
const isLine = pxHeight > 3 * Math.max(lineInset, circleRadius);
3238

3339
const transform = `translate(${offsetX},${topHeight})`;
3440

@@ -40,7 +46,7 @@ function HeightRangeAnnotation(props: HeightRangeAnnotationProps) {
4046
y2: pxHeight - lineInset,
4147
}),
4248
h.if(!isLine)("circle", {
43-
r: 2,
49+
r: circleRadius,
4450
transform: `translate(0,${pxHeight / 2})`,
4551
}),
4652
]);

0 commit comments

Comments
 (0)