Сверстать страницу проектов, сделать временное хранилище проектов, скорректировать маршрутизацию

This commit is contained in:
ifraimka committed 2024-05-12 23:08:37 +03:00
1 parent b4fdabc853
commit cb69de3427
9 files changed
+63 -14

No files matched your search

+2 -2
View File
@@ -4,10 +4,10 @@ function Projects() {
return (
<>
<PageHeader className="header">
<h1>Projects</h1>
<h1>Проекты</h1>
</PageHeader>
<PageContent className="content">
</PageContent>
</>
);
+30
View File
@@ -0,0 +1,30 @@
import { useLoaderData, useParams } from "react-router-dom";
import { PageHeader, PageContent } from "../../components";
import { getProjects } from "../../../api";
export async function loader() {
const projects = await getProjects();
return { projects };
}
function Project() {
const params = useParams();
const projectID = params.id;
const { projects } = useLoaderData();
const project = projects[projectID];
return (
<>
<PageHeader className="header">
<h1>{project.name}</h1>
</PageHeader>
<PageContent className="content">
<p>{project.desc}</p>
</PageContent>
</>
);
}
export default Project;
+1
View File
@@ -0,0 +1 @@
export { default as Project, loader } from "./Project";
+1 -7
View File
@@ -1,7 +1,7 @@
import { Outlet } from "react-router-dom";
import { createContext, useEffect } from 'react';
import { getMedia } from "../../api";
import { getProjects } from "../../api";
import useElementOnScreen from '../../lib/useElementOnScreen';
import Navbar from '../../components/Navbar';
import Footer from '../../components/Footer';
@@ -9,11 +9,6 @@ import './Root.styles.scss';
export const RootContext = createContext();
async function loader() {
const media = getMedia();
return { media };
}
function Root() {
const [setRef, isVisible] = useElementOnScreen({
root: null,
@@ -43,5 +38,4 @@ function Root() {
);
}
export { loader };
export default Root;
+1 -1
View File
@@ -1 +1 @@
export { default as Root, RootContext, loader } from './Root';
export { default as Root, RootContext } from './Root';
+1 -1
View File
@@ -1,4 +1,4 @@
export { Root, loader } from './Root';
export { Root } from './Root';
export { default as ErrorPage} from './ErrorPage';
export { default as Main } from './Main';
export { default as AboutUs } from './AboutUs';