Skip to content

Commit ca9cfc4

Browse files
committed
Bug fix to timescale component
1 parent 75a0550 commit ca9cfc4

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

packages/timescale/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [2.3.1] - 2025-12-11
10+
11+
Fix coloring using `intervalStyle` prop, which was mistakenly overridden in the
12+
last update.
13+
914
## [2.3.0] - 2025-11-28
1015

1116
- Allow label positioning to be more discretely controlled (e.g., turn off label

packages/timescale/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/timescale",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "A configurable geologic timescale written with React and Typescript",
55
"type": "module",
66
"source": "src/index.ts",

packages/timescale/src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function IntervalBox(props: {
4040
} else if (intervalStyle != null) {
4141
style = intervalStyle;
4242
}
43-
style.backgroundColor = interval.col;
43+
// Set interval color if not already set by the logic above
44+
style.backgroundColor ??= interval.col;
4445

4546
const className = classNames("interval-box", {
4647
clickable: onClick != null,

packages/timescale/stories/main.stories.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Timescale, TimescaleProps, TimescaleOrientation } from "../src";
2+
import chroma from "chroma-js";
23

34
export default {
45
title: "Timescale/Timescale",
@@ -41,3 +42,19 @@ export const Condensed = {
4142
ageRange: [1000, 0],
4243
},
4344
};
45+
46+
export const WithRecoloredIntervals = {
47+
args: {
48+
orientation: TimescaleOrientation.VERTICAL,
49+
levels: [1, 3],
50+
intervalStyle(interval) {
51+
return {
52+
backgroundColor: chroma(interval.col)
53+
.set("hsl.l", 0.9)
54+
.set("hsl.s", 0.3)
55+
.hex(),
56+
color: chroma(interval.col).set("hsl.l", 0.1).css(),
57+
};
58+
},
59+
},
60+
};

0 commit comments

Comments
 (0)