|
1 |
| -import type { Interpolation, Theme } from "@emotion/react"; |
2 |
| -import { visuallyHidden } from "@mui/utils"; |
3 |
| -import { CodeExample } from "components/CodeExample/CodeExample"; |
4 |
| -import { Loader } from "components/Loader/Loader"; |
| 1 | +import { Button } from "components/Button/Button"; |
5 | 2 | import { SignInLayout } from "components/SignInLayout/SignInLayout";
|
| 3 | +import { Spinner } from "components/Spinner/Spinner"; |
6 | 4 | import { Welcome } from "components/Welcome/Welcome";
|
| 5 | +import { useClipboard } from "hooks"; |
| 6 | +import { CheckIcon, CopyIcon } from "lucide-react"; |
7 | 7 | import type { FC } from "react";
|
8 | 8 | import { Link as RouterLink } from "react-router-dom";
|
9 | 9 |
|
10 | 10 | export interface CliAuthPageViewProps {
|
11 | 11 | sessionToken?: string;
|
12 | 12 | }
|
13 | 13 |
|
14 |
| -const VISUALLY_HIDDEN_SPACE = " "; |
15 |
| - |
16 | 14 | export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => {
|
17 |
| - if (!sessionToken) { |
18 |
| - return <Loader fullscreen />; |
19 |
| - } |
| 15 | + const clipboard = useClipboard({ |
| 16 | + textToCopy: sessionToken ?? "", |
| 17 | + }); |
20 | 18 |
|
21 | 19 | return (
|
22 | 20 | <SignInLayout>
|
23 |
| - <Welcome className="pb-3">Session token</Welcome> |
| 21 | + <Welcome>Session token</Welcome> |
24 | 22 |
|
25 |
| - <p css={styles.instructions}> |
26 |
| - Copy the session token below and |
27 |
| - {/* |
28 |
| - * This looks silly, but it's a case where you want to hide the space |
29 |
| - * visually because it messes up the centering, but you want the space |
30 |
| - * to still be available to screen readers |
31 |
| - */} |
32 |
| - <span css={{ ...visuallyHidden }}>{VISUALLY_HIDDEN_SPACE}</span> |
33 |
| - <strong css={{ display: "block" }}>paste it in your terminal.</strong> |
| 23 | + <p className="m-0 text-center text-sm text-content-secondary leading-normal"> |
| 24 | + Copy the session token below and{" "} |
| 25 | + <strong className="block">paste it in your terminal.</strong> |
34 | 26 | </p>
|
35 | 27 |
|
36 |
| - <CodeExample code={sessionToken} secret /> |
37 |
| - |
38 |
| - <div css={{ paddingTop: 16 }}> |
39 |
| - <RouterLink to="/workspaces" css={styles.backLink}> |
40 |
| - Go to workspaces |
41 |
| - </RouterLink> |
| 28 | + <div className="flex flex-col items-center gap-1 w-full mt-4"> |
| 29 | + <Button |
| 30 | + className="w-full" |
| 31 | + size="lg" |
| 32 | + disabled={!sessionToken} |
| 33 | + onClick={clipboard.copyToClipboard} |
| 34 | + > |
| 35 | + {clipboard.showCopiedSuccess ? ( |
| 36 | + <CheckIcon /> |
| 37 | + ) : ( |
| 38 | + <Spinner loading={!sessionToken}> |
| 39 | + <CopyIcon /> |
| 40 | + </Spinner> |
| 41 | + )} |
| 42 | + {clipboard.showCopiedSuccess |
| 43 | + ? "Session token copied!" |
| 44 | + : "Copy session token"} |
| 45 | + </Button> |
| 46 | + |
| 47 | + <Button className="w-full" variant="subtle" asChild> |
| 48 | + <RouterLink to="/workspaces">Go to workspaces</RouterLink> |
| 49 | + </Button> |
42 | 50 | </div>
|
43 | 51 | </SignInLayout>
|
44 | 52 | );
|
45 | 53 | };
|
46 |
| - |
47 |
| -const styles = { |
48 |
| - instructions: (theme) => ({ |
49 |
| - fontSize: 16, |
50 |
| - color: theme.palette.text.secondary, |
51 |
| - paddingBottom: 8, |
52 |
| - textAlign: "center", |
53 |
| - lineHeight: 1.4, |
54 |
| - |
55 |
| - // Have to undo styling side effects from <Welcome> component |
56 |
| - marginTop: -24, |
57 |
| - }), |
58 |
| - |
59 |
| - backLink: (theme) => ({ |
60 |
| - display: "block", |
61 |
| - textAlign: "center", |
62 |
| - color: theme.palette.text.primary, |
63 |
| - textDecoration: "underline", |
64 |
| - textUnderlineOffset: 3, |
65 |
| - textDecorationColor: "hsla(0deg, 0%, 100%, 0.7)", |
66 |
| - paddingTop: 16, |
67 |
| - paddingBottom: 16, |
68 |
| - |
69 |
| - "&:hover": { |
70 |
| - textDecoration: "none", |
71 |
| - }, |
72 |
| - }), |
73 |
| -} satisfies Record<string, Interpolation<Theme>>; |
0 commit comments