add of projectDetails page

This commit is contained in:
Giovanni-Josserand 2025-09-13 22:14:42 +02:00
parent f118cf0cf8
commit b612c00f1f
15 changed files with 1820 additions and 64 deletions

View File

@ -1,8 +1,11 @@
# To do # To do
- mettre un moyen de retour sur les pages details et les liens git
- revoir fonction de tri par age car problème entre 1 date et 2 des fois
- Refaire les images qui vont pas - Refaire les images qui vont pas
- Faire une page explicative par projet - Faire une page explicative par projet
- Faire du responsive - Faire du responsive
- utiliser les vraies fonctions de fastapi
## Plus tard ## Plus tard
- Régler problème de scoll entre page - Régler problème de scoll entre page
@ -13,4 +16,5 @@
`npm install` `npm install`
`npm run dev` `npm run dev`
`npm install react-router-dom` `npm install react-router-dom`
`npm install react-markdown remark-gfm`

1476
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,9 @@
"dependencies": { "dependencies": {
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0", "react-dom": "^19.1.0",
"react-router-dom": "^7.8.2" "react-markdown": "^10.1.0",
"react-router-dom": "^7.8.2",
"remark-gfm": "^4.0.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.25.0", "@eslint/js": "^9.25.0",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

View File

@ -1,3 +1,4 @@
#root { #root {
margin: 0 auto; margin: 0 auto;
width: 100%;
} }

View File

@ -2,6 +2,7 @@ import './App.css'
import { Routes, Route, Link } from 'react-router-dom'; import { Routes, Route, Link } from 'react-router-dom';
import HomePage from './pages/HomePage.jsx'; import HomePage from './pages/HomePage.jsx';
import ProjectsPage from './pages/ProjectsPage'; import ProjectsPage from './pages/ProjectsPage';
import ProjectDetailsPage from "./pages/ProjectDetailsPage.jsx";
function App() { function App() {
@ -9,6 +10,7 @@ function App() {
<Routes> <Routes>
<Route path="/" element={<HomePage />} /> <Route path="/" element={<HomePage />} />
<Route path="/projects" element={<ProjectsPage />} /> <Route path="/projects" element={<ProjectsPage />} />
<Route path="/projectDetails/:id" element={<ProjectDetailsPage />} />
</Routes> </Routes>
) )
} }

View File

@ -30,7 +30,7 @@
cursor: pointer; cursor: pointer;
border: none; border: none;
background: none; background: none;
font-size: 15px;
} }
.nav-link:hover { .nav-link:hover {

View File

@ -0,0 +1,149 @@
.project-details {
display: flex;
width: 70%;
margin: 0 15% 0 15%;
gap: 4%;
flex-direction: column;
}
.nav-bar{
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
overflow: hidden;
height: 280px;
background-image: url("/public/assets/images/projectDetailsHeadband.png");
background-size: cover;
&::after { /* Utilise un pseudo-élément pour le dégradé */
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 200px;
background: linear-gradient(to top, #0D0D0D 0%, rgba(26, 26, 26, 0) 100%);
}
}
.project-details-header{
width: 100%;
border-bottom: 2px solid #333;
}
.project-details-header h1{
color: var(--title-color);
display: flex;
align-items: center;
gap: 1rem;
margin: 0;
}
.project-details-container {
width: 92%;
color: var(--text-color);
display: flex;
padding: 0 4%;
}
.project-details-content {
width: 80%
}
.project-details-content h2 {
margin-top: 2rem;
color: var(--title-color);
border-left: 4px solid var(--important-color);
padding-left: 0.75rem;
}
.project-details-years {
color : var(--text-color);
margin : 0;
font-weight: bold;
font-style: italic;
}
.project-details-short-description{
color: var(--text-color);
}
.project-details-header ul{
display: flex;
list-style: none;
padding: 0;
gap: 1em;
}
aside {
width: 20%;
height: fit-content;
position: sticky;
top: 150px;
color: var(--text-color);
}
.aside-title {
font-weight: bold;
color: var(--title-color);
margin-bottom: 1rem;
font-size: 1.1em;
}
aside ul{
border-left: 2px solid #333;
list-style: none;
padding: 0 0 0 1em;
}
aside ul li {
margin-bottom: 0.25em;
}
aside ul li a {
text-decoration: none;
color: var(--text-color);
}
aside ul li a:hover {
color: var(--title-color)
}
.return-button{
position: absolute;
top: 2em;
left: 20px;
border: none;
background: none;
padding: 7px;
cursor: pointer;
z-index: 10;
transition: background-color 0.3s ease;
justify-content: center;
align-items: center;
border-radius: 50%;
width: 38px;
height: 38px;
}
.return-button:hover {
background: rgba(100,100,100, 0.5);
cursor: pointer;
}
.return-button svg {
color: var(--text-color);
transition: all 0.3s ease;
}
.return-button:hover svg {
color: var(--title-color);
}

View File

@ -0,0 +1,101 @@
import "./ProjectDetails.css"
import SkillCard from "../SkillCard/SkillCard.jsx";
import React, {useEffect, useState} from "react";
import NavBar from "../NavBar/NavBar.jsx";
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import {useNavigate} from "react-router-dom";
function ProjectDetails({project}) {
const [mdTitle, setMdTitle] = useState([]);
const navigate = useNavigate();
useEffect(() =>{
if (!project.long_description) return;
const matches = [...project.long_description.matchAll(/^## (?!#)(.+)$/gm)];
setMdTitle(matches.map(match => match[1].trim()));
}, [project.long_description])
const handleSummaryClick = (event, anchor) => {
event.preventDefault();
const element = document.getElementById(anchor);
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
};
return (
<div>
<button className="return-button" onClick={() => navigate(-1)}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="24px" height="24px" fill="currentColor">
<path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"/>
</svg>
</button>
<div className="nav-bar">
<NavBar/>
</div>
<div className="project-details">
<div className="project-details-header">
<h1>
{project.title}
{project.school ? (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="#D95F46" width="1em" height="1em">
<path d="M80 259.8L289.2 345.9C299 349.9 309.4 352 320 352C330.6 352 341 349.9 350.8 345.9L593.2 246.1C602.2 242.4 608 233.7 608 224C608 214.3 602.2 205.6 593.2 201.9L350.8 102.1C341 98.1 330.6 96 320 96C309.4 96 299 98.1 289.2 102.1L46.8 201.9C37.8 205.6 32 214.3 32 224L32 520C32 533.3 42.7 544 56 544C69.3 544 80 533.3 80 520L80 259.8zM128 331.5L128 448C128 501 214 544 320 544C426 544 512 501 512 448L512 331.4L369.1 390.3C353.5 396.7 336.9 400 320 400C303.1 400 286.5 396.7 270.9 390.3L128 331.4z"/>
</svg>
) : null}
</h1>
{project.end_year === null ? (
<p className="project-details-years">{project.beginning_year + ' in progress'}</p>
) : project.beginning_year === project.end_year ? (
<p className="project-details-years">{project.beginning_year}</p>
) : (
<p className="project-details-years">{project.beginning_year + ' ' + project.end_year}</p>
)}
<p className="project-details-short-description">{project.short_description}</p>
<ul>
{project.skills && project.skills.map((skill) => (
<li>
<SkillCard text={skill} />
</li>
))}
</ul>
</div>
<div className="project-details-container">
<div className="project-details-content">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
h2({node, ...props}) {
const id = String(props.children).toLowerCase().replace(/\s+/g, "-");
return <h2 id={id} {...props} />;
}
}}
>
{project.long_description}
</ReactMarkdown>
</div>
<aside>
<ul>
{mdTitle.map(title => {
const anchor = title.toLowerCase().replace(/\s+/g, "-");
return (
<li key={anchor}>
<a href={`#${anchor}`} onClick={(e) => handleSummaryClick(e, anchor)}>
{title}
</a>
</li>
);
})}
</ul>
</aside>
</div>
</div>
</div>
);
}
export default ProjectDetails

View File

@ -7,7 +7,6 @@
.show-more-container { .show-more-container {
text-align: center; text-align: center;
} }
.projects-link { .projects-link {

View File

@ -12,6 +12,7 @@
.single-project:hover { .single-project:hover {
transform: translateY(-5px); transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
cursor: pointer;
} }
.single-project-top { .single-project-top {
@ -115,19 +116,6 @@
gap: 8px; gap: 8px;
} }
.single-project-link {
color: var(--text-color);
text-decoration: none;
font-weight: 600;
margin-bottom : 0;
}
.single-project-link:hover {
cursor: pointer;
color: var(--title-color);
}
.single-project-years{ .single-project-years{
color : var(--text-color); color : var(--text-color);
margin : 0; margin : 0;

View File

@ -1,53 +1,59 @@
import { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import SkillCard from "../SkillCard/SkillCard.jsx"; import SkillCard from "../SkillCard/SkillCard.jsx";
import "./SingleProject.css"; import "./SingleProject.css";
import {Link, useNavigate} from "react-router-dom";
function SingleProject({ image, title, description, skills, id, school, beginningYear, endYear }) { function SingleProject({ image, title, description, skills, id, school, beginningYear, endYear }) {
const color = ["blue", "green", "purple", "red", "yellow"] const color = ["blue", "green", "purple", "red", "yellow"]
const navigate = useNavigate();
const clickProject = () => {
navigate(`/projectDetails/${id}`);
}
return ( return (
<div className="single-project"> <div className="single-project" onClick={clickProject}>
<div className="single-project-top"> <div className="single-project-top">
<img src={`/assets/images/projects/${image}/${image}_1.png`} alt={image}/> <img src={`/assets/images/projects/${image}/${image}_1.png`} alt={image}/>
</div> </div>
<div className="single-project-bottom"> <div className="single-project-bottom">
<div className="single-project-bottom-header"> <div className="single-project-bottom-header">
<div className="single-project-title-wrapper"> <div className="single-project-title-wrapper">
<div className={`single-project-line color-${color[(id-1)%color.length]}`}></div> <div className={`single-project-line color-${color[(id-1)%color.length]}`}></div>
<h3 className="single-project-title"> <h3 className="single-project-title">
{title} {title}
{school ? ( {school ? (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="#D95F46" width="1.25em" height="1.25em"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="#D95F46" width="1em" height="1em">
<path d="M80 259.8L289.2 345.9C299 349.9 309.4 352 320 352C330.6 352 341 349.9 350.8 345.9L593.2 246.1C602.2 242.4 608 233.7 608 224C608 214.3 602.2 205.6 593.2 201.9L350.8 102.1C341 98.1 330.6 96 320 96C309.4 96 299 98.1 289.2 102.1L46.8 201.9C37.8 205.6 32 214.3 32 224L32 520C32 533.3 42.7 544 56 544C69.3 544 80 533.3 80 520L80 259.8zM128 331.5L128 448C128 501 214 544 320 544C426 544 512 501 512 448L512 331.4L369.1 390.3C353.5 396.7 336.9 400 320 400C303.1 400 286.5 396.7 270.9 390.3L128 331.4z"/> <path d="M80 259.8L289.2 345.9C299 349.9 309.4 352 320 352C330.6 352 341 349.9 350.8 345.9L593.2 246.1C602.2 242.4 608 233.7 608 224C608 214.3 602.2 205.6 593.2 201.9L350.8 102.1C341 98.1 330.6 96 320 96C309.4 96 299 98.1 289.2 102.1L46.8 201.9C37.8 205.6 32 214.3 32 224L32 520C32 533.3 42.7 544 56 544C69.3 544 80 533.3 80 520L80 259.8zM128 331.5L128 448C128 501 214 544 320 544C426 544 512 501 512 448L512 331.4L369.1 390.3C353.5 396.7 336.9 400 320 400C303.1 400 286.5 396.7 270.9 390.3L128 331.4z"/>
</svg> </svg>
) : null} ) : null}
</h3> </h3>
</div> </div>
{endYear === null ? ( {endYear === null ? (
<p className="single-project-years">{beginningYear + ' in progress'}</p> <p className="single-project-years">{beginningYear + ' in progress'}</p>
) : beginningYear === endYear ? ( ) : beginningYear === endYear ? (
<p className="single-project-years">{beginningYear}</p> <p className="single-project-years">{beginningYear}</p>
) : ( ) : (
<p className="single-project-years">{beginningYear + ' ' + endYear}</p> <p className="single-project-years">{beginningYear + ' ' + endYear}</p>
)} )}
</div> </div>
<div className="single-project-bottom-container"> <div className="single-project-bottom-container">
<p className="single-project-description" style={{ whiteSpace: "pre-line" }}> <p className="single-project-description" style={{ whiteSpace: "pre-line" }}>
{description} {description}
</p> </p>
<ul className="single-project-skills-list"> <ul className="single-project-skills-list">
{skills.map((skill) => ( {skills.map((skill) => (
<li key={skill}> <li key={skill}>
<SkillCard text={skill} /> <SkillCard text={skill} />
</li> </li>
))} ))}
</ul> </ul>
<p className="single-project-link">Learn more</p> </div>
</div> </div>
</div> </div>
</div>
); );
} }

View File

@ -3,7 +3,7 @@
font-weight: 400; font-weight: 400;
background-color: #0D0D0D; background-color: #0D0D0D;
--title-color: #EAEAEA; --title-color: #EAEAEA;
--text-color: #B0B0B0; --text-color: #7c7c7c;
--important-color: #D95F46; --important-color: #D95F46;
} }
@ -16,8 +16,6 @@ body {
margin: 0; margin: 0;
display: flex; display: flex;
place-items: center; place-items: center;
min-width: 320px;
min-height: 100vh;
} }
.section-title { .section-title {

View File

@ -0,0 +1,42 @@
import { useParams } from "react-router-dom";
import React, { useEffect, useState } from "react";
import NavBar from "../components/NavBar/NavBar.jsx";
import ProjectDetails from "../components/ProjectDetails/ProjectDetails.jsx";
import Footer from "../components/Footer/Footer.jsx";
function ProjectDetailsPage() {
const { id } = useParams();
const [project, setProject] = useState([]);
const [error, setError] = useState(null);
useEffect(() => {
const fetchProject = async () => {
try {
const response = await fetch(`/api/longProjects/${id}`);
if (!response.ok) {
throw new Error(`Erreur HTTP: ${response.status}`);
}
const data = await response.json();
setProject(data);
} catch (err) {
setError(err.message);
}
};
fetchProject();
}, [id]);
if (error) {
return <p>Erreur : {error}</p>;
}
return (
<div>
<ProjectDetails project={project}/>
<Footer/>
</div>
);
}
export default ProjectDetailsPage;