-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): improve admin setup ux (#1671)
* feat(ui): improve admin setup ux * redirect admin signup to sigin after admin already setup * polish codes * disable scrolling * [autofix.ci] apply automated fixes * fix: form uncontrol warning * fix form value warning * [autofix.ci] apply automated fixes * fix: admin singup form input active border issue * update text --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Meng Zhang <[email protected]>
- Loading branch information
1 parent
0587f8f
commit 47fd912
Showing
5 changed files
with
172 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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,39 @@ | ||
.admin-register-wrap { | ||
transition: transform 0.35s ease-out; | ||
padding-top: 20vh; | ||
padding-bottom: 20vh; | ||
} | ||
|
||
.step-mask { | ||
position: relative; | ||
pointer-events: none; | ||
user-select: none; | ||
border-color: hsl(var(--muted-foreground) / 0.1); | ||
|
||
} | ||
.step-mask:before { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background: linear-gradient( | ||
0deg, | ||
hsl(var(--background) / 1) 0%, | ||
hsl(var(--background) / 1) 30%, | ||
hsl(var(--background) / 0.5) 100% | ||
); | ||
pointer-events: none; | ||
user-select: none; | ||
z-index: 10; | ||
width: 110%; | ||
} | ||
.step-mask.remote:before { | ||
background: linear-gradient( | ||
0deg, | ||
hsl(var(--background) / 1) 0%, | ||
hsl(var(--background) / 1) 30%, | ||
hsl(var(--background) / 0.9) 100% | ||
); | ||
} |
This file contains 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,96 @@ | ||
'use client' | ||
|
||
import { useEffect, useState } from 'react' | ||
import { useRouter } from 'next/navigation' | ||
|
||
import { cn } from '@/lib/utils' | ||
import { Button } from '@/components/ui/button' | ||
|
||
import { UserAuthForm } from './user-register-form' | ||
|
||
import './admin-register.css' | ||
|
||
function AdminRegisterStep({ | ||
step, | ||
currentStep, | ||
children | ||
}: { | ||
step: number | ||
currentStep: number | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<div | ||
id={`step-${step}`} | ||
className={cn('border-l border-foreground py-8 pl-12 pr-2', { | ||
'step-mask': step !== currentStep, | ||
remote: Math.abs(currentStep - step) > 1 | ||
})} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export default function AdminRegister() { | ||
const router = useRouter() | ||
const [currentStep, setCurrentStep] = useState(1) | ||
|
||
useEffect(() => { | ||
if (currentStep === 1) return | ||
document | ||
.getElementById(`step-${currentStep}`) | ||
?.scrollIntoView({ behavior: 'smooth' }) | ||
}, [currentStep]) | ||
|
||
return ( | ||
<div className="admin-register-wrap h-screen w-[600px] overflow-hidden"> | ||
<AdminRegisterStep step={1} currentStep={currentStep}> | ||
<h2 className="text-3xl font-semibold tracking-tight first:mt-0"> | ||
Welcome! | ||
</h2> | ||
<p className="mt-2 leading-7 text-muted-foreground"> | ||
Your tabby server is live and ready to use. This step by step guide | ||
will help you set up your admin account. | ||
</p> | ||
<p className="leading-7 text-muted-foreground"> | ||
Admin account is the highest level of access in your server. Once | ||
created, you can invite other members to join your server. | ||
</p> | ||
<Button className="mt-5 w-48" onClick={() => setCurrentStep(2)}> | ||
Start | ||
</Button> | ||
</AdminRegisterStep> | ||
|
||
<AdminRegisterStep step={2} currentStep={currentStep}> | ||
<h3 className="text-2xl font-semibold tracking-tight"> | ||
Create Admin Account | ||
</h3> | ||
<p className="mb-3 leading-7 text-muted-foreground"> | ||
Please store your password in a safe place. We do not store your | ||
password and cannot recover it for you. | ||
</p> | ||
<UserAuthForm | ||
onSuccess={() => setCurrentStep(3)} | ||
buttonClass="self-start w-48" | ||
/> | ||
</AdminRegisterStep> | ||
|
||
<AdminRegisterStep step={3} currentStep={currentStep}> | ||
<h3 className="text-2xl font-semibold tracking-tight"> | ||
Congratulations! | ||
</h3> | ||
<p className="leading-7 text-muted-foreground"> | ||
You have successfully created an admin account. | ||
</p> | ||
<p className="mb-3 leading-7 text-muted-foreground"> | ||
To start, navigate to the dashboard and invite other members to join | ||
your server. | ||
</p> | ||
<Button className="mt-5 w-48" onClick={() => router.replace('/')}> | ||
Go to dashboard | ||
</Button> | ||
</AdminRegisterStep> | ||
</div> | ||
) | ||
} |
This file contains 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 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 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