mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:39:45 +00:00
Получение, хранение и отображение проектов; новый компонент ProjectList, перенос к нему ProjectCard; реализация страниц проектов
This commit is contained in:
1 parent
81d2a009e0
commit
0ef02b2220
13 files changed
+132
-115
No files matched your search
@@ -1,7 +1,7 @@
|
||||
function MediaContainer({ src, key }) {
|
||||
function MediaContainer({ src }) {
|
||||
return (
|
||||
<div className="media-container">
|
||||
<img className="image" alt="" src={src} key={key} />
|
||||
<img className="image" alt="" src={src} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import "./ProjectCard.styles.scss";
|
||||
|
||||
function ProjectCard({ project }) {
|
||||
return (
|
||||
<Link className="card" to={ `/projects/` + project.id }>
|
||||
<img className="image" alt="project_image" src={project.preview}></img>
|
||||
<div className="label">
|
||||
{ `Проект "${project.name}"` }
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProjectCard;
|
||||
@@ -0,0 +1,32 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
|
||||
.card {
|
||||
display: block;
|
||||
position: relative;
|
||||
height: 250px;
|
||||
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: transparent;
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
left: 22px;
|
||||
bottom: 16px;
|
||||
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
line-height: 24px;
|
||||
color: $text-card-project;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import ProjectCard from "./ProjectCard";
|
||||
import { getProjects } from "../../api";
|
||||
|
||||
import "./ProjectList.styles.scss";
|
||||
|
||||
function ProjectList({ laboratory }) {
|
||||
const [projectList, setProjectList] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
const newProjectList = await getProjects(laboratory);
|
||||
setProjectList(newProjectList);
|
||||
};
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="row project-list">
|
||||
{Object.keys(projectList).map(id => <ProjectCard key={id} project={projectList[id]} />)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProjectList;
|
||||
@@ -0,0 +1,12 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
|
||||
.project-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 32px;
|
||||
|
||||
.card {
|
||||
flex: 1 1 30%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./ProjectList";
|
||||
@@ -4,4 +4,5 @@ export { default as Footer } from './Footer';
|
||||
export { default as MediaBlock } from './MediaBlock';
|
||||
export { default as MediaContainer } from './MediaContainer';
|
||||
export { default as Navbar } from './Navbar';
|
||||
export { default as Slider } from './Slider';
|
||||
export { default as Slider } from './Slider';
|
||||
export { default as ProjectList } from './Projects';
|
||||
Reference in new issue
Block a user