-
Notifications
You must be signed in to change notification settings - Fork 2
Adds custom signin page #294
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 all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ba6530b
Reduces exported auth types
simonbs ad64c35
Installs Font Awesome brand icons
simonbs c51686d
Adds custom sign in page
simonbs 8bc05f1
Merge branch 'develop' into enhancement/custom-signin-page
simonbs 9b57fe9
Increases size required for two columns
simonbs 67eff14
Decreases padding on small screens
simonbs 4db8422
Fixes mobile display
simonbs 5a0817c
Increases padding of GitHub button
simonbs da81b8c
Updates login screenshot
simonbs 6a40f50
Removes debug log
simonbs e510020
Fixes linting errors
simonbs 41c1db0
Merge branch 'develop' into enhancement/custom-signin-page
simonbs 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,3 +1,3 @@ | ||
| import { auth } from "@/composition" | ||
| import { authHandlers } from "@/composition" | ||
|
|
||
| export const { GET, POST } = auth.handlers | ||
| export const { GET, POST } = authHandlers |
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 |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| import Image from "next/image" | ||
| import Link from "next/link" | ||
| import { Box, Button, Stack, Typography } from "@mui/material" | ||
| import { signIn } from "@/composition" | ||
| import { env } from "@/common" | ||
| import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" | ||
| import { faGithub } from "@fortawesome/free-brands-svg-icons" | ||
| import SignInTexts from "@/features/auth/view/SignInTexts" | ||
|
|
||
| const SITE_NAME = env.getOrThrow("NEXT_PUBLIC_SHAPE_DOCS_TITLE") | ||
| const HELP_URL = env.get("NEXT_PUBLIC_SHAPE_DOCS_HELP_URL") | ||
|
|
||
| export default async function SignInPage() { | ||
| return ( | ||
| <Box display="flex" height="100vh"> | ||
| <InfoColumn/> | ||
| <SignInColumn/> | ||
| </Box> | ||
| ) | ||
| } | ||
|
|
||
| const InfoColumn = () => { | ||
| return ( | ||
| <Box | ||
| flex={1} | ||
| sx={{ display: { xs: "none", sm: "none", md: "flex" } }} | ||
| alignItems="center" | ||
| bgcolor="#000" | ||
| color="#fff" | ||
| > | ||
| <SignInTexts /> | ||
| </Box> | ||
| ) | ||
| } | ||
|
|
||
| const SignInColumn = () => { | ||
| const title = `Get started with ${SITE_NAME}` | ||
| return ( | ||
| <Box | ||
| flex={1} | ||
| display="flex" | ||
| flexDirection="column" | ||
| justifyContent="space-between" | ||
| alignItems="center" | ||
| bgcolor="#fff" | ||
| > | ||
| <Box display="flex" flex={1} justifyContent="center" alignItems="center"> | ||
| <Stack direction="column" sx={{ | ||
| alignItems: { xs: "center", sm: "center", md: "flex-start" }, | ||
| padding: 4 | ||
| }}> | ||
| <Box sx={{ marginBottom: 8 }}> | ||
| <Image | ||
| src="/images/logo.png" | ||
| alt={`${SITE_NAME} logo`} | ||
| width={150} | ||
| height={171} | ||
| priority={true} | ||
| /> | ||
| </Box> | ||
| <Typography variant="h6" sx={{ | ||
| display: { xs: "flex", sm: "flex", md: "none" }, | ||
| marginBottom: 3, | ||
| textAlign: "center" | ||
| }}> | ||
| {title} | ||
| </Typography> | ||
| <Typography variant="h4" sx={{ | ||
| display: { xs: "none", sm: "none", md: "flex" }, | ||
| marginBottom: 3 | ||
| }}> | ||
| {title} | ||
| </Typography> | ||
| <SignInWithGitHub /> | ||
| </Stack> | ||
| </Box> | ||
| <Box sx={{ marginBottom: 2 }}> | ||
| <Footer/> | ||
| </Box> | ||
| </Box> | ||
| ) | ||
| } | ||
|
|
||
| const SignInWithGitHub = () => { | ||
| return ( | ||
| <form | ||
| action={async () => { | ||
| "use server" | ||
| try { | ||
| await signIn("github", { redirectTo: "/" }) | ||
| } catch (error) { | ||
| console.error(error) | ||
| throw error | ||
| } | ||
| }} | ||
| > | ||
| <Button variant="outlined" type="submit"> | ||
| <Stack direction="row" alignItems="center" spacing={1} padding={1}> | ||
| <FontAwesomeIcon icon={faGithub} size="2xl" /> | ||
| <Typography variant="h6" sx={{ display: "flex" }}> | ||
| Sign in with GitHub | ||
| </Typography> | ||
| </Stack> | ||
| </Button> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| const Footer = () => { | ||
| return ( | ||
| <Stack direction="row"> | ||
| {HELP_URL && | ||
| <Link href={HELP_URL} target="_blank" rel="noopener"> | ||
| <Typography variant="body2" sx={{ | ||
| opacity: 0.5, | ||
| transition: "opacity 0.3s ease", | ||
| "&:hover": { | ||
| opacity: 1 | ||
| } | ||
| }}> | ||
| Learn more about {SITE_NAME} | ||
| </Typography> | ||
| </Link> | ||
| } | ||
| </Stack> | ||
| ) | ||
| } |
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
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
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 |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| "use client" | ||
|
|
||
| import { Box, Typography, SxProps } from "@mui/material" | ||
| import { useEffect, useState, useMemo } from "react" | ||
|
|
||
| const SignInTexts = () => { | ||
| const getRandomTextColor = ({ excluding }: { excluding?: string }) => { | ||
| const colors = ["#01BBFE", "#00AE47", "#FCB23D"] | ||
| .filter(e => e !== excluding) | ||
| return colors[Math.floor(Math.random() * colors.length)] | ||
| } | ||
| const [characterIndex, setCharacterIndex] = useState(0) | ||
| const [textIndex, setTextIndex] = useState(0) | ||
| const [displayedText, setDisplayedText] = useState("") | ||
| const [textColor, setTextColor] = useState(getRandomTextColor({})) | ||
| const texts = useMemo(() => [ | ||
| "is a great OpenAPI viewer", | ||
| "facilitates spec-driven development", | ||
| "puts your documentation in one place", | ||
| "adds documentation previews to pull requests" | ||
| ], []) | ||
| useEffect(() => { | ||
| const interval = setInterval(() => { | ||
| setDisplayedText("") | ||
| setCharacterIndex(0) | ||
| setTextColor(getRandomTextColor({ excluding: textColor })) | ||
| setTextIndex((prevIndex) => (prevIndex + 1) % texts.length) | ||
| }, 5000) | ||
| return () => clearInterval(interval) | ||
| }, [texts.length, textColor]) | ||
| useEffect(() => { | ||
| const interval = setInterval(() => { | ||
| setCharacterIndex(characterIndex + 1) | ||
| setDisplayedText(texts[textIndex].substring(0, characterIndex)) | ||
| if (characterIndex === texts[textIndex].length) { | ||
| clearInterval(interval) | ||
| } | ||
| }, 50) | ||
| return () => clearInterval(interval) | ||
| }, [texts, textIndex, characterIndex]) | ||
| const longestText = texts.reduce((a, b) => (a.length > b.length ? a : b)) | ||
| return ( | ||
| <> | ||
| <Box sx={{ position: "relative" }}> | ||
| <Text text={longestText} sx={{ visibility: "hidden" }} /> | ||
| <Text | ||
| text={displayedText} | ||
| textColor={textColor} | ||
| sx={{ position: "absolute", top: 0, left: 0, right: 0 }} | ||
| > | ||
| <Box component="span" sx={{ | ||
| borderRight: `2px solid #fff`, | ||
| animation: "blink 1s step-end infinite" | ||
| }}> | ||
| | ||
| </Box> | ||
| </Text> | ||
| <style jsx>{` | ||
| @keyframes blink { | ||
| 0%, 100% { border-color: transparent; } | ||
| 50% { border-color: #fff; } | ||
| } | ||
| `}</style> | ||
| </Box> | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| export default SignInTexts | ||
|
|
||
| const Text = ({ | ||
| text, | ||
| textColor, | ||
| children, | ||
| sx | ||
| }: { | ||
| text: string, | ||
| textColor?: string, | ||
| children?: React.ReactNode, | ||
| sx?: SxProps | ||
| }) => { | ||
| return ( | ||
| <Typography variant="h4" sx={{ | ||
| ...sx, | ||
| paddingLeft: { md: 5, lg: 10 }, | ||
| paddingRight: { md: 5, lg: 10 } | ||
| }}> | ||
| Shape Docs <span style={{ color: textColor }}>{text}</span> | ||
| {children} | ||
| </Typography> | ||
| ) | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Uh oh!
There was an error while loading. Please reload this page.