From 2016a8619d2824d42e6b25b57607d87feabfe1a6 Mon Sep 17 00:00:00 2001 From: 0ry5 Date: Fri, 13 Sep 2024 21:28:03 +0200 Subject: [PATCH] feat(Darkmode): add Darkmode --- frontend/src/App.tsx | 3 +- frontend/src/darkmodeColors.ts | 5 + frontend/src/index.css | 227 +++++++++++++++--- .../src/pages/Library/components/Actions.tsx | 34 +-- frontend/src/pages/Main/Main.tsx | 17 -- .../components/modals/AuthenticationModal.tsx | 16 +- .../shared/components/modals/BookModal.tsx | 17 +- .../components/modals/CheckoutModal.tsx | 14 +- .../components/modals/DeleteBookModal.tsx | 17 +- .../shared/components/modals/ModalHeader.tsx | 11 +- .../shared/components/modals/ScannerModal.tsx | 14 +- 11 files changed, 216 insertions(+), 159 deletions(-) create mode 100644 frontend/src/darkmodeColors.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f86f282..b2dae2a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,7 +6,7 @@ import "./App.css"; import { Main } from "./pages"; import { Library } from "./pages/Library"; import { Book } from "./pages/Book"; -import { primary } from "./colors"; +import * as colors from "./colors"; import { ActiveModalProps } from "./shared/components/modals/types"; export const AuthContext = createContext<{ @@ -50,7 +50,6 @@ function App() { style={{ height: "100vh", width: "100vw", - backgroundColor: primary, fontFamily: "New Amsterdam", overflow: "scroll", }} diff --git a/frontend/src/darkmodeColors.ts b/frontend/src/darkmodeColors.ts new file mode 100644 index 0000000..61021a2 --- /dev/null +++ b/frontend/src/darkmodeColors.ts @@ -0,0 +1,5 @@ +export const primary = "#5e6268"; +export const primaryRGBA = "rgba(83,86,91, 0.8)"; +export const secondary = "#5f5e68"; +export const tertiary = "#5e6768"; +export const danger = "#685e62"; diff --git a/frontend/src/index.css b/frontend/src/index.css index 336c05e..052c22e 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -12,49 +12,208 @@ body { } } -#bootstrap-overrides .form-select .form-control { - background-color: #f2f2e8 !important; - border-color: #f2f2e8 !important; +#bootstrap-overrides { + background-color: #f2f3f4; + color: #5e6268; + + .btn-primary { + background-color: #5e6268; + color: #f2f3f4; + border: 2px solid #5e6268; + } + + form-control { + background-color: #f2f2e8 !important; + border-color: #5e6268 !important; + } + + .form-select .form-control { + background-color: #f2f2e8 !important; + border-color: #f2f2e8 !important; + } + + .dropdown-toggle::after { + display: none; + } + + .form-label { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", + "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", + "Helvetica Neue", sans-serif !important; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + letter-spacing: normal; + } + + .table > :not(caption) > * > * { + background-color: #f2f2e8 !important; + color: #5e6268 !important; + } + + table { + letter-spacing: 0.25em; + } + + .bg-primary { + background-color: #f2f3f4 !important; + } + + .modal-content { + background-color: #f2f3f4 !important; + border-radius: 10px; + } + + .modal-body { + background-color: #f2f3f4 !important; + border-radius: 0px 0px 10px 10px; + } + + .modal-header { + background-color: #f2f3f4 !important; + border-radius: 10px 10px 0px 0px; + border-bottom: none; + } + + .dropdown button { + background-color: #f2f2e8 !important; + color: #5e6268 !important; + border: 2px solid #5e6268; + } + + .dropdown-menu { + background-color: #f2f2e8 !important; + color: #5e6268 !important; + border: 2px solid #f2f2e8; + } + + .danger { + background-color: #f9a9ab !important; + } + + .page-link { + color: #5e6268 !important; + border: 2px solid #5e6268 !important; + background-color: transparent !important; + } + + .active > .page-link { + background-color: #5e6268 !important; + color: #f2f3f4 !important; + } + + .pagination { + margin-top: 10px !important; + + li { + min-width: 40px; + } + } } -#bootstrap-overrides .dropdown-toggle::after { - display: none; -} +@media (prefers-color-scheme: dark) { + #bootstrap-overrides { + background-color: #5e6268; + color: #f2f3f4; -#bootstrap-overrides .form-label { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", - "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", - sans-serif !important; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - letter-spacing: normal; -} + .btn-primary { + background-color: #f2f3f4; + color: #5e6268; + border: 2px solid #5e6268; + } -#bootstrap-overrides table { - letter-spacing: 0.25em; -} + .form-control { + background-color: #f2f2e8 !important; + border-color: #5e6268 !important; + border-right: none; + } -#bootstrap-overrides .bg-primary { - background-color: #f2f3f4 !important; -} + .form-select .form-control { + background-color: #f2f2e8 !important; + border-color: #f2f2e8 !important; + } -#bootstrap-overrides .modal-body { - background-color: #f2f3f4 !important; -} + .dropdown-toggle::after { + display: none; + } -#bootstrap-overrides .danger { - background-color: #f9a9ab !important; -} + .form-label { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", + "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", + "Helvetica Neue", sans-serif !important; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + letter-spacing: normal; + } -#bootstrap-overrides .page-link { - color: black !important; - border: 2px solid black !important; - background-color: transparent !important; -} + .table > :not(caption) > * > * { + background-color: #5e6268 !important; + color: #f2f2e8 !important; + } -#bootstrap-overrides .active > .page-link { - background-color: black !important; - color: #f2f3f4 !important; + table { + letter-spacing: 0.25em; + } + + .bg-primary { + background-color: #5e6268 !important; + } + + .dropdown button { + background-color: #f2f2e8 !important; + color: #5e6268 !important; + } + + .dropdown-menu { + background-color: #5e6268 !important; + border: 2px solid #5e6268; + } + + .dropdown-item { + color: #f2f2e8 !important; + svg { + color: #f2f2e8 !important; + } + } + .dropdown-item:hover { + color: #5e6268 !important; + background-color: #f2f2e8 !important; + } + + .modal-content { + background-color: #5e6268 !important; + border-radius: 10px; + } + + .modal-body { + background-color: #5e6268 !important; + border-radius: 0px 0px 10px 10px; + } + + .modal-header { + background-color: #5e6268 !important; + border-radius: 10px 10px 0px 0px; + border-bottom: none; + } + + .danger { + background-color: #c94414 !important; + } + + .page-link { + color: #f2f3f4 !important; + border: 2px solid #f2f3f4 !important; + background-color: transparent !important; + } + + .active > .page-link { + background-color: #f2f3f4 !important; + color: #5e6268 !important; + } + + .pagination { + margin-top: 10px !important; + } + } } code { diff --git a/frontend/src/pages/Library/components/Actions.tsx b/frontend/src/pages/Library/components/Actions.tsx index 2bc5dd4..59077ad 100644 --- a/frontend/src/pages/Library/components/Actions.tsx +++ b/frontend/src/pages/Library/components/Actions.tsx @@ -2,7 +2,8 @@ import { Badge, Dropdown } from "react-bootstrap"; import { Book } from "../../../types/Book"; import { ImBin, ImBook, ImBoxAdd, ImBoxRemove, ImMenu } from "react-icons/im"; import { useMutation } from "@tanstack/react-query"; -import { secondary } from "../../../colors"; +import * as colors from "../../../colors"; +import * as dark from "../../../darkmodeColors"; import { ModalContextType } from "../../../App"; import { modalTypes } from "../../../shared/components/modals/types"; import { useCallback } from "react"; @@ -44,11 +45,7 @@ export const Actions = ({ return ( <> - + @@ -59,14 +56,7 @@ export const Actions = ({ className='d-flex' onClick={() => setActiveModal({ type: bookModal, book, onClose })} > - +

@@ -87,13 +77,7 @@ export const Actions = ({ }) } > - + {" "}

@@ -130,13 +114,7 @@ export const Actions = ({ setActiveModal({ type: del, uuid: book.uuid, onClose }) } > - + {" "}

diff --git a/frontend/src/pages/Main/Main.tsx b/frontend/src/pages/Main/Main.tsx index 090b13d..a1c7197 100644 --- a/frontend/src/pages/Main/Main.tsx +++ b/frontend/src/pages/Main/Main.tsx @@ -13,7 +13,6 @@ import { TfiKey } from "react-icons/tfi"; import { Link, useNavigate } from "react-router-dom"; import { Book } from "../../types/Book"; -import { secondary } from "../../colors"; import { useAuth } from "../../shared/utils/useAuthentication"; import { ModalContext } from "../../App"; import { modalTypes } from "../../shared/components/modals/types"; @@ -95,16 +94,12 @@ export const Main = (): React.JSX.Element => { onChange={(ev) => setTitle(ev.target.value)} style={{ borderRadius: "20px 0px 0px 20px", - border: "2px solid black", borderRight: "none", }} />