diff --git a/packages/ui-components/src/postgrest-infinite-scroll.ts b/packages/ui-components/src/postgrest-infinite-scroll.ts index 2acac8ae..00c078c7 100644 --- a/packages/ui-components/src/postgrest-infinite-scroll.ts +++ b/packages/ui-components/src/postgrest-infinite-scroll.ts @@ -9,6 +9,7 @@ import { InputGroup, Collapse, Icon, + NonIdealState, } from "@blueprintjs/core"; import styles from "./postgrest.module.sass"; @@ -45,6 +46,12 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps { title: string; children: React.ReactNode; }>; + NonIdealStateParams?: { + title?: string; + description?: string; + icon?: string; + className?: string; + }; } export function PostgRESTInfiniteScrollView( @@ -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; @@ -289,6 +302,7 @@ export function PostgRESTInfiniteScrollView( rest, hideData, GroupingComponent, + NonIdealStateParams, }) : h(InfiniteScrollView, { ...rest, @@ -333,6 +347,12 @@ interface GroupingProps { rest?: any; hideData?: boolean; GroupingComponent?: React.ComponentType; + NonIdealStateParams?: { + title?: string; + description?: string; + icon?: string; + className?: string; + }; } function Grouping(props: GroupingProps) { @@ -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) { diff --git a/packages/ui-components/src/postgrest.module.sass b/packages/ui-components/src/postgrest.module.sass index fa306f08..a6cf5d9c 100644 --- a/packages/ui-components/src/postgrest.module.sass +++ b/packages/ui-components/src/postgrest.module.sass @@ -4,6 +4,8 @@ justify-content: space-between align-items: center gap: 1em + position: sticky + top: 0 .search-bar flex: 1 1 auto @@ -27,4 +29,7 @@ margin: 0 .child-container - padding-left: .2em \ No newline at end of file + padding-left: .2em + +.non-ideal-container + margin-top: 2em \ No newline at end of file diff --git a/packages/ui-components/stories/postgrest-infinite-scroll.stories.ts b/packages/ui-components/stories/postgrest-infinite-scroll.stories.ts index b35ddf82..c8a23eac 100644 --- a/packages/ui-components/stories/postgrest-infinite-scroll.stories.ts +++ b/packages/ui-components/stories/postgrest-infinite-scroll.stories.ts @@ -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", @@ -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", + }, };