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

Commit

Permalink
feat: improve social page (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alezco authored Aug 31, 2020
1 parent c5943f2 commit 89e865d
Showing 1 changed file with 36 additions and 9 deletions.
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

0 comments on commit 89e865d

Please sign in to comment.