generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from moevm/LoginPage
Routes and Login Page
- Loading branch information
Showing
12 changed files
with
198 additions
and
56 deletions.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +0,0 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { InputHTMLAttributes } from "react"; | ||
|
||
interface FormInputProps extends InputHTMLAttributes<HTMLInputElement> {} | ||
|
||
function FormInput({...props}: FormInputProps) { | ||
|
||
return ( | ||
<> | ||
<input {...props} | ||
className="w-full border-b border-black border-opacity-30 | ||
bg-base2 text-black p-3 outline-0 text-opacity-75 text-lg | ||
h-10 placeholder:text-opacity-30 placeholder:text-black | ||
" | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default FormInput |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Перечисление роутов | ||
export enum AppRoutes { | ||
WELCOME = "welcome", | ||
// REGISTER = "register", | ||
LOGIN = "login", | ||
// FEED = "feed", | ||
// POST = "post", | ||
// NOT_FOUND = "notFound", | ||
} | ||
|
||
// Перечисление параметров предлагаю | ||
// использовать чтобы не хардкодить шаблонную строку, | ||
// а так же ссылаться на RoutePaths и c помощью | ||
// метода replace менять на параметр сущности. | ||
// Пример: | ||
// RoutePaths.user.replace(RouteParams.USERNAME, username) | ||
export enum RouteParams { | ||
POST_ID = ":id", | ||
USERNAME = ":username", | ||
} | ||
|
||
export const RoutePaths: Record<AppRoutes, string> = { | ||
// Будем отрисовывать профиль в зависимости от параметра. | ||
// Если на беке не найдётся юзер, то кинем на 404. | ||
[AppRoutes.WELCOME]: '/' + AppRoutes.WELCOME, | ||
// [AppRoutes.REGISTER]: "/register", | ||
[AppRoutes.LOGIN]: "/login", | ||
// [AppRoutes.FEED]: "/feed", | ||
// [AppRoutes.POST]: "/post/" + RouteParams.POST_ID, | ||
// [AppRoutes.NOT_FOUND]: "*", | ||
}; |
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,50 @@ | ||
import Header from "../../Widgets/Header/Header.tsx"; | ||
import LoginButton from "../../Components/LoginButton/LoginButton.tsx"; | ||
import FormCard from "../../Components/FormCard/FormCard.tsx"; | ||
import FormInput from "../../Components/FormInput/FormInput.tsx"; | ||
import { FormEvent } from "react"; | ||
|
||
|
||
function LoginPage() { | ||
|
||
function onSubmit(event: FormEvent) { | ||
event.preventDefault() | ||
const target: any = event.target | ||
console.log(target.username.value) | ||
console.log(target.password.value) | ||
} | ||
return ( | ||
<> | ||
<Header /> | ||
<div className=" | ||
w-full h-auto py-28 | ||
font-poppins text-center font-bold | ||
flex justify-evenly items-center | ||
" | ||
> | ||
<FormCard> | ||
<h2 className="leading-relaxed text-6xl text-base1 font-semibold"> | ||
LOG IN | ||
</h2> | ||
<form action="/welcome" onSubmit={onSubmit} className="flex h-64 flex-col justify-between mt-16"> | ||
<FormInput name={"username"} | ||
placeholder={"Username"} | ||
required={true} | ||
autoComplete={"off"} /> | ||
<FormInput name={"password"} | ||
placeholder={"Password"} | ||
required={true} | ||
autoComplete={"off"} /> | ||
<div> | ||
<LoginButton theme="primary" children="Log in" type="submit"></LoginButton> | ||
</div> | ||
</form> | ||
</FormCard> | ||
<img className="bg-base1 rounded-full " src="src/assets/doctor-img1.png" alt=""/> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
|
||
export default LoginPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import WelcomePage from "../Pages/WelcomePage/WelcomePage.tsx"; | ||
import {AppRoutes, RoutePaths} from "../Config/routeConfig.ts"; | ||
import { Route, Routes, RouteProps } from "react-router-dom"; | ||
import LoginPage from "../Pages/LoginPage/LoginPage.tsx"; | ||
|
||
const routes: Record<AppRoutes, RouteProps> = { | ||
[AppRoutes.WELCOME]: { | ||
path: RoutePaths.welcome, | ||
element: <WelcomePage />, | ||
}, | ||
// [AppRoutes.REGISTER]: { | ||
// path: RoutePaths.register, | ||
// element: <>Register page</>, | ||
// }, | ||
[AppRoutes.LOGIN]: { | ||
path: RoutePaths.login, | ||
element: <LoginPage />, | ||
}, | ||
// [AppRoutes.FEED]: { | ||
// path: RoutePaths.feed, | ||
// element: <>Feed</>, | ||
// }, | ||
// [AppRoutes.POST]: { | ||
// path: RoutePaths.post, | ||
// element: <>Post page</>, | ||
// }, | ||
// [AppRoutes.NOT_FOUND]: { | ||
// path: RoutePaths.notFound, | ||
// element: <>404 not found</>, | ||
// }, | ||
}; | ||
|
||
export default function AppRouter() { | ||
return ( | ||
<Routes> | ||
{Object.values(routes).map(({ path, element }) => ( | ||
<Route key={path} path={path} element={element} /> | ||
))} | ||
</Routes> | ||
); | ||
} |
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