Skip to content

Commit bcac91f

Browse files
committed
Creado loader y mejorada la carga de los proyectos
1 parent 8cfa2e0 commit bcac91f

File tree

3 files changed

+74
-10
lines changed

3 files changed

+74
-10
lines changed

src/components/Loader/Loader.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import './_Loader.scss';
2+
3+
export default function Loader() {
4+
return (
5+
<div className="loader">
6+
<span className="bar"></span>
7+
<span className="bar"></span>
8+
<span className="bar"></span>
9+
</div>
10+
);
11+
}

src/components/Loader/_Loader.scss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.loader {
2+
display: flex;
3+
align-items: center;
4+
margin-inline: auto;
5+
margin-block: 5% 35%;
6+
}
7+
8+
.bar {
9+
display: inline-block;
10+
width: 3px;
11+
height: 20px;
12+
background-color: rgba(255, 255, 255, 0.5);
13+
border-radius: 10px;
14+
animation: scale-up4 1s linear infinite;
15+
}
16+
17+
.bar:nth-child(2) {
18+
height: 35px;
19+
margin: 0 5px;
20+
animation-delay: 0.25s;
21+
}
22+
23+
.bar:nth-child(3) {
24+
animation-delay: 0.5s;
25+
}
26+
27+
@keyframes scale-up4 {
28+
20% {
29+
background-color: #ffff;
30+
transform: scaleY(1.5);
31+
}
32+
33+
40% {
34+
transform: scaleY(1);
35+
}
36+
}

src/components/ProjectsSection/ProjectsSection.jsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import { useState } from 'react';
2-
import ProjectCard from '../ProjectCard/ProjectCard';
32
import './_ProjectsSection.scss';
43
import { getJSON } from '/src/utils/projects/tarjetasAssets';
54
import Project from '../Project/Project';
65
import { useEffect } from 'react';
6+
import Loader from '../Loader/Loader';
77

88
export default function ProjectsSection() {
99
const [category, setCategory] = useState('web');
10-
const [project, setProject] = useState({});
1110
const [tarjetasAssets, setTarjetasAssets] = useState({});
11+
const [isLoading, setIsLoading] = useState(true);
1212

1313
useEffect(() => {
14-
getJSON('/assets/json/tarjetaAssets.json').then(assets =>
15-
setTarjetasAssets(assets)
16-
);
14+
setIsLoading(true);
15+
getJSON('/assets/json/tarjetaAssets.json').then(assets => {
16+
setTarjetasAssets(assets);
17+
setTimeout(() => setIsLoading(false), 500);
18+
});
1719
}, []);
1820

19-
const categoryEntries = Object.entries(tarjetasAssets).filter(
20-
([, v]) => v.category === category
21-
);
21+
const categoryEntries = e =>
22+
Object.entries(tarjetasAssets).filter(([, v]) => v.category === e);
2223

2324
const handleSetCategory = e => {
2425
const category = e.target.id;
@@ -50,8 +51,24 @@ export default function ProjectsSection() {
5051
</li>
5152
</ul>
5253

53-
<div id={`trabajos-${category}`} className="trabajos-container">
54-
{categoryEntries.map(([key, value]) => (
54+
{isLoading && <Loader />}
55+
56+
<div
57+
className="trabajos-container"
58+
style={{ display: !isLoading && category === 'web' ? 'grid' : 'none' }}
59+
>
60+
{categoryEntries('web').map(([key, value]) => (
61+
<Project key={key} name={key} project={value} />
62+
))}
63+
</div>
64+
65+
<div
66+
className="trabajos-container"
67+
style={{
68+
display: !isLoading && category === 'movil' ? 'grid' : 'none'
69+
}}
70+
>
71+
{categoryEntries('movil').map(([key, value]) => (
5572
<Project key={key} name={key} project={value} />
5673
))}
5774
</div>

0 commit comments

Comments
 (0)