Skip to content

Commit

Permalink
fix: removed image fetches
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Victor committed Jan 31, 2023
1 parent 2d94d3b commit 38c6b5e
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/components/inc/GalleryTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const GalleryTabs = () => {
useState<typeof galleryTabs[number]["value"]>("cloud");

return (
<TabRoot defaultValue={activeTab}>
<TabRoot defaultValue={activeTab} css={{ maxWidth: "100%" }}>
<TabList asChild>
<ScrollArea>
<ScrollArea orientation="horizontal" css={{}}>
<Flex gap="1" css={{ pb: "$2" }}>
{galleryTabs.map(({ value, name }) => {
return (
Expand All @@ -66,47 +66,26 @@ const GalleryTabs = () => {
</TabList>
<TagInput />
<Tabs.Content value="cloud">
<GalleryContent tags={["tags"]} />
<GalleryContent />
</Tabs.Content>
<Tabs.Content value="2">hey</Tabs.Content>
</TabRoot>
);
};

const GalleryContent = ({ tags }: { tags: string[] }) => {
const GalleryContent = () => {
const [loading, setLoading] = useState(true);
const getPhotos = useStore((state) => state.getPhotos);
const [images, setImages] = useLocalStorage<Random[]>(
"gallery content",
undefined
);

React.useEffect(() => {
getPhotos(10)
.then((data) => {
setLoading(false);
setImages(data);
})
.catch(() => {
console.log("you need mobile data to get new images");
});
}, [tags]);
return (
<ScrollArea>
<Grid columns={{ "@initial": 1, "@lg": 2 }} gap="2">
{loading
? Array.from({ length: 10 }).map((_, i) => {
return <Skeleton key={i} />;
})
: images!.map((image, i) => {
return (
<Skeleton
as={"img"}
src={`${image.urls.raw}&w=240&q=70&auto=format`}
key={i}
/>
);
})}
{Array.from({ length: 10 }).map((_, i) => {
return <Skeleton key={i} />;
})}
</Grid>
</ScrollArea>
);
Expand Down

0 comments on commit 38c6b5e

Please sign in to comment.