@macrostrat/column-views 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/esm/_shared.f7eec55a.js +9 -0
  3. package/dist/esm/_shared.f7eec55a.js.map +1 -0
  4. package/dist/esm/age-axis.4a8cf5e6.js +98 -0
  5. package/dist/esm/age-axis.4a8cf5e6.js.map +1 -0
  6. package/dist/esm/age-axis.module.03773a80.css +33 -0
  7. package/dist/esm/age-axis.module.03773a80.css.map +1 -0
  8. package/dist/esm/age-axis.module.3cc91335.js +22 -0
  9. package/dist/esm/age-axis.module.3cc91335.js.map +1 -0
  10. package/dist/esm/age-model-overlay.c7226855.js +57 -0
  11. package/dist/esm/age-model-overlay.c7226855.js.map +1 -0
  12. package/dist/esm/age-model-overlay.module.5d9e78fb.css +14 -0
  13. package/dist/esm/age-model-overlay.module.5d9e78fb.css.map +1 -0
  14. package/dist/esm/age-model-overlay.module.cd985dcb.js +16 -0
  15. package/dist/esm/age-model-overlay.module.cd985dcb.js.map +1 -0
  16. package/dist/esm/base.910b80b4.js +288 -0
  17. package/dist/esm/base.910b80b4.js.map +1 -0
  18. package/dist/esm/boxes.8292cff2.js +258 -0
  19. package/dist/esm/boxes.8292cff2.js.map +1 -0
  20. package/dist/esm/boxes.module.2b5fb18e.css +26 -0
  21. package/dist/esm/boxes.module.2b5fb18e.css.map +1 -0
  22. package/dist/esm/boxes.module.4ebc7796.js +19 -0
  23. package/dist/esm/boxes.module.4ebc7796.js.map +1 -0
  24. package/dist/esm/{carbon-isotopes.3b502a9e.js → carbon-isotopes.10db8285.js} +2 -2
  25. package/dist/esm/{carbon-isotopes.3b502a9e.js.map → carbon-isotopes.10db8285.js.map} +1 -1
  26. package/dist/esm/colors.395c6db5.js +40 -0
  27. package/dist/esm/colors.395c6db5.js.map +1 -0
  28. package/dist/esm/column-correlation.c8dcfe98.js +9 -0
  29. package/dist/esm/column-correlation.c8dcfe98.js.map +1 -0
  30. package/dist/esm/column-nav.5414677c.js +55 -0
  31. package/dist/esm/column-nav.5414677c.js.map +1 -0
  32. package/dist/esm/column-navigation.37cd3245.js +9 -0
  33. package/dist/esm/column-navigation.37cd3245.js.map +1 -0
  34. package/dist/esm/column.01d68dd8.js +127 -0
  35. package/dist/esm/column.01d68dd8.js.map +1 -0
  36. package/dist/esm/{column.db058031.js → column.a25f8ebd.js} +4 -4
  37. package/dist/esm/column.a25f8ebd.js.map +1 -0
  38. package/dist/esm/column.module.1b776e15.js +46 -0
  39. package/dist/esm/column.module.1b776e15.js.map +1 -0
  40. package/dist/esm/column.module.a67a6b4c.css +159 -0
  41. package/dist/esm/column.module.a67a6b4c.css.map +1 -0
  42. package/dist/esm/composite-scale.577bf64a.js +222 -0
  43. package/dist/esm/composite-scale.577bf64a.js.map +1 -0
  44. package/dist/esm/composite.039e4798.js +163 -0
  45. package/dist/esm/composite.039e4798.js.map +1 -0
  46. package/dist/esm/{core.4db8e452.js → core.843310d3.js} +11 -12
  47. package/dist/esm/core.843310d3.js.map +1 -0
  48. package/dist/esm/core.91ede078.js +206 -0
  49. package/dist/esm/core.91ede078.js.map +1 -0
  50. package/dist/esm/correlation-chart.abd8b346.js +9 -0
  51. package/dist/esm/correlation-chart.abd8b346.js.map +1 -0
  52. package/dist/esm/data-provider.1506eb64.js.map +1 -1
  53. package/dist/esm/data-provider.f10c6d0b.js +13 -0
  54. package/dist/esm/data-provider.f10c6d0b.js.map +1 -0
  55. package/dist/esm/fetch.99aec438.js +152 -0
  56. package/dist/esm/fetch.99aec438.js.map +1 -0
  57. package/dist/esm/hash-string.285b37fb.js +39 -0
  58. package/dist/esm/hash-string.285b37fb.js.map +1 -0
  59. package/dist/esm/helpers.2f0a0cb7.js +141 -0
  60. package/dist/esm/helpers.2f0a0cb7.js.map +1 -0
  61. package/dist/esm/index.d.ts +797 -120
  62. package/dist/esm/index.d.ts.map +1 -1
  63. package/dist/esm/index.js +14 -8
  64. package/dist/esm/index.js.map +1 -1
  65. package/dist/esm/inset-map.3c18106d.js +66 -0
  66. package/dist/esm/inset-map.3c18106d.js.map +1 -0
  67. package/dist/esm/keyboard-navigation.6713401b.js +48 -0
  68. package/dist/esm/keyboard-navigation.6713401b.js.map +1 -0
  69. package/dist/esm/keyboard-navigation.a9fc80dd.js +112 -0
  70. package/dist/esm/keyboard-navigation.a9fc80dd.js.map +1 -0
  71. package/dist/esm/layers.033d3fb0.js +170 -0
  72. package/dist/esm/layers.033d3fb0.js.map +1 -0
  73. package/dist/esm/main.2e0375a5.js +221 -0
  74. package/dist/esm/main.2e0375a5.js.map +1 -0
  75. package/dist/esm/main.module.3dd9500b.css +134 -0
  76. package/dist/esm/main.module.3dd9500b.css.map +1 -0
  77. package/dist/esm/main.module.c09154b1.js +70 -0
  78. package/dist/esm/main.module.c09154b1.js.map +1 -0
  79. package/dist/esm/mapbox.cac42eed.js +167 -0
  80. package/dist/esm/mapbox.cac42eed.js.map +1 -0
  81. package/dist/esm/maps.bcdea9c1.js +11 -0
  82. package/dist/esm/maps.bcdea9c1.js.map +1 -0
  83. package/dist/esm/{names.f6a4e9a4.js → names.a8f2b452.js} +5 -5
  84. package/dist/esm/names.a8f2b452.js.map +1 -0
  85. package/dist/esm/panel.598f76a5.js +420 -0
  86. package/dist/esm/panel.598f76a5.js.map +1 -0
  87. package/dist/esm/panel.module.386166cc.js +58 -0
  88. package/dist/esm/panel.module.386166cc.js.map +1 -0
  89. package/dist/esm/panel.module.3d2ea3c6.css +111 -0
  90. package/dist/esm/panel.module.3d2ea3c6.css.map +1 -0
  91. package/dist/esm/popover.a810b7bc.js +66 -0
  92. package/dist/esm/popover.a810b7bc.js.map +1 -0
  93. package/dist/esm/popover.module.c4ba4189.js +22 -0
  94. package/dist/esm/popover.module.c4ba4189.js.map +1 -0
  95. package/dist/esm/{selection-popover.module.0a701258.css → popover.module.c4d6bfb0.css} +11 -8
  96. package/dist/esm/popover.module.c4d6bfb0.css.map +1 -0
  97. package/dist/esm/prepare-data.d4284b4a.js +125 -0
  98. package/dist/esm/prepare-data.d4284b4a.js.map +1 -0
  99. package/dist/esm/prepare-units.6c890a96.js +104 -0
  100. package/dist/esm/prepare-units.6c890a96.js.map +1 -0
  101. package/dist/esm/{resolvers.b5c82b78.js → resolvers.36013b49.js} +13 -2
  102. package/dist/esm/resolvers.36013b49.js.map +1 -0
  103. package/dist/esm/section.a34d379a.js +215 -0
  104. package/dist/esm/section.a34d379a.js.map +1 -0
  105. package/dist/esm/selection.f5b0297e.js +143 -0
  106. package/dist/esm/selection.f5b0297e.js.map +1 -0
  107. package/dist/esm/state.178ef364.js +75 -0
  108. package/dist/esm/state.178ef364.js.map +1 -0
  109. package/dist/esm/state.2952cbca.js +118 -0
  110. package/dist/esm/state.2952cbca.js.map +1 -0
  111. package/dist/esm/store.c4d7a8a4.js +52 -0
  112. package/dist/esm/store.c4d7a8a4.js.map +1 -0
  113. package/dist/esm/styles.7bc776d1.js +95 -0
  114. package/dist/esm/styles.7bc776d1.js.map +1 -0
  115. package/dist/esm/svg.4b9a96c1.js +89 -0
  116. package/dist/esm/svg.4b9a96c1.js.map +1 -0
  117. package/dist/esm/types.0f0b57c9.js +3 -0
  118. package/dist/esm/types.0f0b57c9.js.map +1 -0
  119. package/dist/esm/unit-details.071cefed.js +9 -0
  120. package/dist/esm/unit-details.071cefed.js.map +1 -0
  121. package/dist/esm/units.5a4fc058.js +98 -0
  122. package/dist/esm/units.5a4fc058.js.map +1 -0
  123. package/dist/esm/utils.d7a43a2a.js +55 -0
  124. package/dist/esm/utils.d7a43a2a.js.map +1 -0
  125. package/dist/node/index.js.map +1 -1
  126. package/package.json +24 -7
  127. package/src/age-axis.module.sass +27 -0
  128. package/src/age-axis.ts +82 -19
  129. package/src/age-model-overlay.module.sass +11 -0
  130. package/src/age-model-overlay.ts +73 -0
  131. package/src/carbon-isotopes/column.ts +4 -2
  132. package/src/carbon-isotopes/core.ts +9 -6
  133. package/src/carbon-isotopes/data-provider.ts +3 -3
  134. package/src/column.module.sass +58 -49
  135. package/src/column.ts +149 -135
  136. package/src/correlation-chart/hash-string.ts +57 -0
  137. package/src/correlation-chart/index.ts +2 -0
  138. package/src/correlation-chart/main.module.sass +122 -0
  139. package/src/correlation-chart/main.ts +305 -0
  140. package/src/correlation-chart/prepare-data.ts +217 -0
  141. package/src/correlation-chart/stories/correlation-chart.stories.ts +192 -0
  142. package/src/correlation-chart/stories/stories.module.sass +18 -0
  143. package/src/correlation-chart/unconformity-line.module.sass +8 -0
  144. package/src/correlation-chart/unconformity-line.ts +25 -0
  145. package/src/data-provider/base.ts +388 -0
  146. package/src/data-provider/column-nav.ts +53 -0
  147. package/src/data-provider/fetch.ts +231 -0
  148. package/src/data-provider/index.ts +4 -0
  149. package/src/data-provider/store.ts +72 -0
  150. package/src/index.ts +6 -3
  151. package/src/maps/_shared/index.ts +2 -0
  152. package/src/maps/_shared/inset-map.stories.ts +20 -0
  153. package/src/maps/_shared/inset-map.ts +87 -0
  154. package/src/maps/_shared/styles.ts +57 -0
  155. package/src/maps/column-correlation/column-correlation-map.stories.ts +96 -0
  156. package/src/maps/column-correlation/core.ts +225 -0
  157. package/src/maps/column-correlation/index.ts +2 -0
  158. package/src/maps/column-correlation/state.ts +192 -0
  159. package/src/maps/column-navigation/index.ts +2 -0
  160. package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +102 -0
  161. package/src/maps/column-navigation/mapbox/index.ts +219 -0
  162. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +119 -0
  163. package/src/maps/column-navigation/mapbox/state.ts +109 -0
  164. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +46 -0
  165. package/src/{map → maps/column-navigation/svg}/index.ts +18 -6
  166. package/src/{map → maps/column-navigation/svg}/layers.ts +28 -109
  167. package/src/maps/column-navigation/utils/keyboard-navigation.ts +58 -0
  168. package/src/maps/index.ts +3 -0
  169. package/src/prepare-units/composite-scale.ts +353 -0
  170. package/src/prepare-units/helpers.ts +226 -0
  171. package/src/prepare-units/index.ts +177 -0
  172. package/src/prepare-units/utils.ts +98 -0
  173. package/src/section.ts +264 -84
  174. package/src/unit-details/index.ts +2 -215
  175. package/src/unit-details/{index.module.sass → panel.module.sass} +39 -8
  176. package/src/unit-details/panel.ts +523 -0
  177. package/src/{selection-popover.module.sass → unit-details/popover.module.sass} +4 -2
  178. package/src/unit-details/popover.ts +82 -0
  179. package/src/units/boxes.module.sass +16 -0
  180. package/src/units/boxes.ts +243 -90
  181. package/src/units/colors.ts +64 -0
  182. package/src/units/composite.ts +157 -152
  183. package/src/units/index.ts +76 -9
  184. package/src/units/names.ts +8 -4
  185. package/src/units/resolvers.ts +11 -0
  186. package/src/units/selection.ts +115 -101
  187. package/src/units/types.ts +5 -16
  188. package/dist/esm/age-axis.64c509ee.js +0 -41
  189. package/dist/esm/age-axis.64c509ee.js.map +0 -1
  190. package/dist/esm/boxes.13968b76.js +0 -164
  191. package/dist/esm/boxes.13968b76.js.map +0 -1
  192. package/dist/esm/boxes.module.28873d08.css +0 -4
  193. package/dist/esm/boxes.module.28873d08.css.map +0 -1
  194. package/dist/esm/boxes.module.605bdcd6.js +0 -13
  195. package/dist/esm/boxes.module.605bdcd6.js.map +0 -1
  196. package/dist/esm/column.8dd26e1a.js +0 -149
  197. package/dist/esm/column.8dd26e1a.js.map +0 -1
  198. package/dist/esm/column.db058031.js.map +0 -1
  199. package/dist/esm/column.module.039d872c.css +0 -151
  200. package/dist/esm/column.module.039d872c.css.map +0 -1
  201. package/dist/esm/column.module.e632868a.js +0 -19
  202. package/dist/esm/column.module.e632868a.js.map +0 -1
  203. package/dist/esm/composite.608a4ca2.js +0 -153
  204. package/dist/esm/composite.608a4ca2.js.map +0 -1
  205. package/dist/esm/core.4db8e452.js.map +0 -1
  206. package/dist/esm/helpers.8a03cfc7.js +0 -94
  207. package/dist/esm/helpers.8a03cfc7.js.map +0 -1
  208. package/dist/esm/index.module.0844afd8.css +0 -65
  209. package/dist/esm/index.module.0844afd8.css.map +0 -1
  210. package/dist/esm/index.module.24fe3a2e.js +0 -37
  211. package/dist/esm/index.module.24fe3a2e.js.map +0 -1
  212. package/dist/esm/layers.ad5fd25d.js +0 -231
  213. package/dist/esm/layers.ad5fd25d.js.map +0 -1
  214. package/dist/esm/map.7aa26f17.js +0 -82
  215. package/dist/esm/map.7aa26f17.js.map +0 -1
  216. package/dist/esm/names.f6a4e9a4.js.map +0 -1
  217. package/dist/esm/providers.cd1e652f.js +0 -25
  218. package/dist/esm/providers.cd1e652f.js.map +0 -1
  219. package/dist/esm/resolvers.b5c82b78.js.map +0 -1
  220. package/dist/esm/section.cc1b1100.js +0 -118
  221. package/dist/esm/section.cc1b1100.js.map +0 -1
  222. package/dist/esm/selection-popover.17d1bd55.js +0 -60
  223. package/dist/esm/selection-popover.17d1bd55.js.map +0 -1
  224. package/dist/esm/selection-popover.module.0a701258.css.map +0 -1
  225. package/dist/esm/selection-popover.module.e22f5183.js +0 -22
  226. package/dist/esm/selection-popover.module.e22f5183.js.map +0 -1
  227. package/dist/esm/selection.bbf26d0e.js +0 -117
  228. package/dist/esm/selection.bbf26d0e.js.map +0 -1
  229. package/dist/esm/store.25eaa168.js +0 -18
  230. package/dist/esm/store.25eaa168.js.map +0 -1
  231. package/dist/esm/types.f016e032.js +0 -18
  232. package/dist/esm/types.f016e032.js.map +0 -1
  233. package/dist/esm/unit-details.56ff8b70.js +0 -209
  234. package/dist/esm/unit-details.56ff8b70.js.map +0 -1
  235. package/dist/esm/units.361088d4.js +0 -42
  236. package/dist/esm/units.361088d4.js.map +0 -1
  237. package/src/helpers.ts +0 -133
  238. package/src/providers.ts +0 -34
  239. package/src/selection-popover.ts +0 -71
  240. package/src/store.ts +0 -12
  241. package/src/units/units.scss +0 -16
  242. /package/src/{map → maps/column-navigation/svg}/animated.ts +0 -0
package/src/section.ts CHANGED
@@ -1,69 +1,151 @@
1
- import { CompositeUnitsColumn, IUnit } from "./units";
2
- import { ReactNode, useMemo } from "react";
3
- import { AgeAxis } from "./age-axis";
1
+ import {
2
+ CompositeUnitsColumn,
3
+ LabelTrackerProvider,
4
+ SectionLabelsColumn,
5
+ } from "./units";
6
+ import { ReactNode, FunctionComponent, useMemo } from "react";
4
7
  import { Timescale, TimescaleOrientation } from "@macrostrat/timescale";
5
- import { ColumnSVG } from "@macrostrat/column-components";
6
- import { MacrostratColumnProvider } from "./index";
8
+ import { ColumnAxisType, SVG } from "@macrostrat/column-components";
7
9
  import hyper from "@macrostrat/hyper";
8
10
  import styles from "./column.module.sass";
11
+ import type { ExtUnit } from "./prepare-units/helpers";
12
+ import { PackageScaleLayoutData } from "./prepare-units/composite-scale";
13
+ import {
14
+ useMacrostratColumnData,
15
+ useMacrostratUnits,
16
+ MacrostratColumnProvider,
17
+ } from "./data-provider";
18
+ import { Duration } from "./unit-details";
9
19
 
10
20
  const h = hyper.styled(styles);
11
21
 
12
- export interface SectionInfo {
13
- section_id: number | number[];
14
- t_age: number;
15
- b_age: number;
16
- units: IUnit[];
17
- }
18
-
19
- export interface IColumnProps {
20
- data: IUnit[];
21
- pixelScale?: number;
22
- range?: [number, number];
23
- unitComponent?: React.FunctionComponent<any>;
22
+ export interface SectionSharedProps {
23
+ unitComponent?: FunctionComponent<any>;
24
24
  unitComponentProps?: any;
25
25
  showLabels?: boolean;
26
26
  width?: number;
27
27
  columnWidth?: number;
28
- targetUnitHeight?: number;
29
28
  children?: ReactNode;
30
29
  showLabelColumn?: boolean;
30
+ axisType?: ColumnAxisType;
31
+ className?: string;
32
+ clipUnits?: boolean;
33
+ maxInternalColumns?: number;
34
+ // Space between sections
35
+ verticalSpacing?: number;
36
+ // Whether to render unconformity labels
37
+ unconformityLabels?: boolean;
38
+ }
39
+
40
+ export interface SectionProps extends SectionSharedProps {
41
+ units: ExtUnit[];
42
+ scaleInfo: PackageScaleLayoutData;
31
43
  }
32
44
 
33
- export function Section(props: IColumnProps) {
34
- // Section with "squishy" time scale
45
+ export function SectionsColumn(props: SectionSharedProps) {
35
46
  const {
36
- data,
37
- range: _range,
38
- pixelScale: _pixelScale,
47
+ unconformityLabels = true,
39
48
  unitComponent,
49
+ unitComponentProps,
40
50
  showLabels = true,
41
- targetUnitHeight = 20,
42
51
  width = 300,
43
52
  columnWidth = 150,
44
- unitComponentProps,
45
53
  showLabelColumn = true,
54
+ clipUnits = true,
55
+ maxInternalColumns,
46
56
  } = props;
47
57
 
48
- const b_age = Math.max(...data.map((d) => d.b_age));
49
- const t_age = Math.min(...data.map((d) => d.t_age));
58
+ const units = useMacrostratUnits();
50
59
 
51
- const range = useMemo(() => {
52
- if (_range == null) {
53
- return [b_age, t_age];
54
- }
55
- return _range;
56
- }, [_range, b_age, t_age]);
60
+ // Get a unique key for the column
61
+ const key = units[0]?.unit_id;
57
62
 
58
- const dAge = useMemo(() => range[0] - range[1], [range]);
63
+ return h(LabelTrackerProvider, { units, key }, [
64
+ h(SectionUnitsColumn, {
65
+ width: columnWidth,
66
+ unitComponent,
67
+ unitComponentProps,
68
+ showLabels,
69
+ clipUnits,
70
+ maxInternalColumns,
71
+ unconformityLabels,
72
+ }),
73
+ h.if(showLabelColumn)(SectionLabelsColumn, {
74
+ width: width - columnWidth,
75
+ }),
76
+ ]);
77
+ }
78
+
79
+ function SectionUnitsColumn(props: SectionSharedProps) {
80
+ const {
81
+ width,
82
+ showLabels,
83
+ unitComponent,
84
+ unitComponentProps,
85
+ clipUnits,
86
+ maxInternalColumns,
87
+ unconformityLabels = true,
88
+ } = props;
59
89
 
60
- const pixelScale = useMemo(() => {
61
- if (_pixelScale != null) return _pixelScale;
62
- const targetHeight = targetUnitHeight * data.length;
63
- return Math.ceil(targetHeight / dAge);
64
- }, [_pixelScale, targetUnitHeight, data.length, dAge]);
90
+ const { sections, totalHeight } = useMacrostratColumnData();
91
+
92
+ const scaleData: PackageScaleLayoutData[] = sections.map((section) => {
93
+ return section.scaleInfo;
94
+ });
95
+
96
+ const innerWidth = width - 2;
97
+
98
+ return h("div.section-units-container", { style: { width } }, [
99
+ h(
100
+ SVG,
101
+ {
102
+ className: "sections",
103
+ height: totalHeight,
104
+ innerWidth,
105
+ paddingH: 1,
106
+ },
107
+ sections.map((group) => {
108
+ const { units, scaleInfo, section_id } = group;
109
+
110
+ const key = `section-${section_id}`;
111
+ return h(
112
+ SectionUnits,
113
+ {
114
+ units,
115
+ scaleInfo,
116
+ key,
117
+ unitComponent,
118
+ unitComponentProps,
119
+ showLabels,
120
+ width: innerWidth,
121
+ clipUnits,
122
+ maxInternalColumns,
123
+ } // This unconformity is with the section _above_
124
+ );
125
+ })
126
+ ),
127
+ h.if(unconformityLabels)(UnconformityLabels, {
128
+ width,
129
+ sections: scaleData,
130
+ }),
131
+ ]);
132
+ }
133
+
134
+ function SectionUnits(props: SectionProps) {
135
+ // Section with "squishy" timescale
136
+ const {
137
+ units,
138
+ scaleInfo,
139
+ unitComponent,
140
+ showLabels = true,
141
+ width = 300,
142
+ unitComponentProps,
143
+ className,
144
+ clipUnits = true,
145
+ maxInternalColumns,
146
+ } = props;
65
147
 
66
- const height = useMemo(() => dAge * pixelScale, [dAge, pixelScale]);
148
+ const { domain, pixelScale, pixelHeight } = scaleInfo;
67
149
 
68
150
  /** Ensure that we can arrange units into the maximum number
69
151
  * of columns defined by unitComponentProps, but that we don't
@@ -73,57 +155,155 @@ export function Section(props: IColumnProps) {
73
155
  return {
74
156
  ...unitComponentProps,
75
157
  nColumns: Math.min(
76
- Math.max(...data.map((d) => d.column)) + 1,
77
- unitComponentProps?.nColumns ?? 2
158
+ maxInternalColumns ?? Math.floor(width / 10),
159
+ unitComponentProps?.nColumns ?? Infinity,
160
+ Math.max(...units.map((d) => d.column)) + 1
78
161
  ),
162
+ //axisType,
79
163
  };
80
- }, [data, unitComponentProps]);
164
+ }, [units, unitComponentProps, maxInternalColumns, width]);
165
+
166
+ const style = {
167
+ "--section-height": `${pixelHeight}px`,
168
+ "--section-width": `${width}px`,
169
+ };
81
170
 
82
171
  return h(
83
- MacrostratColumnProvider,
172
+ "g.section",
173
+ { className, style, transform: `translate(0 ${scaleInfo.offset})` },
174
+ h(
175
+ MacrostratColumnProvider,
176
+ {
177
+ units,
178
+ domain,
179
+ pixelScale, // Actually pixels per myr,
180
+ },
181
+ h(CompositeUnitsColumn, {
182
+ width,
183
+ showLabels,
184
+ unitComponent,
185
+ unitComponentProps: _unitComponentProps,
186
+ clipToFrame: clipUnits,
187
+ })
188
+ )
189
+ );
190
+ }
191
+
192
+ interface CompositeTimescaleProps {
193
+ levels?: [number, number] | number;
194
+ }
195
+
196
+ export function CompositeTimescale(props: CompositeTimescaleProps) {
197
+ const { sections } = useMacrostratColumnData();
198
+ const sectionScales = sections.map((section) => {
199
+ return section.scaleInfo;
200
+ });
201
+
202
+ return h(CompositeTimescaleCore, {
203
+ packages: sectionScales,
204
+ ...props,
205
+ });
206
+ }
207
+
208
+ type CompositeTimescaleCoreProps = CompositeTimescaleProps & {
209
+ packages: PackageScaleLayoutData[];
210
+ unconformityLabels?: boolean;
211
+ };
212
+
213
+ export function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {
214
+ const { levels = 3, packages, unconformityLabels = false } = props;
215
+
216
+ let _levels: [number, number];
217
+ if (typeof levels === "number") {
218
+ // If levels is a number, use the most common starting level
219
+ _levels = [2, Math.max(2 + Math.min(levels, 5) - 1, 1)];
220
+ } else {
221
+ _levels = levels;
222
+ }
223
+
224
+ const nCols = _levels[1] - _levels[0] + 1;
225
+
226
+ return h("div.timescale-column", [
227
+ h(
228
+ "div.timescales",
229
+ packages.map((group) => {
230
+ const { domain, pixelHeight, paddingTop, key } = group;
231
+ return h(
232
+ "div.timescale-container",
233
+ { style: { paddingTop, "--timescale-level-count": nCols }, key },
234
+ [
235
+ h(Timescale, {
236
+ orientation: TimescaleOrientation.VERTICAL,
237
+ length: pixelHeight,
238
+ levels: _levels,
239
+ absoluteAgeScale: true,
240
+ showAgeAxis: false,
241
+ ageRange: domain as [number, number],
242
+ }),
243
+ ]
244
+ );
245
+ })
246
+ ),
247
+ h.if(unconformityLabels)(UnconformityLabels, {
248
+ width: "100%",
249
+ sections: packages,
250
+ className: "unconformity-labels",
251
+ }),
252
+ ]);
253
+ }
254
+
255
+ export function UnconformityLabels(props: {
256
+ width: string | number;
257
+ sections: PackageScaleLayoutData[];
258
+ className?: string;
259
+ }) {
260
+ const { width, sections, className } = props;
261
+
262
+ return h(
263
+ "div.unconformity-labels",
84
264
  {
85
- divisions: data,
86
- range,
87
- pixelsPerMeter: pixelScale, // Actually pixels per myr
265
+ style: {
266
+ width,
267
+ },
268
+ className,
88
269
  },
89
- [
90
- h(AgeAxis, {
91
- width: 20,
92
- padding: 0,
93
- paddingV: 10,
94
- showLabel: false,
95
- }),
96
- h("div.timescale-container", { style: { marginTop: `10px` } }, [
97
- h(Timescale, {
98
- orientation: TimescaleOrientation.VERTICAL,
99
- length: height,
100
- levels: timescaleLevels as [number, number],
101
- absoluteAgeScale: true,
102
- showAgeAxis: false,
103
- ageRange: range as [number, number],
104
- }),
105
- ]),
106
- h(
107
- ColumnSVG,
108
- {
109
- innerWidth: showLabels ? width : columnWidth,
110
- paddingRight: 1,
111
- paddingLeft: 1,
112
- paddingV: 10,
113
- innerHeight: height,
270
+ sections.map((scaleInfo, i) => {
271
+ const lastGroup = sections[i - 1];
272
+ const top = scaleInfo.offset - scaleInfo.paddingTop;
273
+ const upperAge = lastGroup?.domain[0];
274
+ const lowerAge = scaleInfo.domain[1];
275
+ return h(Unconformity, {
276
+ upperAge,
277
+ lowerAge,
278
+ style: {
279
+ width,
280
+ height: scaleInfo.paddingTop,
281
+ top,
114
282
  },
115
- h(CompositeUnitsColumn, {
116
- showLabelColumn: showLabelColumn,
117
- width: showLabels ? width : columnWidth,
118
- columnWidth,
119
- gutterWidth: 5,
120
- showLabels,
121
- unitComponent,
122
- unitComponentProps: _unitComponentProps,
123
- })
124
- ),
125
- ]
283
+ });
284
+ })
126
285
  );
127
286
  }
128
287
 
129
- const timescaleLevels = [2, 5];
288
+ function Unconformity({ upperAge, lowerAge, style }) {
289
+ if (upperAge == null || lowerAge == null) {
290
+ return null;
291
+ }
292
+
293
+ const ageGap = Math.abs(upperAge - lowerAge);
294
+
295
+ let className: string = null;
296
+ if (ageGap > 1000) {
297
+ className = "giga";
298
+ } else if (ageGap > 100) {
299
+ className = "mega";
300
+ } else if (ageGap > 10) {
301
+ className = "large";
302
+ } else if (ageGap < 1) {
303
+ className = "small";
304
+ }
305
+
306
+ return h("div.unconformity", { style, className }, [
307
+ h("div.unconformity-text", h(Duration, { value: ageGap })),
308
+ ]);
309
+ }
@@ -1,215 +1,2 @@
1
- import hyper from "@macrostrat/hyper";
2
- import styles from "./index.module.sass";
3
- import { JSONView } from "@macrostrat/ui-components";
4
- import { Button } from "@blueprintjs/core";
5
- import { useState } from "react";
6
- import {
7
- DataField,
8
- EnvironmentsList,
9
- Interval,
10
- ItemList,
11
- LithologyList,
12
- } from "@macrostrat/data-components";
13
- import { useUnitSelectionDispatch } from "../units/selection";
14
- import { useMacrostratUnits } from "../store";
15
-
16
- const h = hyper.styled(styles);
17
-
18
- export function UnitDetailsPanel({
19
- unit,
20
- onClose,
21
- }: {
22
- unit: any;
23
- onClose?: any;
24
- }) {
25
- const [showJSON, setShowJSON] = useState(false);
26
-
27
- let content = null;
28
- if (showJSON) {
29
- content = h(JSONView, { data: unit, showRoot: false });
30
- } else {
31
- content = h(UnitDetailsContent, { unit });
32
- }
33
-
34
- return h("div.unit-details-panel", [
35
- h(LegendPanelHeader, {
36
- onClose,
37
- title: unit.unit_name,
38
- id: unit.unit_id,
39
- actions: [
40
- h(Button, {
41
- icon: "code",
42
- small: true,
43
- minimal: true,
44
- className: "json-view-toggle",
45
- onClick() {
46
- setShowJSON(!showJSON);
47
- },
48
- }),
49
- ],
50
- }),
51
- h("div.unit-details-content", [content]),
52
- ]);
53
- }
54
-
55
- export function LegendPanelHeader({ title, id, onClose, actions = null }) {
56
- return h("header.legend-panel-header", [
57
- h.if(title != null)("h3", title),
58
- h("div.spacer"),
59
- h.if(id != null)("code", id),
60
- actions,
61
- h.if(onClose != null)(Button, {
62
- icon: "cross",
63
- minimal: true,
64
- small: true,
65
- onClick() {
66
- onClose();
67
- },
68
- }),
69
- ]);
70
- }
71
-
72
- function UnitDetailsContent({ unit }) {
73
- let outcrop = unit.outcrop;
74
- if (outcrop == "both") {
75
- outcrop = "surface and subsurface";
76
- }
77
-
78
- return h("div.unit-details-content", [
79
- h(DataField, {
80
- label: "Thickness",
81
- value: `${unit.min_thick}–${unit.max_thick}`,
82
- unit: "m",
83
- }),
84
- h(LithologyList, { lithologies: unit.lith }),
85
- h(DataField, {
86
- label: "Age range",
87
- value: `${unit.b_age}–${unit.t_age}`,
88
- unit: "Ma",
89
- }),
90
- h(IntervalField, { unit }),
91
- h(EnvironmentsList, { environments: unit.environ }),
92
- h(DataField, { label: "Outcrop", value: outcrop }),
93
- h(
94
- DataField,
95
- {
96
- label: "Stratigraphic name",
97
- },
98
- h("span.strat-name-id", unit.strat_name_id)
99
- ),
100
- h(
101
- DataField,
102
- { label: "Above" },
103
- h(UnitIDList, { units: unit.units_above })
104
- ),
105
- h(
106
- DataField,
107
- { label: "Below" },
108
- h(UnitIDList, { units: unit.units_below })
109
- ),
110
- h(
111
- DataField,
112
- { label: "Color" },
113
- h("span.color-swatch", { style: { backgroundColor: unit.color } })
114
- ),
115
- ]);
116
- }
117
-
118
- function UnitIDList({ units }) {
119
- const u1 = units.filter((d) => d != 0);
120
- const dispatch = useUnitSelectionDispatch();
121
- const allUnits = useMacrostratUnits();
122
-
123
- if (u1.length === 0) {
124
- return h("span.no-units", "None");
125
- }
126
-
127
- let onClickHandler = null;
128
- let tag = "span";
129
- if (dispatch != null) {
130
- onClickHandler = (id: number) => (evt) => {
131
- console.log(units);
132
- const unit = allUnits.find((d) => d.unit_id == id);
133
- dispatch(unit, null, null);
134
- evt.stopPropagation();
135
- };
136
- tag = "a";
137
- }
138
-
139
- return h(ItemList, { className: "unit-id-list" }, [
140
- u1.map((unit) => {
141
- return h(
142
- tag,
143
- { className: "unit-id", onClick: onClickHandler?.(unit) },
144
- unit
145
- );
146
- }),
147
- ]);
148
- }
149
-
150
- function IntervalField({ unit }) {
151
- return h([
152
- h(
153
- DataField,
154
- {
155
- label: "Intervals",
156
- },
157
- h(IntervalProportions, { unit })
158
- ),
159
- ]);
160
- }
161
-
162
- function IntervalProportions({ unit }) {
163
- const i0 = unit.b_int_id;
164
- const i1 = unit.t_int_id;
165
- let b_prop = unit.b_prop ?? 0;
166
- let t_prop = unit.t_prop ?? 1;
167
-
168
- if (i0 === i1 && b_prop === 0 && t_prop === 1) {
169
- // We have a single interval with undefined proportions
170
- return h(Interval, {
171
- interval: {
172
- id: i0,
173
- name: unit.b_int_name,
174
- },
175
- });
176
- }
177
-
178
- return h(ItemList, { className: "interval-proportions" }, [
179
- h(Proportion, { value: b_prop }),
180
- h.if(i0 != i1)(Interval, {
181
- interval: {
182
- id: i0,
183
- name: unit.b_int_name,
184
- },
185
- proportion: b_prop,
186
- }),
187
- h("span.sep", "to"),
188
- h(Proportion, { value: t_prop }),
189
- h(Interval, {
190
- interval: {
191
- id: i1,
192
- name: unit.t_int_name,
193
- },
194
- proportion: t_prop,
195
- }),
196
- ]);
197
- }
198
-
199
- const formatProportion = (d) => {
200
- if (d == null) return null;
201
- return d.toFixed(1);
202
- };
203
-
204
- function Proportion({ value }) {
205
- let content = null;
206
- if (value == 0) {
207
- content = "base";
208
- } else if (value == 1) {
209
- content = "top";
210
- } else {
211
- content = formatProportion(value * 100) + "%";
212
- }
213
-
214
- return h("span.proportion", content);
215
- }
1
+ export * from "./panel";
2
+ export * from "./popover";
@@ -7,9 +7,25 @@
7
7
  position: sticky
8
8
  top: 0
9
9
  background-color: var(--panel-secondary-background-color)
10
- margin: -1em -1em 0
11
10
  padding: 0.5em 1em
12
11
  z-index: 50
12
+ .title-container
13
+ display: flex
14
+ flex-direction: row
15
+ gap: 0.5em
16
+ align-items: center
17
+ margin: -0.5em 0
18
+ &:hover
19
+ .hidden-actions
20
+ display: flex
21
+ opacity: 0.5
22
+ h1, h2, h3
23
+ margin: 0.5em 0
24
+ .hidden-actions
25
+ display: none
26
+ button
27
+ transform: translateY(0px)
28
+
13
29
  code
14
30
  font-size: 0.9em
15
31
  color: var(--secondary-color)
@@ -19,24 +35,24 @@
19
35
  line-height: 1.5
20
36
  transform: translateY(2px)
21
37
 
22
- h3
23
- margin: 0 0 0.5em
24
- font-size: 1.1em
38
+ .unit-details-panel
39
+ display: flex
40
+ flex-direction: column
41
+ .unit-details-content-holder
42
+ flex: 1
43
+ overflow-y: scroll
25
44
 
26
45
  .unit-details-content
27
46
  position: relative
28
- margin-top: 1em
29
- margin-bottom: -0.5em
47
+ margin: 1em
30
48
 
31
49
  .proportion, .sep, .no-units
32
50
  color: var(--secondary-color)
33
51
  font-style: italic
34
- font-size: 0.9em
35
52
 
36
53
  .strat-name-id, .unit-id
37
54
  font-family: var(--monospace-font)
38
55
  color: var(--secondary-color)
39
- font-size: 0.9em
40
56
 
41
57
  &::before
42
58
  content: '#'
@@ -49,3 +65,18 @@
49
65
  margin-right: 0.2em
50
66
  border: 1px solid var(--panel-rule-color)
51
67
  display: inline-block
68
+
69
+ .refs
70
+ list-style: none
71
+ margin: 0
72
+ padding-left: 0
73
+
74
+ .interval-proportions
75
+ flex-grow: 1
76
+ width: 100%
77
+ text-align: right
78
+ .discourage-break
79
+ white-space: nowrap
80
+ .sep
81
+ margin: 0 0.3em
82
+