Skip to content

Commit

Permalink
feat(feat/repository): adding dark and light theme with mire infos ab…
Browse files Browse the repository at this point in the history
…out the repositories (owner, language)
  • Loading branch information
eliestroun14 committed Aug 14, 2024
1 parent 593bab4 commit c878948
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 19 deletions.
28 changes: 27 additions & 1 deletion src/app/repository/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
45 changes: 27 additions & 18 deletions src/app/repository/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Repository[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [theme, setTheme] = useState("light");

useEffect(() => {
const fetchRepositories = async () => {
Expand Down Expand Up @@ -60,6 +61,10 @@ const RepositoryPage: React.FC = () => {
console.log(repositories);
}, [repositories]);

const toggleTheme = () => {
setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light"));
};

if (loading) {
return <div>Loading...</div>;
}
Expand All @@ -71,22 +76,26 @@ const RepositoryPage: React.FC = () => {

return (
<>
<div className="container">
<h1 className="title">Your Repositories</h1>
<ul className="repository-list">
{repositories.map((repo) => (
<li key={repo.id} className="repository-item">
<div className="repo-details">
<h2>{repo.name}</h2>
<p className="version">LastPush: {repo.LastPush}</p>
</div>
<div className="repo-author">
<span>LastPush: {repo.LastPush}</span>
</div>
</li>
))}
</ul>
</div>
<div className={`container ${theme}`}>
<h1 className="title">Your Repositories</h1>
<button onClick={toggleTheme} className="theme-toggle">
Switch to {theme === "light" ? "Dark" : "Light"} Theme
</button>
<ul className="repository-list">
{repositories.map((repo) => (
<li key={repo.id} className="repository-item">
<div className="repo-details">
<h2>{repo.name}</h2>
<span>Language: {repo.language}</span>
</div>
<div className="Owner">
<p className="owner">Owner: {repo.owner?.login}</p>
</div>
<img src={repo.owner.avatar_url} alt={repo.owner.login} className="avatar"/>
</li>
))}
</ul>
</div>
</>
);
};
Expand Down

0 comments on commit c878948

Please sign in to comment.