Skip to content

Commit b3e67c7

Browse files
authored
Merge pull request #87 from UW-Macrostrat/add-ui
Add UI components
2 parents c3d9085 + 888b0df commit b3e67c7

File tree

15 files changed

+714
-15
lines changed

15 files changed

+714
-15
lines changed

packages/timescale/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ 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+
## [unreleased]
10+
Timescale now clickable, returns event and interval clicked
11+
912
## [2.1.1] - 2025-02-15
1013

1114
Add a `node` target to bundle without imported CSS.

packages/timescale/src/components/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ function IntervalBox(props: {
2121
interval: Interval;
2222
showLabel?: boolean;
2323
intervalStyle: IntervalStyleBuilder;
24+
onClick: (e: Event, interval: Interval) => void;
2425
}) {
25-
const { interval, showLabel = true, intervalStyle } = props;
26+
const { interval, showLabel = true, intervalStyle, onClick } = props;
2627

2728
const [labelText, setLabelText] = useState<string>(interval.nam);
2829

@@ -52,15 +53,16 @@ function IntervalBox(props: {
5253
setLabelText(labelText[0]);
5354
}
5455
},
56+
onClick: (e) => onClick(e, interval),
5557
});
5658
}
5759

58-
function IntervalChildren({ children, intervalStyle }) {
60+
function IntervalChildren({ children, intervalStyle, onClick }) {
5961
if (children == null || children.length == 0) return null;
6062
return h(
6163
"div.children",
6264
children.map((d) => {
63-
return h(TimescaleBoxes, { interval: d, intervalStyle });
65+
return h(TimescaleBoxes, { interval: d, intervalStyle, onClick });
6466
})
6567
);
6668
}
@@ -72,8 +74,9 @@ function ensureIncreasingAgeRange(ageRange) {
7274
function TimescaleBoxes(props: {
7375
interval: NestedInterval;
7476
intervalStyle: IntervalStyleBuilder;
77+
onClick: (e: Event, interval: Interval) => void;
7578
}) {
76-
const { interval, intervalStyle } = props;
79+
const { interval, intervalStyle, onClick } = props;
7780
const { scale, orientation, levels, ageRange } = useTimescale();
7881
const { eag, lag, lvl } = interval;
7982

@@ -108,8 +111,8 @@ function TimescaleBoxes(props: {
108111
const className = slugify(name);
109112

110113
return h("div.interval", { className, style }, [
111-
h.if(lvl >= minLevel)(IntervalBox, { interval, intervalStyle }),
112-
h.if(lvl < maxLevel)(IntervalChildren, { children, intervalStyle }),
114+
h.if(lvl >= minLevel)(IntervalBox, { interval, intervalStyle, onClick }),
115+
h.if(lvl < maxLevel)(IntervalChildren, { children, intervalStyle, onClick }),
113116
]);
114117
}
115118

packages/timescale/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import classNames from "classnames";
88
import { useMemo } from "react";
99
import h from "./hyper";
1010

11-
type ClickHandler = (event: Event, age: number) => void;
11+
type ClickHandler = (event: Event, interval: any) => void;
1212

1313
export enum IncreaseDirection {
1414
UP_RIGHT = "up-right",
@@ -75,7 +75,7 @@ function Timescale(props: TimescaleProps) {
7575
axisProps = {},
7676
cursorPosition,
7777
cursorComponent = Cursor,
78-
onClick = () => {},
78+
onClick = null,
7979
intervalStyle,
8080
increaseDirection = IncreaseDirection.DOWN_LEFT,
8181
} = props;
@@ -85,7 +85,7 @@ function Timescale(props: TimescaleProps) {
8585
[rootInterval, intervals]
8686
);
8787

88-
const className = classNames(orientation, "increase-" + increaseDirection);
88+
const className = classNames(orientation, "increase-" + increaseDirection, onClick ? "clickable" : null);
8989
const length = absoluteAgeScale ? l ?? 6000 : null;
9090

9191
let ageRange2 = null;
@@ -114,8 +114,8 @@ function Timescale(props: TimescaleProps) {
114114
orientation,
115115
levels,
116116
},
117-
h(TimescaleContainer, { className, onClick }, [
118-
h(TimescaleBoxes, { interval: timescale, intervalStyle }),
117+
h(TimescaleContainer, { className }, [
118+
h(TimescaleBoxes, { interval: timescale, intervalStyle, onClick }),
119119
h.if(showAgeAxis)(AgeAxis, axisProps),
120120
h.if(cursorPosition != null)(cursorComponent, { age: cursorPosition }),
121121
])

packages/timescale/src/main.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,7 @@
125125
height: 2px;
126126
width: 100%;
127127
}
128+
129+
.clickable {
130+
cursor: pointer;
131+
}

packages/timescale/stories/main.stories.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const Horizontal = {
1717
orientation: TimescaleOrientation.HORIZONTAL,
1818
levels: [0, 5],
1919
absoluteAgeScale: false,
20+
onClick: (e, interval) => {
21+
console.log("Clicked interval:", interval);
22+
}
2023
},
2124
};
2225

packages/ui-components/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [unreleased]
4+
Added the following components:
5+
- SearchBar - general input field search bar
6+
- CreateCheckins - takes checkin data as input and creates checkins
7+
38
## [4.2.0] - 2025-04-09
49

510
- Updated `zustand` dependency
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.checkin
2+
background-color: var(--panel-background-color)
3+
color: black
4+
text-align: left
5+
border: solid var(--card-shadow-color) 1px
6+
padding: 6px 15px
7+
padding-top: 2px
8+
font-size: 14px
9+
color: var(--text-emphasized-color)
10+
margin-top: 10px
11+
cursor: pointer
12+
13+
&:hover
14+
border: solid var(--text-emphasized-color) 1px
15+
16+
.description
17+
padding: 0
18+
19+
h3
20+
color: var(--text-emphasized-color)
21+
22+
a
23+
color: black
24+
text-decoration: none
25+
26+
&:hover
27+
color: black
28+
29+
.star
30+
height: 15px
31+
32+
.checkin-header
33+
display: flex
34+
35+
.checkin-name
36+
font-size: 20px
37+
font-weight: 500
38+
color: #333
39+
margin-bottom: 0
40+
41+
.profile-pic
42+
height: 80px
43+
width: 80px
44+
border-radius: 50%
45+
display: inline-block
46+
margin-right: 10px
47+
48+
.box-header
49+
display: flex
50+
51+
.checkin-info
52+
display: grid
53+
margin: auto
54+
margin-left: 0
55+
margin-right: 0
56+
p
57+
padding: 0
58+
59+
h3, h4, p
60+
margin: 0
61+
62+
.checkin-link
63+
position: relative
64+
65+
.image-details
66+
position: absolute
67+
top: -150px
68+
left: 0
69+
right: 0
70+
bottom: 0
71+
display: flex
72+
justify-content: center
73+
align-items: center
74+
display: none
75+
color: white
76+
77+
.observation-img
78+
margin-top: 10px
79+
width: 100%
80+
height: 150px
81+
object-fit: cover
82+
border-radius: 2%
83+
84+
&:hover
85+
.observation-img
86+
-webkit-filter: brightness(70%)
87+
.image-details
88+
display: flex
89+
90+
.description
91+
margin-top: 10px
92+
93+
.no-image
94+
color: var(--panel-text)
95+
display: flex
96+
justify-content: center
97+
align-items: center
98+
gap: 10px
99+
marigin: 0
100+
101+
.details-image
102+
filter: var(--anti-img-color)
103+
104+
.checkin-footer
105+
display: flex
106+
justify-content: center
107+
108+
svg
109+
filter: var(--anti-img-color)
110+
111+
.likes-container
112+
display: grid
113+
grid-template-columns: 50% 50%
114+
width: 25%
115+
justify-content: end
116+
place-items: center
117+
118+
.comments-container
119+
display: grid
120+
grid-template-columns: 50% 50%
121+
width: 25%
122+
place-items: center
123+
124+
.observations-container
125+
display: grid
126+
grid-template-columns: 50% 50%
127+
width: 25%
128+
place-items: center
129+
130+
.details
131+
color: var(--text-emphasized-color)

0 commit comments

Comments
 (0)