Skip to content
25 changes: 25 additions & 0 deletions packages/ui-components/src/postgrest-infinite-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
InputGroup,
Collapse,
Icon,
NonIdealState,
} from "@blueprintjs/core";
import styles from "./postgrest.module.sass";

Expand Down Expand Up @@ -45,6 +46,12 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
title: string;
children: React.ReactNode;
}>;
NonIdealStateParams?: {
title?: string;
description?: string;
icon?: string;
className?: string;
};
}

export function PostgRESTInfiniteScrollView(
Expand All @@ -70,6 +77,12 @@ export function PostgRESTInfiniteScrollView(
searchColumns = undefined,
group_key = undefined,
filter_threshold = 0,
NonIdealStateParams = {
title: "No Results",
description: "No results found",
icon: "search",
className: "no-results",
},
...rest
} = props;

Expand Down Expand Up @@ -289,6 +302,7 @@ export function PostgRESTInfiniteScrollView(
rest,
hideData,
GroupingComponent,
NonIdealStateParams,
})
: h(InfiniteScrollView, {
...rest,
Expand Down Expand Up @@ -333,6 +347,12 @@ interface GroupingProps {
rest?: any;
hideData?: boolean;
GroupingComponent?: React.ComponentType<GroupingProps>;
NonIdealStateParams?: {
title?: string;
description?: string;
icon?: string;
className?: string;
};
}

function Grouping(props: GroupingProps) {
Expand All @@ -347,8 +367,13 @@ function Grouping(props: GroupingProps) {
rest,
hideData,
GroupingComponent,
NonIdealStateParams,
} = props;

if (hideData) {
return h("div.non-ideal-container", h(NonIdealState, NonIdealStateParams));
}

return h("div.group-page", [
groups.map((group) => {
if (!group.value || !group.label) {
Expand Down
7 changes: 6 additions & 1 deletion packages/ui-components/src/postgrest.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
justify-content: space-between
align-items: center
gap: 1em
position: sticky
top: 0

.search-bar
flex: 1 1 auto
Expand All @@ -27,4 +29,7 @@
margin: 0

.child-container
padding-left: .2em
padding-left: .2em

.non-ideal-container
margin-top: 2em
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Grouping.args = {
id_key: "id",
filterable: true,
ascending: true,
route: "https://dev2.macrostrat.org/api/pg/autocomplete",
route: "https://dev.macrostrat.org/api/pg/autocomplete",
delay: 100,
searchColumns: [{ value: "name", label: "Name" }],
group_key: "type",
Expand All @@ -75,4 +75,10 @@ Grouping.args = {
]);
},
filter_threshold: 2, // Minimum characters to trigger filtering
NonIdealStateParams: {
title: "No data to display",
description: "Type at least 2 characters to filter results",
icon: "search",
className: "no-results",
},
};