-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
171 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.action-area { | ||
height: 100% !important; | ||
display: flex !important; | ||
justify-content: flex-start !important; | ||
align-items: flex-start !important; | ||
flex-direction: column !important; | ||
} | ||
|
||
.image { | ||
height: 100px; | ||
width: 100%; | ||
} | ||
|
||
.description { | ||
margin-bottom: 1rem !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Card as MuiCard, CardActionArea, CardContent, CardMedia, Typography } from '@mui/material'; | ||
import Contentful from 'contentful'; | ||
|
||
import { TagBlock } from 'Components/TagBlock'; | ||
|
||
import styles from './Card.module.css'; | ||
|
||
interface CardProps { | ||
image?: Contentful.Asset; | ||
title: Contentful.EntryFields.Text; | ||
description?: Contentful.EntryFields.Text; | ||
tags?: Contentful.TagLink[]; | ||
onClick: () => void; | ||
} | ||
|
||
export const Card = ({ onClick, image, title, description, tags }: CardProps) => { | ||
return ( | ||
<MuiCard className={styles.container}> | ||
<CardActionArea className={styles['action-area']} onClick={onClick}> | ||
{image && <CardMedia className={styles.image} image={image.fields.file.url} title="foofoo" />} | ||
<CardContent className={styles.content}> | ||
<Typography className={styles.title} gutterBottom variant="h5" component="div"> | ||
{title} | ||
</Typography> | ||
{description && ( | ||
<Typography className={styles.description} variant="body2" color="text.secondary"> | ||
{description} | ||
</Typography> | ||
)} | ||
{tags && <TagBlock tags={tags} />} | ||
</CardContent> | ||
</CardActionArea> | ||
</MuiCard> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Card'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './useExperienceApi'; | ||
export * from './useJournalApi'; | ||
export * from './usePageContentApi'; | ||
export * from './useProjectsApi'; | ||
export * from './useSkillsApi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { useContentfulClient } from '../useContentfulClient'; | ||
|
||
import { ProjectItem } from 'Types'; | ||
|
||
export const useProjectsApi = () => { | ||
const { fetchEntries } = useContentfulClient(); | ||
|
||
return useQuery({ | ||
queryKey: ['useProjectsApi'], | ||
queryFn: () => fetchEntries<ProjectItem>('project', { | ||
order: '-sys.createdAt', | ||
}), | ||
staleTime: Infinity, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { Card, ErrorAlert, Grid, LoadingSpinner, NoDataAlert } from 'Components'; | ||
|
||
import { useProjectsApi } from 'Hooks'; | ||
|
||
export const ProjectsGrid = () => { | ||
const { data, isLoading, error } = useProjectsApi(); | ||
const navigate = useNavigate(); | ||
|
||
const navigateProjectItem = (slug: string) => { | ||
navigate(`/projects/${slug}`); | ||
}; | ||
|
||
if (isLoading) { | ||
return <LoadingSpinner />; | ||
} | ||
|
||
if (error) { | ||
return <ErrorAlert error="Error retrieving projects list" />; | ||
} | ||
|
||
if (!isLoading && !error && !data?.items?.length) { | ||
return <NoDataAlert />; | ||
} | ||
|
||
console.log(data); | ||
|
||
return ( | ||
<Grid> | ||
{data?.items?.map(project => ( | ||
<Card | ||
key={project.sys.id} | ||
image={project?.fields?.heroImage} | ||
title={project.fields.title} | ||
description={project.fields.shortDescription} | ||
tags={project.metadata.tags} | ||
onClick={() => navigateProjectItem(project.fields.slug)} | ||
/> | ||
))} | ||
</Grid> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ProjectsGrid'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const ProjectsItemPage = () => { | ||
return ( | ||
<section> | ||
projects item here | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect } from 'react'; | ||
import { Helmet } from 'react-helmet-async'; | ||
import { useLocation,useOutlet } from 'react-router-dom'; | ||
|
||
import { Title } from 'Components'; | ||
import { ProjectsGrid } from 'Modules'; | ||
|
||
import { useUi } from 'Context/uiContext'; | ||
import { useAnalytics } from 'Hooks/useAnalytics/useAnalytics'; | ||
|
||
export const ProjectsPage = () => { | ||
const outlet = useOutlet(); | ||
const { pageTitle } = useUi(); | ||
const { pageView } = useAnalytics(); | ||
const { pathname } = useLocation(); | ||
|
||
useEffect(() => { | ||
if (!outlet) { | ||
pageView(pathname); | ||
} | ||
}); | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<title>Projects {pageTitle}</title> | ||
</Helmet> | ||
|
||
<Title title="Projects" /> | ||
|
||
<ProjectsGrid /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ProjectsItemPage'; | ||
export * from './ProjectsPage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import Contentful from 'contentful'; | ||
|
||
export interface ProjectItem { | ||
title: Contentful.EntryFields.Text; | ||
slug: Contentful.EntryFields.Text; | ||
heroImage: Contentful.Asset; | ||
title: Contentful.EntryFields.Text; | ||
shortDescription: Contentful.EntryFields.Text; | ||
description: Contentful.EntryFields.RichText; | ||
url: Contentful.EntryFields.Text; | ||
repo: Contentful.EntryFields.Text; | ||
description: Contentful.EntryFields.RichText; | ||
image: Contentful.Asset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters