TwoColumnFullScreenLayout.tsx raw

   1  import { ChevronLeftIcon } from "lucide-react";
   2  import { useEffect, useState } from "react";
   3  import { Outlet, useLocation, useNavigate } from "react-router";
   4  import { AlbyHubLogo } from "src/components/icons/AlbyHubLogo";
   5  import { Button } from "src/components/ui/button.tsx";
   6  import { useInfo } from "src/hooks/useInfo";
   7  
   8  import AntonopoulosSVG from "public/images/quotes/antonopoulos.svg";
   9  import BackSVG from "public/images/quotes/back.svg";
  10  import FinneySVG from "public/images/quotes/finney.svg";
  11  import HayekSVG from "public/images/quotes/hayek.svg";
  12  import NakamotoSVG from "public/images/quotes/nakamoto.svg";
  13  import ObamaSVG from "public/images/quotes/obama.svg";
  14  import RolandSVG from "public/images/quotes/roland.svg";
  15  import WilsonSVG from "public/images/quotes/wilson.svg";
  16  
  17  const quotes = [
  18    {
  19      content: `This isn't about nation-states anymore. This isn't about who adopts
  20          bitcoin first or who adopts cryptocurrencies first, because the
  21          internet is adopting cryptocurrencies, and the internet is the world's
  22          largest economy. It is the first transnational economy, and it needs a
  23          transnational currency.`,
  24      author: "Andreas M. Antonopoulos",
  25      imageUrl: AntonopoulosSVG,
  26    },
  27    {
  28      content: `It might make sense just to get some in case it catches on. If enough people think the same way, that becomes a self fulfilling prophecy. Once it gets bootstrapped, there are so many applications if you could effortlessly pay a few cents to a website as easily as dropping coins in a vending machine.`,
  29      author: "Satoshi Nakamoto",
  30      imageUrl: NakamotoSVG,
  31    },
  32    {
  33      content: `Since we're all rich with bitcoins, or we will be once they're worth a million dollars like everyone expects, we ought to put some of this unearned wealth to good use.`,
  34      author: "Hal Finney",
  35      imageUrl: FinneySVG,
  36    },
  37    {
  38      content: `I don't believe we shall ever have a good money again before we take the thing out of the hands of government, that is, we can't take it violently out of the hands of government, all we can do is by some sly roundabout way introduce something that they can't stop.`,
  39      author: "Friedrich August von Hayek",
  40      imageUrl: HayekSVG,
  41    },
  42    {
  43      content: `Bitcoin is what they fear it is.`,
  44      author: "Cody Wilson",
  45      imageUrl: WilsonSVG,
  46    },
  47    {
  48      content: `If in fact you can't crack that at all, government can't get in then —everybody's walking around with a Swiss bank account in their pocket.`,
  49      author: "Barack Obama",
  50      imageUrl: ObamaSVG,
  51    },
  52    {
  53      content: `Bitcoin is the new wonder of the world, more work and human ingenuity, than went into the great pyramids of Egypt. The biggest computation ever done, a digital monument, a verifiable artefact of digital gold - the foundation of a new digital age.`,
  54      author: "Adam Back",
  55      imageUrl: BackSVG,
  56    },
  57    {
  58      content: `We who choose Bitcoin, are pioneers of a new world. A world filled with freedom, hope and peace.`,
  59      author: "Roland",
  60      imageUrl: RolandSVG,
  61    },
  62  ];
  63  
  64  export default function TwoColumnFullScreenLayout() {
  65    const { data: info } = useInfo();
  66    const navigate = useNavigate();
  67    const { pathname } = useLocation();
  68    const [quote, setQuote] = useState(
  69      // eslint-disable-next-line react-hooks/purity
  70      quotes[Math.floor(Math.random() * quotes.length)]
  71    );
  72  
  73    // Change quote on route changes
  74    useEffect(() => {
  75      setQuote(quotes[Math.floor(Math.random() * quotes.length)]);
  76    }, [pathname]);
  77  
  78    return (
  79      <div className="w-full lg:grid lg:h-screen lg:grid-cols-2 items-stretch text-background">
  80        <div className="hidden lg:flex flex-col bg-foreground justify-end p-10 gap-2 relative">
  81          <img
  82            src={quote.imageUrl}
  83            alt={quote.author}
  84            className="absolute inset-0 w-full h-full object-cover object-top opacity-30 dark:opacity-20 pointer-events-none"
  85          />
  86          <div className="flex-1 w-full h-full flex flex-col">
  87            <div className="flex flex-row justify-between items-center">
  88              <AlbyHubLogo monochrome className="h-8" />
  89              {info?.version && (
  90                <p className="text-sm text-muted-foreground">{info.version}</p>
  91              )}
  92            </div>
  93          </div>
  94          <div className="flex flex-row gap-5">
  95            <div className="flex flex-col justify-center">
  96              <p className="text-muted-foreground text-lg mb-2">
  97                {quote.content}
  98              </p>
  99              <p className="text-background text-sm">{quote.author}</p>
 100            </div>
 101          </div>
 102        </div>
 103        <div className="flex items-center justify-center py-12 text-foreground relative">
 104          {pathname.startsWith("/setup") &&
 105            !pathname.startsWith("/setup/finish") && (
 106              // show the back button on setup pages, except the setup finish page
 107              <Button
 108                type="button"
 109                variant="outline"
 110                onClick={() => {
 111                  navigate(-1);
 112                }}
 113                className="top-4 left-4 md:top-10 md:left-10 absolute mr-4"
 114              >
 115                <ChevronLeftIcon />
 116                Back
 117              </Button>
 118            )}
 119          <Outlet />
 120        </div>
 121      </div>
 122    );
 123  }
 124