Skip to content

Commit

Permalink
twitter wrapped v1 fin.
Browse files Browse the repository at this point in the history
  • Loading branch information
sksuryan committed Dec 21, 2022
1 parent 4bccccb commit b69278b
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
Expand Down
27 changes: 16 additions & 11 deletions components/Cards/FavoritePeople.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@ interface Props {
const FavoritePeople: React.FC<Props> = ({ className, favPeople }) => {
return (
<div className={clsx(className, styles.container)}>
<h1>Some of your twitter favorites are...</h1>
<h1 style={{ textAlign: "left" }}>
Some of our favorite beta testers are...
</h1>
{favPeople.map((item) => (
<div key={item.id} className={styles.itemContainer}>
<div className={styles.profileImageWrapper}>
<Image
src={item.profile_image_url?.replace("_normal", "") ?? ""}
layout="fill"
quality={100}
className={styles.profileImage}
priority
alt="user image"
/>
</div>
{item.profile_image_url ? (
<div className={styles.profileImageWrapper}>
<Image
src={item.profile_image_url?.replace("_normal", "") ?? ""}
layout="fill"
quality={100}
className={styles.profileImage}
priority
alt="user image"
/>
</div>
) : null}

<div className={styles.detailContainer}>
<p>{item.name}</p>
<p>@{item.username}</p>
Expand Down
38 changes: 19 additions & 19 deletions components/DataLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ export const DataLayerProvider: React.FC<DataLayerProviderType> = ({
const router = useRouter();
const [data, setData] = useState<DataLayerType | undefined>(undefined);

useEffect(() => {
const localStorageData = localStorage.getItem("wrapped_data");
// useEffect(() => {
// const localStorageData = localStorage.getItem("wrapped_data");

try {
if (localStorageData) {
setData(JSON.parse(localStorageData));
}
} catch (err) {
// failed to parse data
}
}, []);
// try {
// if (localStorageData) {
// setData(JSON.parse(localStorageData));
// }
// } catch (err) {
// // failed to parse data
// }
// }, []);

useEffect(() => {
if (data && data.twitterReport && doItOnce.current) {
localStorage.setItem("wrapped_data", JSON.stringify(data));
router.push("/wrapped");
doItOnce.current = false;
} else if (data?.error) {
router.push("/error");
}
}, [data, router]);
// useEffect(() => {
// if (data && data.twitterReport && doItOnce.current) {
// localStorage.setItem("wrapped_data", JSON.stringify(data));
// router.push("/wrapped");
// doItOnce.current = false;
// } else if (data?.error) {
// router.push("/error");
// }
// }, [data, router]);

return (
<DataLayerContext.Provider value={[data, setData]}>
Expand Down
261 changes: 261 additions & 0 deletions components/TwitterWrappedWrapped.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
import { FC, useMemo, useRef } from "react";
import { UserV2 } from "twitter-api-v2";
import styles from "../styles/Wrapper.module.scss";
import BigNumberCard from "./Cards/BigNumberCard";
import FavoritePeople from "./Cards/FavoritePeople";
import TextCard from "./Cards/TextCard";
import Twemoji from "./Twemoji";

const ParaTextWithEmoji = ({
text,
emoji,
}: {
text: string;
emoji: string;
}) => {
return (
<p key={0}>
{text}
<span
style={{
verticalAlign: "middle",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
marginLeft: "4px",
}}
>
<Twemoji emoji={emoji} width={20} height={20} />
</span>
</p>
);
};

const favPeople: UserV2[] = [
{
id: "nitro",
name: "Nirupama Singh",
username: "nitropumaa",
},
{
id: "adi",
name: "Aditya Oberai",
username: "adityaoberai1",
},
{
id: "raghav",
name: "Raghav Agarwal",
username: "raghav1687",
},
{
id: "ranjit",
name: "Ranjit",
username: "ranjitzade",
},
{
id: "harsh",
name: "Harsh Suryan",
username: "hksuryan",
},
{
id: "mitra",
name: "Haimantika Mitra",
username: "HaimantikaM",
},
{
id: "Shlokzz",
name: "Shloka",
username: "shlokasspam",
},
];

const favPeople2: UserV2[] = [
{
id: "darshan",
name: "Darshan",
username: "SirusTweets",
},
{
id: "Shrankhla",
name: "Shrankhla Srivastava",
username: "shrankhla3",
},
{
id: "sree",
name: "Sreekaran",
username: "skxrxn",
},
{
id: "otc",
name: "Our Tech Community",
username: "OurTechComm",
},
];

const TwitterWrappedWrapped: FC = () => {
// TODO: remove swipe gesture, make it tap gesture instead
// TODO: add instagram story sort of indicator

const array = useMemo(
() => [
<TextCard
key={1}
className={styles.card}
text={[
<ParaTextWithEmoji
key={1}
text="Last couple of days were fun and nerve wracking at the same time. It was one hell of a ride for me & twitter wrapped."
emoji="🫣"
/>,
]}
/>,
<TextCard
key={2}
className={styles.card}
text={[
<ParaTextWithEmoji
key={1}
text="And with this this ride comes to an end so, how about one last wrapped?"
emoji="😍"
/>,
]}
/>,
<BigNumberCard
key={3}
className={styles.card}
data={[
{
bigNumber: "20K",
text: (
<ParaTextWithEmoji
text={`the number of times twitter wrapped was opened in first 24 hours.`}
emoji="🤩"
/>
),
},
]}
/>,
<BigNumberCard
key={4}
className={styles.card}
data={[
{
bigNumber: "100K",
text: (
<ParaTextWithEmoji
text={`the number of hits we completed in first 48 hours of the project.`}
emoji="😍"
/>
),
},
]}
/>,
<BigNumberCard
key={5}
className={styles.card}
data={[
{
bigNumber: "227K",
text: (
<ParaTextWithEmoji
text={`the number of hits we completed in first 60 hours of the project. STONKS`}
emoji="💯"
/>
),
},
]}
/>,
<BigNumberCard
key={6}
className={styles.card}
data={[
{
bigNumber: ">150K",
text: (
<ParaTextWithEmoji
text={`that's how many times the wrapped api successfully delivered the twitter wrapped.`}
emoji="🥵"
/>
),
},
]}
/>,
<BigNumberCard
key={7}
className={styles.card}
data={[
{
bigNumber: "23K",
text: (
<ParaTextWithEmoji
text={`the number of times the wrapped API errored out in last 60 hours`}
emoji="💀"
/>
),
},
]}
/>,
<BigNumberCard
key={8}
className={styles.card}
data={[
{
bigNumber: ">10,000,000",
text: (
<ParaTextWithEmoji
text={`that's the number of tweets that were fetched during the 60 hour run of twitter wrapped.`}
emoji="🤯"
/>
),
},
]}
/>,
<TextCard
key={99}
className={styles.card}
text={[
<ParaTextWithEmoji
key={0}
text="but you all know how some people are always way more special than others right?"
emoji="🥰"
/>,
]}
/>,
<FavoritePeople key={4} className={styles.card} favPeople={favPeople} />,
<FavoritePeople key={4} className={styles.card} favPeople={favPeople2} />,
<TextCard
key={108}
className={styles.card}
text={[
"Thank you all for your love & support <3",
<ParaTextWithEmoji
key={0}
text="And well that's all for this time around, see you next year? "
emoji="🫣"
/>,
]}
/>,
],
[]
);

return (
<>
<div className={styles.border}>
<div className={styles.container}>{array}</div>
</div>
<div className={styles.keepSwiping}>
<h3>keep swiping to continue...</h3>
</div>
<div
className="sign"
style={{ marginTop: "2rem", marginBottom: "0.75rem" }}
>
crafted with ❤️ by{" "}
<a href="https://twitter.com/0xSaurabh">@0xSaurabh</a>
</div>
</>
);
};

export default TwitterWrappedWrapped;
5 changes: 5 additions & 0 deletions pages/error.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GetServerSideProps } from "next";
import Head from "next/head";
import ErrorScreen from "../components/ErrorScreen";

Expand All @@ -12,4 +13,8 @@ const ErrorView = () => {
);
};

export const getServerSideProps: GetServerSideProps = async () => {
return { redirect: { destination: "/", permanent: true } };
};

export default ErrorView;
Loading

1 comment on commit b69278b

@vercel
Copy link

@vercel vercel bot commented on b69278b Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

twitter-wrapped – ./

twitter-wrapped-sksuryan.vercel.app
twitter-wrapped-git-main-sksuryan.vercel.app
twitter-wrapped-mu.vercel.app

Please sign in to comment.