Skip to content

Commit 6607a5a

Browse files
committed
Factor out CliAuth token component
1 parent 87fc9e2 commit 6607a5a

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Paper from "@material-ui/core/Paper"
2+
import Typography from "@material-ui/core/Typography"
3+
import { makeStyles } from "@material-ui/core/styles"
4+
import React from "react"
5+
import { CodeExample } from "../CodeExample"
6+
7+
export interface CliAuthTokenProps {
8+
sessionToken: string
9+
}
10+
11+
export const CliAuthToken: React.FC<CliAuthTokenProps> = ({ sessionToken }) => {
12+
const styles = useStyles()
13+
return (
14+
<Paper className={styles.container}>
15+
<Typography className={styles.title}>Session Token</Typography>
16+
<CodeExample code={sessionToken} />
17+
</Paper>
18+
)
19+
}
20+
21+
const useStyles = makeStyles((theme) => ({
22+
title: {
23+
marginBottom: theme.spacing(2),
24+
},
25+
container: {
26+
maxWidth: "680px",
27+
padding: theme.spacing(2),
28+
},
29+
}))

site/components/SignIn/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from "./CliAuthToken"
12
export * from "./SignInForm"

site/pages/cli-auth.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import Paper from "@material-ui/core/Paper"
2-
import Typography from "@material-ui/core/Typography"
31
import { makeStyles } from "@material-ui/core/styles"
42
import React, { useEffect, useState } from "react"
53
import { getApiKey } from "../api"
6-
import { CodeExample } from "../components/CodeExample"
4+
import { CliAuthToken } from "../components/SignIn"
75

86
import { FullScreenLoader } from "../components/Loader/FullScreenLoader"
97
import { useUser } from "../contexts/UserContext"
@@ -28,29 +26,19 @@ const CliAuthenticationPage: React.FC = () => {
2826

2927
return (
3028
<div className={styles.root}>
31-
<Paper className={styles.container}>
32-
<Typography className={styles.title}>Session Token</Typography>
33-
<CodeExample code={apiKey} />
34-
</Paper>
29+
<CliAuthToken sessionToken={apiKey} />
3530
</div>
3631
)
3732
}
3833

3934
const useStyles = makeStyles((theme) => ({
4035
root: {
41-
width: "100vh",
42-
height: "100vw",
36+
width: "100vw",
37+
height: "100vh",
4338
display: "flex",
4439
justifyContent: "center",
4540
alignItems: "center",
4641
},
47-
title: {
48-
marginBottom: theme.spacing(2),
49-
},
50-
container: {
51-
maxWidth: "680px",
52-
padding: theme.spacing(2),
53-
},
5442
}))
5543

5644
export default CliAuthenticationPage

0 commit comments

Comments
 (0)