Commit f596260a authored by Grant's avatar Grant
Browse files

update the login prompt (fediverse-auth rft)

parent b06f9f22
Loading
Loading
Loading
Loading
Loading
+10 −57
Original line number Diff line number Diff line
import { Link, ModalBody, ModalFooter } from "@heroui/react";
import { useCallback, useState } from "react";
import { useCallback } from "react";

import { type DialogData } from "../../contexts/DialogContext";
import { RECOMMENDED_INSTANCES } from "../../lib/constants";
import { Button } from "../core/Button";

export const Normal = ({
@@ -10,8 +9,6 @@ export const Normal = ({
}: {
  state: DialogData<"LOGIN_INFO"> & { mode: "NORMAL" };
}) => {
  const [step, setStep] = useState<"WELCOME" | "NEW">("WELCOME");

  const WelcomeStep = useCallback(
    () => (
      <>
@@ -63,66 +60,22 @@ export const Normal = ({
        </p>
      </>
    ),
    []
  );

  const NewStep = useCallback(
    () => (
      <>
        <p>To get started on the Fediverse, you'll need an account</p>
        <p>
          The group behind Canvas,{" "}
          <Link href="https://sc07.com" target="_blank">
            sc07
          </Link>
          , hosts a couple Fediverse services but you aren't limited to using
          one of those
        </p>
        <strong>Recommended Instances:</strong>
        <ul className="list-disc ml-3">
          {RECOMMENDED_INSTANCES.map((instance) => (
            <li key={instance.name}>
              <Link href={instance.url} target="_blank">
                {instance.name}
              </Link>{" "}
              ({instance.software.name}, {instance.software.like})
            </li>
          ))}
          <li>
            <Link href="https://fedidb.com/welcome" target="_blank">
              Explore more options
            </Link>
          </li>
        </ul>
        <strong>Return to this page after registering an account</strong>
      </>
    ),
    []
    [],
  );

  return (
    <>
      <ModalBody>
        {step === "WELCOME" && <WelcomeStep />}
        {step === "NEW" && <NewStep />}
        <WelcomeStep />
      </ModalBody>
      <ModalFooter>
        {step === "WELCOME" && (
          <>
            <Button onPress={() => setStep("NEW")}>I'm new here</Button>
        {/* we have both here to avoid confusing people */}
        <Button as={Link} href={state.url}>
              I'm already a part of the Fediverse
          Register
        </Button>
          </>
        )}
        {step === "NEW" && (
          <>
            <Button onPress={() => setStep("WELCOME")}>Back</Button>
            <Button as={Link} href={state.url} color="primary">
              I have an account now
        <Button as={Link} href={state.url}>
          Login
        </Button>
          </>
        )}
      </ModalFooter>
    </>
  );
+0 −56
Original line number Diff line number Diff line
/**
 * Instances listed here must work with fediverse-auth out of the box
 *
 * @see https://sc07.dev/sc07/fediverse-auth
 * @see https://auth-demo.fediverse.events
 */
export const RECOMMENDED_INSTANCES: IRecommendedInstance[] = [
  {
    sc07: true,
    name: "grants.cafe",
    url: "https://grants.cafe",
    software: {
      name: "Mastodon",
      like: "microblogging",
    },
  },
  {
    sc07: true,
    name: "toast.ooo",
    url: "https://toast.ooo",
    software: {
      name: "Lemmy",
      like: "forum-like",
    },
  },
  {
    name: "bytes.programming.dev",
    url: "https://bytes.programming.dev",
    software: {
      name: "Iceshrimp",
      like: "microblogging",
    },
  },
  {
    name: "programming.dev",
    url: "https://programming.dev",
    software: {
      name: "Lemmy",
      like: "forum-like",
    },
  },
];

const MATRIX_VIA = ["fediverse.ooo", "aftermath.gg", "matrix.org"]
  .map((via) => "via=" + via)
  .join("&");
@@ -52,16 +9,3 @@ export const MATRIX_INVITE = `https://matrix.to/#/${MATRIX_ALIAS}?${MATRIX_VIA}`
 * @see https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2312-matrix-uri.md
 */
export const MATRIX_URL = `matrix:r/${MATRIX_ALIAS.slice(1)}?${MATRIX_VIA}`;

interface IRecommendedInstance {
  /**
   * is this instance hosted by sc07?
   */
  sc07?: true;
  name: string;
  url: `https://${string}`;
  software: {
    name: string;
    like: string;
  };
}