-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ef84ea
commit 0530372
Showing
1 changed file
with
4 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,13 @@ | ||
import React, { useEffect } from "react"; | ||
import useStore from "@store"; | ||
import { Box } from "@components/base"; | ||
import { Main } from "@components/inc"; | ||
import React from "react"; | ||
import { MainLayout, Scaffold } from "@components/inc"; | ||
|
||
function App() { | ||
const setTheme = useStore((state) => state.setTheme); | ||
useEffect(() => { | ||
setTheme(); | ||
}, []); | ||
return ( | ||
<> | ||
<Main /> | ||
<ImageCache /> | ||
<MainLayout /> | ||
<Scaffold /> | ||
</> | ||
); | ||
} | ||
|
||
const ImageCache = () => { | ||
const [photos, setPhotos] = useStore((state) => [ | ||
state.photos, | ||
state.setPhotos, | ||
]); | ||
useEffect(() => { | ||
const today = new Date().toDateString(); | ||
const todayImage = photos.filter( | ||
(photo) => new Date(photo.for).toDateString() === today | ||
)[0]; | ||
if (photos.length === 0 || !todayImage) { | ||
setPhotos("mountains", false); | ||
} | ||
}, []); | ||
return ( | ||
<Box css={{ display: "none" }}> | ||
{photos?.map((photo, index) => { | ||
return ( | ||
<img | ||
key={index} | ||
src={photo.urls.raw + "&w=2048&q=80&auto=format"} | ||
alt="image" | ||
/> | ||
); | ||
})} | ||
</Box> | ||
); | ||
}; | ||
export default App; |