From c8789482692326d47fa3256b0d31c1e039ce016b Mon Sep 17 00:00:00 2001 From: elies Date: Wed, 14 Aug 2024 10:05:43 +0200 Subject: [PATCH] feat(feat/repository): adding dark and light theme with mire infos about the repositories (owner, language) --- src/app/repository/page.css | 28 ++++++++++++++++++++++- src/app/repository/page.tsx | 45 ++++++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/app/repository/page.css b/src/app/repository/page.css index 6418d9b..cc6335a 100644 --- a/src/app/repository/page.css +++ b/src/app/repository/page.css @@ -12,6 +12,12 @@ margin-bottom: 20px; } +.theme-toggle { + margin-bottom: 20px; + padding: 10px 20px; + cursor: pointer; +} + .repository-list { list-style-type: none; padding: 0; @@ -46,10 +52,30 @@ width: 30px; height: 30px; border-radius: 50%; - margin-right: 10px; + margin-left: 10px; } .version { font-size: 0.9em; color: #666; } + +/* Light Theme */ +.container.light { + background-color: #ffffff; + color: #000000; +} + +/* Dark Theme */ +.container.dark { + background-color: #333333; + color: #ffffff; +} + +.container.dark .repository-item { + background-color: #444444; +} + +.container.dark .repository-item:hover { + background-color: #555555; +} \ No newline at end of file diff --git a/src/app/repository/page.tsx b/src/app/repository/page.tsx index 0577c24..739bbe0 100644 --- a/src/app/repository/page.tsx +++ b/src/app/repository/page.tsx @@ -8,19 +8,20 @@ import { redirect } from "next/navigation"; interface Repository { id: string; name: string; - author?: { + owner?: { avatar_url: string; login: string; }; version: string; LastPush : string; - + language: string; } const RepositoryPage: React.FC = () => { const [repositories, setRepositories] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [theme, setTheme] = useState("light"); useEffect(() => { const fetchRepositories = async () => { @@ -60,6 +61,10 @@ const RepositoryPage: React.FC = () => { console.log(repositories); }, [repositories]); + const toggleTheme = () => { + setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light")); + }; + if (loading) { return
Loading...
; } @@ -71,22 +76,26 @@ const RepositoryPage: React.FC = () => { return ( <> -
-

Your Repositories

-
    - {repositories.map((repo) => ( -
  • -
    -

    {repo.name}

    -

    LastPush: {repo.LastPush}

    -
    -
    - LastPush: {repo.LastPush} -
    -
  • - ))} -
-
+
+

Your Repositories

+ +
    + {repositories.map((repo) => ( +
  • +
    +

    {repo.name}

    + Language: {repo.language} +
    +
    +

    Owner: {repo.owner?.login}

    +
    + {repo.owner.login} +
  • + ))} +
+
); };