1+ import { ComponentStory , ComponentMeta } from "@storybook/react" ;
2+ import h from "@macrostrat/hyper" ;
3+ import { InfiniteScrollView } from "../src/infinite-scroll" ;
4+
5+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
6+ export default {
7+ title : "UI components/Infinite scroll" ,
8+ component : InfiniteScrollView ,
9+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
10+ argTypes : { } ,
11+ } as ComponentMeta < typeof InfiniteScrollView > ;
12+
13+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
14+ const Template : ComponentStory < typeof InfiniteScrollView > = ( args ) =>
15+ h ( InfiniteScrollView , args ) ;
16+
17+ export const Primary = Template . bind ( { } ) ;
18+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
19+ Primary . args = {
20+ params : {
21+ combined_id : "gt.10" ,
22+ limit : 10 ,
23+ order : "combined_id.asc" ,
24+ } ,
25+ route : "https://dev.macrostrat.org/api/pg/strat_combined" ,
26+ getNextParams,
27+ initialItems : [
28+ {
29+ "concept_id" : 1 ,
30+ "id" : null ,
31+ "name" : "Aaron" ,
32+ "rank" : null ,
33+ "strat_names" : "Aaron" ,
34+ "strat_ids" : "60001" ,
35+ "all_names" : "Aaron,Aaron" ,
36+ "combined_id" : 1 ,
37+ "strat_ranks" : "Fm"
38+ } ,
39+ {
40+ "concept_id" : 2 ,
41+ "id" : null ,
42+ "name" : "Abbott" ,
43+ "rank" : null ,
44+ "strat_names" : null ,
45+ "strat_ids" : null ,
46+ "all_names" : "Abbott," ,
47+ "combined_id" : 2 ,
48+ "strat_ranks" : null
49+ } ,
50+ {
51+ "concept_id" : 3 ,
52+ "id" : null ,
53+ "name" : "Abel Gap" ,
54+ "rank" : null ,
55+ "strat_names" : "Abel Gap" ,
56+ "strat_ids" : "7637" ,
57+ "all_names" : "Abel Gap,Abel Gap" ,
58+ "combined_id" : 3 ,
59+ "strat_ranks" : "Fm"
60+ } ,
61+ {
62+ "concept_id" : 4 ,
63+ "id" : null ,
64+ "name" : "Aberdeen" ,
65+ "rank" : null ,
66+ "strat_names" : "Aberdeen,Aberdeen Sandstone" ,
67+ "strat_ids" : "60004,60005" ,
68+ "all_names" : "Aberdeen,Aberdeen,Aberdeen Sandstone" ,
69+ "combined_id" : 4 ,
70+ "strat_ranks" : "Mbr,Mbr"
71+ } ,
72+ {
73+ "concept_id" : 5 ,
74+ "id" : null ,
75+ "name" : "Abingdon" ,
76+ "rank" : null ,
77+ "strat_names" : "Abingdon Coal" ,
78+ "strat_ids" : "60006" ,
79+ "all_names" : "Abingdon,Abingdon Coal" ,
80+ "combined_id" : 5 ,
81+ "strat_ranks" : "Mbr"
82+ } ,
83+ {
84+ "concept_id" : 6 ,
85+ "id" : null ,
86+ "name" : "Able" ,
87+ "rank" : null ,
88+ "strat_names" : "Able" ,
89+ "strat_ids" : "6899" ,
90+ "all_names" : "Able,Able" ,
91+ "combined_id" : 6 ,
92+ "strat_ranks" : "Mbr"
93+ } ,
94+ {
95+ "concept_id" : 7 ,
96+ "id" : null ,
97+ "name" : "Abrahams Creek" ,
98+ "rank" : null ,
99+ "strat_names" : "Abrahams Creek" ,
100+ "strat_ids" : "60008" ,
101+ "all_names" : "Abrahams Creek,Abrahams Creek" ,
102+ "combined_id" : 7 ,
103+ "strat_ranks" : "Mbr"
104+ } ,
105+ {
106+ "concept_id" : 8 ,
107+ "id" : null ,
108+ "name" : "Absalona" ,
109+ "rank" : null ,
110+ "strat_names" : "Absalona,Absalona" ,
111+ "strat_ids" : "60009,10498" ,
112+ "all_names" : "Absalona,Absalona,Absalona" ,
113+ "combined_id" : 8 ,
114+ "strat_ranks" : "Fm,Fm"
115+ } ,
116+ {
117+ "concept_id" : 9 ,
118+ "id" : null ,
119+ "name" : "Accomac Canyon" ,
120+ "rank" : null ,
121+ "strat_names" : "Accomac Canyon Alloformation" ,
122+ "strat_ids" : "60011" ,
123+ "all_names" : "Accomac Canyon,Accomac Canyon Alloformation" ,
124+ "combined_id" : 9 ,
125+ "strat_ranks" : "Fm"
126+ } ,
127+ {
128+ "concept_id" : 10 ,
129+ "id" : null ,
130+ "name" : "Accomack" ,
131+ "rank" : null ,
132+ "strat_names" : "Accomack" ,
133+ "strat_ids" : "60012" ,
134+ "all_names" : "Accomack,Accomack" ,
135+ "combined_id" : 10 ,
136+ "strat_ranks" : "Mbr"
137+ }
138+ ] ,
139+ } ;
140+
141+ function getNextParams ( response , params ) {
142+ console . log ( "getNextParams" , response , params ) ;
143+ return {
144+ ...params ,
145+ combined_id : "gt." + response [ response . length - 1 ] . combined_id ,
146+ } ;
147+ }
0 commit comments