Skip to content

Commit

Permalink
feat: add ad banners
Browse files Browse the repository at this point in the history
  • Loading branch information
bchmnn committed Jul 18, 2024
1 parent b9d27e1 commit cb7d027
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 17 deletions.
Binary file added service/frontend/public/assets/imagi-date.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service/frontend/public/assets/onlyflags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service/frontend/public/assets/onlyflags2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service/frontend/public/assets/pirate-say.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service/frontend/public/assets/sceam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service/frontend/public/assets/whatsscam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 24 additions & 17 deletions service/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import CreateDevenvButton from "@/components/create-devenv-button";
import CreateReplButton from "@/components/create-repl-button";
import RandomAdBanner from "@/components/random-ad-banner";
import { Button } from "@/components/ui/button";
import { useUserQuery } from "@/hooks/use-user-query";
import { RocketIcon } from "@radix-ui/react-icons";
Expand All @@ -11,24 +12,30 @@ export default function Page() {
const isAuthenticatedMode = !userQuery.isStale && userQuery.isSuccess;

return (
<main className="flex h-screen w-screen flex-col items-center p-24 justify-center space-y-5">
<div className="text-2xl italic">Want a clean /home?</div>
<div className="text-5xl font-bold">Use replme!</div>
<div>
Hack together your ideas in development environments, use a throwaway
shell - all in one place.
<main className="flex h-screen w-screen flex-row p-24">
<div className="flex h-full w-full flex-col items-center justify-center space-y-5 grow-0">
<div className="text-2xl italic">Want a clean /home?</div>
<div className="text-5xl font-bold">Use replme!</div>
<div>
Hack together your ideas in development environments, use a throwaway
shell - all in one place.
</div>
<div className="flex flex-row space-x-3 items-center">
{isAuthenticatedMode ? (
<CreateDevenvButton />
) : (
<a href="/register">
<Button>
<RocketIcon className="mr-2 h-4 w-4" /> REGISTER!
</Button>
</a>
)}
<CreateReplButton />
</div>
</div>
<div className="flex flex-row space-x-3 items-center">
{isAuthenticatedMode ? (
<CreateDevenvButton />
) : (
<a href="/register">
<Button>
<RocketIcon className="mr-2 h-4 w-4" /> REGISTER!
</Button>
</a>
)}
<CreateReplButton />

<div className="relative w-96 h-full">
<RandomAdBanner />
</div>
</main>
);
Expand Down
37 changes: 37 additions & 0 deletions service/frontend/src/components/random-ad-banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use client";
import Image from "next/image";
import { useEffect, useState } from "react";

const IMAGES = [
"/assets/imagi-date.png",
"/assets/onlyflags.png",
"/assets/onlyflags2.png",
"/assets/pirate-say.png",
"/assets/sceam.png",
"/assets/whatsscam.png",
];

function getRandomArbitrary(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

const RandomAdBanner = () => {
const [index, setIndex] = useState<number>();

useEffect(() => {
setIndex(getRandomArbitrary(0, IMAGES.length - 1));
}, []);

if (index === undefined) return <></>;

return (
<Image
className="object-contain"
src={IMAGES[index]}
fill={true}
alt="ad"
/>
);
};

export default RandomAdBanner;

0 comments on commit cb7d027

Please sign in to comment.