Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

feat: improve social page #47

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions src/pages/social.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
import { Box } from "@material-ui/core";
import React, { FC } from "react";
import { useTheme } from "@material-ui/core";
import Box from "@material-ui/core/Box";
import CircularProgress from "@material-ui/core/CircularProgress";
import Grid from "@material-ui/core/Grid";
import React, { FC, useCallback, useState } from "react";
import TweetEmbed from "react-tweet-embed";

import SEO from "../components/seo";
import { tweetIds } from "../display-data/tweets-data";
import Layout from "../layout";

const Social: FC = () => {
const theme = useTheme();

const [isLoaded, setIsLoaded] = useState(false);

const onTweetLoad = useCallback(() => {
setIsLoaded(true);
}, [setIsLoaded]);

return (
<Layout>
<SEO title="Social" />
<Box>
{!isLoaded && (
<Box
display="flex"
flexDirection="column"
justifyContent="center"
alignItems="center"
height="100%"
width="100%"
>
<CircularProgress />
<div>Chargement des tweets en cours...</div>
</Box>
)}
<Grid container spacing={1}>
{tweetIds.map((tweet: string, index: number) => (
<TweetEmbed
key={`${tweet}-${index}`}
id={tweet}
placeholder={"Chargement du tweet en cours..."}
/>
<Grid key={`${tweet}-${index}`} item md={6}>
<TweetEmbed
id={tweet}
onTweetLoadSuccess={onTweetLoad}
onTweetLoadError={onTweetLoad}
options={{ theme: theme.palette.type }}
/>
</Grid>
))}
</Box>
</Grid>
</Layout>
);
};
Expand Down