code/components/Home/Projects.tsx

60 lines
2.7 KiB
TypeScript
Raw Normal View History

2021-12-09 09:09:52 +00:00
import { createSignal, For, Show } from 'solid-js';
import projects from '../../config/projects';
import ProjectCard from '../Project';
function Projects() {
2021-12-09 09:09:52 +00:00
const [toggleLibrary, setToggleLibrary] = createSignal<boolean>(false);
const libraryProjects = projects.filter(project => project.type === 'library');
const moreLibraries = libraryProjects.slice(6);
const [toggleApplication, setToggleApplication] = createSignal<boolean>(false);
const applicationProjects = projects.filter(project => project.type === 'application');
const moreApplications = applicationProjects.slice(6);
return (
<>
2022-08-06 08:44:27 +00:00
<section id='projects'>
<div><h2 class='text-3xl font-bold py-2'>Library</h2></div>
<div class='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 grid-flow-row gap-4 py-8'>
2021-12-09 09:09:52 +00:00
<For each={libraryProjects.slice(0, 6)}>
{project => <ProjectCard {...project} />}
</For>
2021-12-09 09:09:52 +00:00
<Show when={moreLibraries.length > 0}>
2022-08-06 08:44:27 +00:00
<Show when={toggleLibrary()} fallback={<div onClick={() => setToggleLibrary(true)} class='text-center py-4 w-full cursor-pointer self-center'>See more libraries</div>}>
2021-12-09 09:09:52 +00:00
<For each={moreLibraries}>
{project => <ProjectCard {...project} />}
</For>
2022-08-06 08:44:27 +00:00
<div onClick={() => setToggleLibrary(false)} class='text-center py-4 w-full cursor-pointer self-center'>Show less libraries</div>
2021-12-09 09:09:52 +00:00
</Show>
</Show>
</div>
</section>
<section>
2022-08-06 08:44:27 +00:00
<div><h2 class='text-3xl font-bold py-2'>Application</h2></div>
<div class='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 grid-flow-row gap-4 py-8'>
2021-12-09 09:09:52 +00:00
<For each={applicationProjects.slice(0, 6)}>
{project => <ProjectCard {...project} />}
</For>
2021-12-09 09:09:52 +00:00
<Show when={moreApplications.length > 0}>
2022-08-06 08:44:27 +00:00
<Show when={toggleApplication()} fallback={<div onClick={() => setToggleApplication(true)} class='text-center py-4 w-full cursor-pointer self-center'>See more applications</div>}>
2021-12-09 09:09:52 +00:00
<For each={moreApplications}>
{project => <ProjectCard {...project} />}
</For>
2022-08-06 08:44:27 +00:00
<div onClick={() => setToggleApplication(false)} class='text-center py-4 w-full cursor-pointer self-center'>Show less applications</div>
2021-12-09 09:09:52 +00:00
</Show>
</Show>
</div>
</section>
2022-08-06 08:44:27 +00:00
<section class='py-4'>
<p class='text-sm text-center text-gray-100 pb-8 lg:opacity-80 hover:opacity-100 transition duration-500 ease-in-out'>
These are just a few of my projects.&nbsp;
2022-08-06 08:44:27 +00:00
<a class='hover:underline' href='https://www.github.com/aldy505'>Explore more on my Github</a>
</p>
</section>
</>
);
}
export default Projects;