-
Notifications
You must be signed in to change notification settings - Fork 894
refactor: update cli auth page design #17915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,53 @@ | ||
import type { Interpolation, Theme } from "@emotion/react"; | ||
import { visuallyHidden } from "@mui/utils"; | ||
import { CodeExample } from "components/CodeExample/CodeExample"; | ||
import { Loader } from "components/Loader/Loader"; | ||
import { Button } from "components/Button/Button"; | ||
import { SignInLayout } from "components/SignInLayout/SignInLayout"; | ||
import { Spinner } from "components/Spinner/Spinner"; | ||
import { Welcome } from "components/Welcome/Welcome"; | ||
import { useClipboard } from "hooks"; | ||
import { CheckIcon, CopyIcon } from "lucide-react"; | ||
import type { FC } from "react"; | ||
import { Link as RouterLink } from "react-router-dom"; | ||
|
||
export interface CliAuthPageViewProps { | ||
sessionToken?: string; | ||
} | ||
|
||
const VISUALLY_HIDDEN_SPACE = " "; | ||
|
||
export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => { | ||
if (!sessionToken) { | ||
return <Loader fullscreen />; | ||
} | ||
const clipboard = useClipboard({ | ||
textToCopy: sessionToken ?? "", | ||
}); | ||
|
||
return ( | ||
<SignInLayout> | ||
<Welcome className="pb-3">Session token</Welcome> | ||
<Welcome>Session token</Welcome> | ||
|
||
<p css={styles.instructions}> | ||
Copy the session token below and | ||
{/* | ||
* This looks silly, but it's a case where you want to hide the space | ||
* visually because it messes up the centering, but you want the space | ||
* to still be available to screen readers | ||
*/} | ||
<span css={{ ...visuallyHidden }}>{VISUALLY_HIDDEN_SPACE}</span> | ||
<p className="m-0 text-center text-sm text-content-secondary leading-normal"> | ||
Copy the session token below and{" "} | ||
<strong css={{ display: "block" }}>paste it in your terminal.</strong> | ||
</p> | ||
|
||
<CodeExample code={sessionToken} secret /> | ||
|
||
<div css={{ paddingTop: 16 }}> | ||
<RouterLink to="/workspaces" css={styles.backLink}> | ||
Go to workspaces | ||
</RouterLink> | ||
<div className="flex flex-col items-center gap-1 w-full mt-4"> | ||
<Button | ||
className="w-full" | ||
size="lg" | ||
disabled={!sessionToken} | ||
onClick={clipboard.copyToClipboard} | ||
> | ||
{clipboard.showCopiedSuccess ? ( | ||
<CheckIcon /> | ||
) : ( | ||
<Spinner loading={!sessionToken}> | ||
<CopyIcon /> | ||
</Spinner> | ||
)} | ||
{clipboard.showCopiedSuccess | ||
? "Session token copied!" | ||
: "Copy session token"} | ||
</Button> | ||
|
||
<Button className="w-full" variant="subtle" asChild> | ||
<RouterLink to="/workspaces">Go to workspaces</RouterLink> | ||
</Button> | ||
</div> | ||
</SignInLayout> | ||
); | ||
}; | ||
|
||
const styles = { | ||
instructions: (theme) => ({ | ||
fontSize: 16, | ||
color: theme.palette.text.secondary, | ||
paddingBottom: 8, | ||
textAlign: "center", | ||
lineHeight: 1.4, | ||
|
||
// Have to undo styling side effects from <Welcome> component | ||
marginTop: -24, | ||
}), | ||
|
||
backLink: (theme) => ({ | ||
display: "block", | ||
textAlign: "center", | ||
color: theme.palette.text.primary, | ||
textDecoration: "underline", | ||
textUnderlineOffset: 3, | ||
textDecorationColor: "hsla(0deg, 0%, 100%, 0.7)", | ||
paddingTop: 16, | ||
paddingBottom: 16, | ||
|
||
"&:hover": { | ||
textDecoration: "none", | ||
}, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this can be swapped over to Tailwind, too:
className="block"