Skip to content

Commit def6a79

Browse files
committed
Select the active collection by default
1 parent d6ec7ae commit def6a79

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

plugins/cms-export/src/App.css

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,14 @@
6969
height: 100%;
7070
}
7171

72-
.preview-container-layer-a,
73-
.preview-container-layer-b {
72+
.preview-container-image,
73+
.preview-container-table {
7474
position: absolute;
7575
inset: 0;
76+
opacity: 0;
77+
transition: opacity 300ms;
7678
}
7779

78-
.preview-container-layer-a--hidden {
79-
animation: fade-in 300ms forwards reverse linear;
80-
}
81-
82-
.preview-container-layer-b {
83-
animation: fade-in 300ms forwards linear;
84-
}
85-
86-
@keyframes fade-in {
87-
from { opacity: 0; }
88-
to { opacity: 1; }
80+
.visible {
81+
opacity: 1;
8982
}

plugins/cms-export/src/App.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { PreviewTable } from "./PreviewTable"
88
import splashImageSrc from "./assets/splash.png"
99

1010
export function App() {
11+
const [isLoading, setIsLoading] = useState(true)
1112
const [collections, setCollections] = useState<Collection[]>([])
1213
const [selectedCollection, setSelectedCollection] = useState<Collection | null>(null)
1314

@@ -18,7 +19,11 @@ export function App() {
1819
resizable: false,
1920
})
2021

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+
})
2227
}, [])
2328

2429
const exportCSV = async () => {
@@ -64,29 +69,32 @@ export function App() {
6469
return (
6570
<div className="export-collection">
6671
<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" : ""}`}>
6873
<div className="empty-state">
6974
<img className="empty-state-image" src={splashImageSrc} alt="" />
7075
<p className="empty-state-message">Export all your CMS content to CSV files.</p>
7176
</div>
7277
</div>
7378

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>
7982
</div>
8083

8184
<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+
>
8389
<option selected disabled>
8490
Select Collection…
8591
</option>
8692

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+
))}
9098
</select>
9199

92100
<div className="footer-actions">

0 commit comments

Comments
 (0)