Skip to content

Commit 1021bac

Browse files
authored
Merge branch 'main' into postgrest-scroll-group
2 parents 55031e4 + 8eb6e09 commit 1021bac

Some content is hidden

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

43 files changed

+446
-733
lines changed

packages/data-components/src/field-locations/rockd-checkins/checkins.stories.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,27 @@ WithImage.args = {
306306
result: [checkinWithImage],
307307
mapRef: null,
308308
setInspectPosition: () => {},
309-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
309+
rockdCheckinURL: "https://dev.rockd.org/checkin",
310+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
311+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
310312
};
311313

312314
export const WithoutImage = Template.bind({});
313315
WithoutImage.args = {
314316
result: [checkinWithoutImage],
315317
mapRef: null,
316318
setInspectPosition: () => {},
317-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
319+
rockdCheckinURL: "https://dev.rockd.org",
320+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
321+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
318322
};
319323

320324
export const Multiple = Template.bind({});
321325
Multiple.args = {
322326
result: [checkinWithImage, checkinWithoutImage],
323327
mapRef: null,
324328
setInspectPosition: () => {},
325-
rockdAPIUrl: "https://dev.rockd.org/api/v2",
329+
rockdCheckinURL: "https://dev.rockd.org",
330+
rockdImageURL: "https://dev.rockd.org/api/v2/protected/image",
331+
rockdProfilePicURL: "https://dev.rockd.org/api/v2/protected/gravatar",
326332
};

packages/data-components/src/field-locations/rockd-checkins/index.ts

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,34 @@ export interface CheckinProps {
5252
}>;
5353
mapRef?: React.RefObject<mapboxgl.Map>;
5454
setInspectPosition?: (position: { lat: number; lng: number }) => void;
55-
rockdAPIUrl: string;
55+
rockdCheckinURL: string;
56+
rockdImageURL: string;
57+
rockdProfilePicURL: string;
5658
}
5759

5860
export function RockdWebsiteCheckinList(props: CheckinProps) {
5961
/** Checkin list component used in the Rockd website */
60-
const { result, mapRef, setInspectPosition, rockdAPIUrl } = props;
61-
const isDarkMode = useDarkMode().isEnabled;
62-
let checkins = [];
62+
const {
63+
result,
64+
mapRef,
65+
setInspectPosition,
66+
rockdCheckinURL,
67+
rockdImageURL,
68+
rockdProfilePicURL,
69+
} = props;
6370
const map = mapRef?.current;
6471
const len = result.length;
65-
const color = isDarkMode ? "white" : "black";
6672

6773
return h(
6874
result.map((checkin) => {
6975
// format rating
7076
let ratingArr = [];
7177
for (var i = 0; i < checkin.rating; i++) {
72-
ratingArr.push(
73-
h(Icon, { className: "star", icon: "star", style: { color } }),
74-
);
78+
ratingArr.push(h(Icon, { className: "star", icon: "star" }));
7579
}
7680

7781
for (var i = 0; i < 5 - checkin.rating; i++) {
78-
ratingArr.push(
79-
h(Icon, { className: "star", icon: "star-empty", style: { color } }),
80-
);
82+
ratingArr.push(h(Icon, { className: "star", icon: "star-empty" }));
8183
}
8284

8385
let imageView = null;
@@ -86,7 +88,7 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
8688
const imgSrc = getImageUrl(
8789
checkin.person_id,
8890
checkin.photo,
89-
rockdAPIUrl,
91+
rockdImageURL,
9092
);
9193
imageView = h([
9294
h("img.observation-img", {
@@ -98,7 +100,6 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
98100
h(Icon, {
99101
className: "details-image",
100102
icon: "arrow-right",
101-
style: { color },
102103
}),
103104
]),
104105
]);
@@ -108,7 +109,6 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
108109
h(Icon, {
109110
className: "details-image",
110111
icon: "arrow-right",
111-
style: { color },
112112
}),
113113
]);
114114
}
@@ -159,7 +159,10 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
159159
"h3.profile-pic",
160160

161161
h("img.profile-pic", {
162-
src: getProfilePicUrl(checkin.person_id, rockdAPIUrl),
162+
src: getProfilePicUrl(
163+
checkin.person_id,
164+
rockdProfilePicURL,
165+
),
163166
}),
164167
)
165168
: null,
@@ -182,35 +185,30 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
182185
"a",
183186
{
184187
className: "checkin-link",
185-
href: "/checkin/" + checkin.checkin_id,
188+
href: rockdCheckinURL + "/" + checkin.checkin_id,
186189
target: "_blank",
187190
},
188191
imageView,
189192
),
190193
h("div", { className: "checkin-footer" }, [
191194
h("div", { className: "likes-container" }, [
192195
h(Icon, {
193-
className: "likes-icon " + (isDarkMode ? "icon-dark-mode" : ""),
196+
className: "likes-icon",
194197
icon: "thumbs-up",
195-
style: { color },
196198
}),
197199
h("h3", { className: "likes" }, checkin.likes),
198200
]),
199201
h("div", { className: "observations-container" }, [
200202
h(Icon, {
201-
className:
202-
"observations-icon " + (isDarkMode ? "icon-dark-mode" : ""),
203+
className: "observations-icon",
203204
icon: "camera",
204-
style: { color },
205205
}),
206206
h("h3", { className: "likes" }, checkin.observations.length),
207207
]),
208208
h("div", { className: "comments-container" }, [
209209
h(Icon, {
210-
className:
211-
"comments-icon " + (isDarkMode ? "icon-dark-mode" : ""),
210+
className: "comments-icon",
212211
icon: "comment",
213-
style: { color },
214212
}),
215213
h("h3", { className: "comments" }, checkin.comments),
216214
]),
@@ -221,12 +219,10 @@ export function RockdWebsiteCheckinList(props: CheckinProps) {
221219
);
222220
}
223221

224-
function getImageUrl(person_id, photo_id, rockdAPIUrl) {
225-
return (
226-
rockdAPIUrl + "/protected/image/" + person_id + "/thumb_large/" + photo_id
227-
);
222+
function getImageUrl(person_id, photo_id, rockdImageURL) {
223+
return rockdImageURL + "/" + person_id + "/thumb_large/" + photo_id;
228224
}
229225

230-
function getProfilePicUrl(person_id, rockdAPIUrl) {
231-
return rockdAPIUrl + "/protected/gravatar/" + person_id;
226+
function getProfilePicUrl(person_id, rockdProfilePicURL) {
227+
return rockdProfilePicURL + "/" + person_id;
232228
}

packages/feedback-components/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ 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-
## [unreleased]
7+
## [1.1.8] - 2025-07-30
8+
9+
- On load, have any nodes matching autoselect input automically selected
10+
- View only bugs fixed
11+
12+
## [1.1.7] - 2025-07-25
13+
14+
- Can't select tree in view only mode
15+
- View matches on hover in view only mode
16+
17+
## [1.1.6] - 2025-07-24
18+
19+
- Fix view and match glitches
20+
21+
## [1.1.5] - 2025-07-24
822

923
- Simplified match logic
24+
- Added view only mode
1025

1126
## [1.1.4] - 2025-07-16
1227

packages/feedback-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/feedback-components",
3-
"version": "1.1.4",
3+
"version": "1.1.8",
44
"description": "",
55
"source": "src/index.ts",
66
"type": "module",

packages/feedback-components/src/feedback/edit-state.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ type TreeAction =
5353
| { type: "select-range"; payload: { ids: number[] } }
5454
| { type: "add-match"; payload: { id: number; payload: any } }
5555
| { type: "remove-match"; payload: { id: number } }
56-
| { type: "toggle-match-mode" };
56+
| { type: "toggle-match-mode" }
57+
| { type: "toggle-view-only" };
5758

5859
export type TreeDispatch = Dispatch<TreeAction>;
5960

@@ -62,15 +63,27 @@ export function useUpdatableTree(
6263
entityTypes: Map<number, EntityType>,
6364
viewOnly: boolean,
6465
matchMode: boolean,
66+
autoSelect: string[] = [],
6567
): [TreeState, TreeDispatch] {
6668
// Get the first entity type
6769
// issue: grabs second entity instead of selected one
6870
const type = entityTypes.values().next().value;
6971

72+
let selectedNodes = [];
73+
autoSelect = autoSelect.map((name) => name.toLowerCase());
74+
75+
if (autoSelect.length > 0) {
76+
// If autoSelect is provided, find the nodes with the matching names
77+
selectedNodes = initialTree
78+
.flatMap((node) => node.children ?? [])
79+
.filter((node) => autoSelect.includes(node.name.toLowerCase()))
80+
.map((node) => node.id);
81+
}
82+
7083
return useReducer(treeReducer, {
7184
initialTree,
7285
tree: initialTree,
73-
selectedNodes: [],
86+
selectedNodes,
7487
entityTypesMap: entityTypes,
7588
selectedEntityType: type,
7689
lastInternalId: 0,
@@ -96,6 +109,10 @@ function treeReducer(state: TreeState, action: TreeAction) {
96109
return { ...state, matchMode: !state.matchMode };
97110
}
98111

112+
if (action.type === "toggle-view-only") {
113+
return { ...state, viewOnly: !state.viewOnly, selectedNodes: [] };
114+
}
115+
99116
if (state.viewOnly) return viewMode(state, action);
100117

101118
if (state.matchMode) return matchMode(state, action);

packages/feedback-components/src/feedback/feedback.module.sass

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
& > svg
2828
width: 800px
2929

30-
.node
31-
cursor: pointer
32-
3330
circle
3431
border: 1px solid black
3532

@@ -167,3 +164,6 @@ mark
167164

168165
.close-btn
169166
cursor: pointer
167+
168+
.match-link
169+
padding: .5em

packages/feedback-components/src/feedback/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,19 @@ export function FeedbackComponent({
5757
allowOverlap,
5858
matchLinks,
5959
view = false,
60+
autoSelect = [],
6061
}) {
6162
const [viewOnly, setViewOnly] = useState(view);
6263
const [match, setMatchLinks] = useState(matchLinks);
63-
const matchMode = match !== null;
64+
const matchMode = match !== undefined;
6465

6566
// Get the input arguments
6667
const [state, dispatch] = useUpdatableTree(
6768
entities.map(processEntity) as any,
6869
entityTypes,
6970
viewOnly,
7071
matchMode,
72+
autoSelect,
7173
);
7274

7375
const {
@@ -93,6 +95,7 @@ export function FeedbackComponent({
9395
small: true,
9496
onValueChange() {
9597
setViewOnly(!viewOnly);
98+
dispatch({ type: "toggle-view-only" });
9699
},
97100
role: "toolbar",
98101
}),
@@ -145,6 +148,7 @@ export function FeedbackComponent({
145148
width,
146149
height,
147150
matchComponent,
151+
viewOnly,
148152
}),
149153
h.if(state.viewMode == "graph")(GraphView, {
150154
tree,
@@ -304,16 +308,23 @@ function countNodes(tree) {
304308
}
305309

306310
function ManagedSelectionTree(props) {
307-
const { selectedNodes, dispatch, tree, height, width, matchComponent } =
308-
props;
311+
const {
312+
selectedNodes,
313+
dispatch,
314+
tree,
315+
height,
316+
width,
317+
matchComponent,
318+
viewOnly,
319+
} = props;
309320

310321
const ref = useRef<TreeApi<TreeData>>();
311322
// Use a ref to track clicks (won't cause rerender)
312323
const clickedRef = useRef(false);
313324

314325
const _Node = useCallback(
315-
(props) => h(Node, { ...props, matchComponent }),
316-
[matchComponent],
326+
(props) => h(Node, { ...props, matchComponent, viewOnly }),
327+
[matchComponent, viewOnly],
317328
);
318329

319330
// Update Tree selection when selectedNodes change

packages/feedback-components/src/feedback/matches.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export function Matches({
2929
h(Divider),
3030
h(Switch, {
3131
label: "Match mode",
32-
checked: match !== null,
32+
checked: match !== undefined,
3333
onChange: (e) => {
34-
setMatchLinks(match === null ? matchLinks || {} : null);
34+
setMatchLinks(match === undefined ? matchLinks || {} : undefined);
3535
dispatch({ type: "toggle-match-mode" });
3636
},
3737
}),
@@ -178,7 +178,7 @@ interface MatchTagProps {
178178
setPayload?: (payload: Record<string, any>) => void;
179179
}
180180

181-
function MatchTag({ data, matchLinks, setPayload }: MatchTagProps) {
181+
export function MatchTag({ data, matchLinks, setPayload }: MatchTagProps) {
182182
if (!data || Object.keys(data).length === 0) return;
183183

184184
if (data.lith_id || data?.type === "lith") {

packages/feedback-components/src/feedback/node.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,32 @@ function isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {
4141
return false;
4242
}
4343

44-
function Node({ node, style, dragHandle, tree, matchComponent }: any) {
44+
function Node({
45+
node,
46+
style,
47+
dragHandle,
48+
tree,
49+
matchComponent,
50+
viewOnly,
51+
}: any) {
4552
let highlighted: boolean = isNodeHighlighted(node, tree);
4653
let active: boolean = isNodeActive(node, tree);
4754

48-
const dispatch = useTreeDispatch();
55+
console.log("viewOnly", viewOnly);
4956

50-
// console.log("Node render", node.data, highlighted, active);
57+
const dispatch = useTreeDispatch();
5158

5259
if (!node.data?.type) {
5360
node.data.type = { name: "lith", color: "rgb(107, 255, 91)" };
5461
}
5562

5663
return h(
57-
"div.node",
64+
"div.node" + (!viewOnly ? ".clickable" : ""),
5865
{ style, ref: dragHandle },
5966
h(EntityTag, {
6067
data: node.data,
61-
active,
62-
highlighted,
68+
active: viewOnly ? false : active,
69+
highlighted: viewOnly ? true : highlighted,
6370
matchComponent,
6471
onClickType() {
6572
dispatch({ type: "toggle-entity-type-selector" });

0 commit comments

Comments
 (0)