Redesign Reset Password page

This commit is contained in:
2024-10-03 17:14:01 +07:00
parent 0c0aa045dc
commit 7b77d59e54
2 changed files with 63 additions and 60 deletions

View File

@ -54,30 +54,29 @@ templ Main(title string, err types.Message) {
templ NewPasswordForm(title string, err types.Message) { templ NewPasswordForm(title string, err types.Message) {
@layout.Base(title){ @layout.Base(title){
<div class="dark flex items-center min-h-screen p-4 sm:p-6 bg-gray-900"> <div class="bg-gray-100 flex items-center justify-center min-h-screen">
<div class="mx-auto w-full max-w-md space-y-8"> <div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
<header class="text-center"> <h1 class="text-2xl font-bold mb-6 text-center text-gray-800">Reset Password</h1>
<div class="space-y-2">
<h1 class="text-3xl font-bold text-white">Forgot password</h1>
<p class="text-gray-500 dark:text-gray-400">Enter your email below to reset your password</p>
switch err.Code { switch err.Code {
case 0: case 0:
<div class="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert"> <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4" role="alert">
{err.Message} <strong class="font-bold">Error!</strong>
<span class="block sm:inline"> {err.Message} </span>
</div> </div>
} }
<form action="" method="POST" class="space-y-4">
<div>
<label for="password" class="block text-sm font-medium text-gray-700">Password</label>
<input type="password" id="password" name="password" required
class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
</div> </div>
</header> <div>
<form class="space-y-4" method="post" action=""> <label for="confirmPassword" class="block text-sm font-medium text-gray-700">Confirm Password</label>
<div class="space-y-2"> <input type="password" id="confirmPassword" name="confirmPassword" required
<label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white" for="password">Password</label> class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
<input type="password" class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-white" id="password" name="password" required />
</div> </div>
<div class="space-y-2"> <div>
<label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white" for="confirmPassword">Confirm Password</label> <div id="checkContainer" class="flex justify-start mt-1 block w-full px-3 py-2 hidden">
<input type="password" class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-white" id="confirmPassword" required />
</div>
<div class="flex justify-start mt-3 ml-4 p-1">
<ul> <ul>
<li class="flex items-center py-1"> <li class="flex items-center py-1">
<div id="matchSvgContainer" class="rounded-full p-1 fill-current bg-red-200 text-green-700"> <div id="matchSvgContainer" class="rounded-full p-1 fill-current bg-red-200 text-green-700">
@ -108,13 +107,17 @@ templ NewPasswordForm(title string, err types.Message) {
</li> </li>
</ul> </ul>
</div> </div>
<button class="bg-slate-200 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full" type="submit" id="submit" name="submit" disabled> <button id="submit"
Submit type="submit"
disabled
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:pointer-events-none disabled:opacity-50">
Reset
</button> </button>
</div>
</form> </form>
</div> </div>
</div>
<script src="/public/validatePassword.js" /> <script src="/public/validatePassword.js" />
</div>
} }
} }

View File

@ -146,31 +146,31 @@ func NewPasswordForm(title string, err types.Message) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"dark flex items-center min-h-screen p-4 sm:p-6 bg-gray-900\"><div class=\"mx-auto w-full max-w-md space-y-8\"><header class=\"text-center\"><div class=\"space-y-2\"><h1 class=\"text-3xl font-bold text-white\">Forgot password</h1><p class=\"text-gray-500 dark:text-gray-400\">Enter your email below to reset your password</p>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"bg-gray-100 flex items-center justify-center min-h-screen\"><div class=\"bg-white p-8 rounded-lg shadow-md w-full max-w-md\"><h1 class=\"text-2xl font-bold mb-6 text-center text-gray-800\">Reset Password</h1>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
switch err.Code { switch err.Code {
case 0: case 0:
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400\" role=\"alert\">") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4\" role=\"alert\"><strong class=\"font-bold\">Error!</strong> <span class=\"block sm:inline\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var7 string var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(err.Message) templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(err.Message)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/client/auth/forgotPassword/forgotPassword.templ`, Line: 66, Col: 38} return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/client/auth/forgotPassword/forgotPassword.templ`, Line: 64, Col: 66}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></header><form class=\"space-y-4\" method=\"post\" action=\"\"><div class=\"space-y-2\"><label class=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white\" for=\"password\">Password</label> <input type=\"password\" class=\"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-white\" id=\"password\" name=\"password\" required></div><div class=\"space-y-2\"><label class=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white\" for=\"confirmPassword\">Confirm Password</label> <input type=\"password\" class=\"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-white\" id=\"confirmPassword\" required></div><div class=\"flex justify-start mt-3 ml-4 p-1\"><ul><li class=\"flex items-center py-1\"><div id=\"matchSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"matchSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"matchGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"matchBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"matchStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Passwords do not match</span></li><li class=\"flex items-center py-1\"><div id=\"uppercaseSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"uppercaseSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"uppercaseGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"uppercaseBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"uppercaseStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Password must contain at least one uppercase letter</span></li><li class=\"flex items-center py-1\"><div id=\"lengthSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"lengthSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"lengthGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"lengthBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"lengthStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Password length must be at least 8 characters</span></li></ul></div><button class=\"bg-slate-200 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full\" type=\"submit\" id=\"submit\" name=\"submit\" disabled>Submit</button></form></div></div><script src=\"/public/validatePassword.js\"></script>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form action=\"\" method=\"POST\" class=\"space-y-4\"><div><label for=\"password\" class=\"block text-sm font-medium text-gray-700\">Password</label> <input type=\"password\" id=\"password\" name=\"password\" required class=\"mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500\"></div><div><label for=\"confirmPassword\" class=\"block text-sm font-medium text-gray-700\">Confirm Password</label> <input type=\"password\" id=\"confirmPassword\" name=\"confirmPassword\" required class=\"mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500\"></div><div><div id=\"checkContainer\" class=\"flex justify-start mt-1 block w-full px-3 py-2 hidden\"><ul><li class=\"flex items-center py-1\"><div id=\"matchSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"matchSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"matchGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"matchBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"matchStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Passwords do not match</span></li><li class=\"flex items-center py-1\"><div id=\"uppercaseSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"uppercaseSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"uppercaseGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"uppercaseBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"uppercaseStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Password must contain at least one uppercase letter</span></li><li class=\"flex items-center py-1\"><div id=\"lengthSvgContainer\" class=\"rounded-full p-1 fill-current bg-red-200 text-green-700\"><svg id=\"lengthSvgIcon\" class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\"><path id=\"lengthGoodPath\" style=\"display: none;\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path> <path id=\"lengthBadPath\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path></svg></div><span id=\"lengthStatusText\" class=\"font-medium text-sm ml-3 text-red-700\">Password length must be at least 8 characters</span></li></ul></div><button id=\"submit\" type=\"submit\" disabled class=\"w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:pointer-events-none disabled:opacity-50\">Reset</button></div></form></div><script src=\"/public/validatePassword.js\"></script></div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }