@@ -8,6 +8,7 @@ import { PreviewTable } from "./PreviewTable"
8
8
import splashImageSrc from "./assets/splash.png"
9
9
10
10
export function App ( ) {
11
+ const [ isLoading , setIsLoading ] = useState ( true )
11
12
const [ collections , setCollections ] = useState < Collection [ ] > ( [ ] )
12
13
const [ selectedCollection , setSelectedCollection ] = useState < Collection | null > ( null )
13
14
@@ -18,7 +19,11 @@ export function App() {
18
19
resizable : false ,
19
20
} )
20
21
21
- framer . getCollections ( ) . then ( setCollections )
22
+ Promise . all ( [ framer . getCollections ( ) , framer . getActiveCollection ( ) ] ) . then ( ( [ collections , activeCollection ] ) => {
23
+ setIsLoading ( false )
24
+ setCollections ( collections )
25
+ setSelectedCollection ( activeCollection )
26
+ } )
22
27
} , [ ] )
23
28
24
29
const exportCSV = async ( ) => {
@@ -64,29 +69,32 @@ export function App() {
64
69
return (
65
70
< div className = "export-collection" >
66
71
< div className = "preview-container" >
67
- < div className = { `preview-container-layer-a ${ selectedCollection ? "preview-container-layer-a--hidden " : "" } ` } >
72
+ < div className = { `preview-container-image ${ ! selectedCollection && ! isLoading ? "visible " : "" } ` } >
68
73
< div className = "empty-state" >
69
74
< img className = "empty-state-image" src = { splashImageSrc } alt = "" />
70
75
< p className = "empty-state-message" > Export all your CMS content to CSV files.</ p >
71
76
</ div >
72
77
</ div >
73
78
74
- { selectedCollection && (
75
- < div className = "preview-container-layer-b" >
76
- < PreviewTable collection = { selectedCollection } />
77
- </ div >
78
- ) }
79
+ < div className = { `preview-container-table ${ selectedCollection ? "visible" : "" } ` } >
80
+ { selectedCollection && < PreviewTable collection = { selectedCollection } /> }
81
+ </ div >
79
82
</ div >
80
83
81
84
< div className = "footer" >
82
- < select onChange = { selectCollection } className = { ! selectedCollection ? "footer-select footer-select--unselected" : "footer-select" } >
85
+ < select
86
+ onChange = { selectCollection }
87
+ className = { ! selectedCollection ? "footer-select footer-select--unselected" : "footer-select" }
88
+ >
83
89
< option selected disabled >
84
90
Select Collection…
85
91
</ option >
86
92
87
- { collections . map ( collection => {
88
- return < option selected = { collection . id === selectedCollection ?. id } > { collection . name } </ option >
89
- } ) }
93
+ { collections . map ( collection => (
94
+ < option key = { collection . id } selected = { collection . id === selectedCollection ?. id } >
95
+ { collection . name }
96
+ </ option >
97
+ ) ) }
90
98
</ select >
91
99
92
100
< div className = "footer-actions" >
0 commit comments