Skip to content

Commit

Permalink
Merge pull request #118 from bas-kirill/feature/login-dark-mode
Browse files Browse the repository at this point in the history
feat(login): add dark mode
  • Loading branch information
bas-kirill authored Aug 25, 2024
2 parents ed4d99d + 9a61895 commit 06a4111
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 29 deletions.
3 changes: 0 additions & 3 deletions client/src/app/App.module.scss

This file was deleted.

11 changes: 8 additions & 3 deletions client/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import "./App.scss";
import styles from "./App.module.scss";
import "./styles/App.scss";
import styles from "./styles/App.module.scss";
import {
createBrowserRouter,
createRoutesFromElements,
Expand Down Expand Up @@ -91,7 +91,12 @@ const App = () => {
const { darkMode } = useDarkMode();

return (
<div id="app" className={`${darkMode && styles.dark}`}>
<div
className={`
${styles.app}
${darkMode && styles.app__dark}
`}
>
<RouterProvider router={router} />
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions client/src/app/styles/App.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.app {
background-color: #f5f5f5;
max-width: 1024px;
margin: 0 auto;
border: 1px #dee2e6 solid;
}

.app__dark {
background-color: #212529;
}
7 changes: 0 additions & 7 deletions client/src/app/App.scss → client/src/app/styles/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ body {
sans-serif;
}

#app {
background-color: #f5f5f5;
max-width: 1024px;
margin: 0 auto;
border: 1px #dee2e6 solid;
}

h1 {
margin: 0;
}
31 changes: 27 additions & 4 deletions client/src/pages/login/ui/Login.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { FooterWidget } from "widgets/footer";
import { Form, useActionData, useNavigate } from "react-router-dom";
import { LoginAction } from "../api/action";
import { REGISTRATION_URL } from "shared/config/paths";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";

export function LoginPage() {
const { darkMode } = useDarkMode();
const actionData = useActionData() as LoginAction;
const navigate = useNavigate();

Expand All @@ -18,14 +20,35 @@ export function LoginPage() {
<>
<HeaderWidget />

<Form method="post" className={styles.login__form}>
<input type="text" name="login" placeholder={"Login"} />
<input type="password" name="password" placeholder={"Password"} />
<input type="submit" value="Login" />
<Form
method="post"
className={`
${styles.login__form}
${darkMode && styles.login__form__dark}
`}
>
<input
type="text"
name="login"
placeholder={"Login..."}
className={styles.login__form__input__dark}
/>
<input
type="password"
name="password"
placeholder={"Password..."}
className={styles.login__form__input__dark}
/>
<input
type="submit"
value="Login"
className={styles.login__form__input__dark}
/>
<input
type="button"
value="Registration"
onClick={handleRegisterRedirect}
className={styles.login__form__input__dark}
/>
{actionData?.errors.length > 0 && (
<div className={styles.login__error}>
Expand Down
14 changes: 14 additions & 0 deletions client/src/pages/login/ui/styles/Login.page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@
font-size: 2em;
}
}

.login__form__dark {
background-color: #212529;
}

.login__form__input__dark {
color: #ffffff;
background-color: #212529;
border: 1px darkgray solid;

&::placeholder {
color: #ffffff;
}
}
23 changes: 17 additions & 6 deletions client/src/pages/profile/ui/Profile.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const logout = new LogoutApi();

export function ProfilePage() {
useJwt();
const { toggleTheme } = useDarkMode();
const { darkMode, toggleTheme } = useDarkMode();
const navigate = useNavigate();
const profile = useLoaderData() as ProfileDetails;

Expand Down Expand Up @@ -46,18 +46,29 @@ export function ProfilePage() {
<>
<HeaderWidget />

<div className={styles.profile}>
<div
className={`
${styles.profile}
${darkMode && styles.profile__dark}
`}
>
<h1>{profile.full_name}</h1>
<div>
<b>Name</b>: <span>{profile?.full_name}</span>
<b>Name</b>: <span>{profile.full_name}</span>
</div>
<div>
<b>Role</b>: <span>{profile?.role}</span>
<b>Role</b>: <span>{profile.role}</span>
</div>
<button onClick={toggleTheme} className={styles.dark_mode__button}>
<button
onClick={toggleTheme}
className={`${darkMode && styles.dark_mode__button}`}
>
Dark Mode
</button>
<button onClick={onLogoutHandler} className={styles.logout__button}>
<button
onClick={onLogoutHandler}
className={`${darkMode && styles.logout__button}`}
>
Logout
</button>
</div>
Expand Down
6 changes: 6 additions & 0 deletions client/src/pages/profile/ui/styles/Profile.page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
margin: 2em auto;
}

.profile__dark {
color: #ffffff;
}

.dark_mode__button {
color: #ffffff;
background-color: darkgray;
}

.logout__button {
color: #ffffff;
background-color: #ff0000;
}
16 changes: 14 additions & 2 deletions client/src/widgets/footer/ui/Footer.widget.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import React from "react";
import "./styles/FooterWidget.css";
import styles from "./styles/Footer.widget.module.css";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";

export function FooterWidget() {
return <footer>Muse Group Frontend Academy</footer>;
const { darkMode } = useDarkMode();

return (
<footer
className={`
${styles.footer}
${darkMode && styles.footer__dark}
`}
>
Muse Group Frontend Academy
</footer>
);
}

export default FooterWidget;
9 changes: 9 additions & 0 deletions client/src/widgets/footer/ui/styles/Footer.widget.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.footer {
background-color: khaki;
padding: 20px;
}

.footer__dark {
background-color: #2c2c2c;
color: #ffffff;
}
4 changes: 0 additions & 4 deletions client/src/widgets/footer/ui/styles/FooterWidget.css

This file was deleted.

0 comments on commit 06a4111

Please sign in to comment.