Skip to content

Commit

Permalink
style: UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Jan 24, 2024
1 parent e125d07 commit 79b1982
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 87 deletions.
3 changes: 3 additions & 0 deletions public/images/Blog/category-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Blog/BannerGradientForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BannerGradientForm = ({ title, subtitle }: { title: string; subtitle: stri
{subtitle}
</Typography>
</Grid>
<Grid item xs={12} md={6} display="flex" alignItems="center">
<Grid item xs={12} md={5} display="flex" alignItems="center">
<form
className={css.form}
onSubmit={(e) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Blog/BannerGradientForm/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
border-radius: 24px;
color: var(--mui-palette-text-dark);
padding: 60px 24px;
margin-top: 60px;
margin-top: 120px;
justify-content: space-between;
position: relative;
background: rgba(15, 255, 128, 1);
background-image: linear-gradient(-45deg, rgba(15, 255, 128, 1) 0%, rgba(94, 221, 255, 1) 100%);
}

.form {
width: 100%;
margin: 0px;
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/BlogHome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const BlogHome = (props: BlogHomeProps) => {

<FeaturedPost {...featuredPost} />

<Typography variant="h3" mt={{ xs: '60px', md: '100px' }} mb={4}>
<Typography variant="h2" mt={{ xs: '60px', md: '100px' }} mb={4}>
Trending
</Typography>
<Grid container spacing={{ xs: '30px', md: 2 }}>
Expand Down
18 changes: 12 additions & 6 deletions src/components/Blog/Card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Link from 'next/link'
import { Typography } from '@mui/material'
import css from '../styles.module.css'
import { Box, Typography } from '@mui/material'
import css from './styles.module.css'
import { calculateReadingTime } from '@/components/Blog/utils/calculateReadingTime'
import Tags from '@/components/Blog/Tags'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'

const Card = (props: any) => {
const { slug, title, content, coverImage, tags, category } = props.fields
Expand All @@ -19,18 +20,23 @@ const Card = (props: any) => {
<img src={image.src} alt={image.alt} className={css.cardImage} />

<div className={css.cardBody}>
<div className={css.metaStart}>
<Typography>#{category}</Typography>
<div className={css.meta}>
<Typography className={css.category}>
<CategoryIcon />
{category}
</Typography>
<Typography variant="caption">{calculateReadingTime(content)}min</Typography>
</div>

<div className={css.cardTitle}>
<div className={css.title}>
<Typography variant="h4">{title}</Typography>
</div>

<span style={{ flexGrow: 1 }} />

<Tags tags={tags} />
<Box mt={2}>
<Tags tags={tags} />
</Box>
</div>
</div>
)
Expand Down
61 changes: 61 additions & 0 deletions src/components/Blog/Card/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.postCard {
height: 100%;
position: relative;
display: flex;
flex-direction: column;
border-radius: 8px;
border: 1px solid var(--mui-palette-border-main);
overflow: hidden;
transition-duration: var(--transition-duration);
}

.postCard:hover {
border: 1px solid var(--mui-palette-primary-main);
}

.postCard:hover .cardImage {
border-bottom: 1px solid var(--mui-palette-primary-main);
}

.link {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}

.cardImage {
height: 200px;
object-fit: cover;
object-position: center left;
border-bottom: 1px solid var(--mui-palette-border-main);
transition-duration: var(--transition-duration);
}

.cardBody {
padding: 24px 16px;
display: flex;
flex-direction: column;
flex-grow: 1;
}

.meta {
display: flex;
gap: 8px;
align-items: baseline;
}

.category {
display: flex;
gap: 4px;
align-items: baseline;
}

.title {
margin-top: 16px;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
26 changes: 18 additions & 8 deletions src/components/Blog/FeaturedPost/index.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
import Tags from '@/components/Blog/Tags'
import { Grid, Link, Typography } from '@mui/material'
import { Box, Grid, Link, Typography } from '@mui/material'
import css from './styles.module.css'
import { formatBlogDate } from '@/components/Blog/utils/formatBlogDate'
import { calculateReadingTime } from '@/components/Blog/utils/calculateReadingTime'
import { type BlogPostEntry } from '@/components/Blog/Post'
import { isAsset, isEntryTypeTag } from '@/lib/typeGuards'

const FeaturedPost = (props: BlogPostEntry) => {
const { slug, coverImage, category, date, title, excerpt, tags, content } = props.fields

return (
<Grid container columnSpacing="60px" rowGap={3} mt="60px">
<Grid item md={7}>
<Link href={`/blog/${slug}`}>
<img src={image.src} alt={image.alt} className={css.image} />
</Link>
{isAsset(coverImage) && coverImage.fields.file?.url ? (
<Link href={`/blog/${slug}`}>
<img src={coverImage.fields.file.url} alt={coverImage.fields.title} className={css.image} />
</Link>
) : undefined}
</Grid>

<Grid item md={5} className={css.body}>
<div className={css.meta}>
<Typography variant="h4">#{category}</Typography>
<Typography variant="caption">{calculateReadingTime(content)}min</Typography>
<div className={css.metaStart}>
<Typography variant="h4">#{category}</Typography>
<Typography variant="caption">{calculateReadingTime(content)}min</Typography>
</div>
<Typography variant="caption">{formatBlogDate(date)}</Typography>
</div>
<Typography variant="h3" className={css.title}>
{title}
<Link href={`/blog/${slug}`}>{title}</Link>
</Typography>
<Typography className={css.excerpt}>{excerpt}</Typography>
<Tags tags={tags} />

<span style={{ flexGrow: 1 }} />
<Box mt={2}>
<Tags tags={tags.filter(isEntryTypeTag)} />
</Box>
</Grid>
</Grid>
)
Expand Down
19 changes: 19 additions & 0 deletions src/components/Blog/FeaturedPost/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
border: 1px solid transparent;
border-radius: 6px;
transition-duration: var(--transition-duration);
border: 1px solid var(--mui-palette-border-main);
}

.image:hover {
Expand All @@ -24,11 +25,29 @@
align-items: baseline;
}

.metaStart {
display: flex;
gap: 8px;
flex-wrap: nowrap;
align-items: baseline;
}

.title,
.excerpt {
margin-top: 16px;
}

.title a {
color: var(--mui-palette-text-primary);
text-decoration-color: var(--mui-palette-background-default);
transition-duration: var(--transition-duration);
}

.title a:hover {
color: var(--mui-palette-primary-main);
text-decoration-color: var(--mui-palette-primary-main);
}

@media (min-width: 900px) {
.title {
margin-top: 24px;
Expand Down
12 changes: 9 additions & 3 deletions src/components/Blog/Post/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from 'next/image'
import { Container, Divider, Grid, Typography } from '@mui/material'
import { Box, Container, Divider, Grid, Typography } from '@mui/material'
import { type Entry } from 'contentful'
import { type TypePostSkeleton } from '@/contentful/types'
import { formatBlogDate } from '@/components/Blog/utils/formatBlogDate'
Expand All @@ -13,6 +13,7 @@ import Authors from '@/components/Blog/Authors'
import RichText from '@/components/Campaign/RichText'
import ContentTable from '@/components/Blog/ContentTable'
import RelatedPosts from '@/components/Blog/RelatedPosts'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'
import css from '../styles.module.css'

export type BlogPostEntry = Entry<TypePostSkeleton, undefined, string>
Expand All @@ -37,7 +38,10 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => {

<div className={css.meta}>
<div className={css.metaStart}>
<Typography>#{category}</Typography>
<Typography className={css.category}>
<CategoryIcon />
{category}
</Typography>
<Typography variant="caption">{calculateReadingTime(content)}min</Typography>
</div>
<Typography variant="caption">{formatBlogDate(date)}</Typography>
Expand All @@ -51,7 +55,9 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => {
{excerpt}
</Typography>

<Tags tags={tags.filter(isEntryTypeTag)} />
<Box mt={{ xs: 2, md: 3 }}>
<Tags tags={tags.filter(isEntryTypeTag)} />
</Box>

<Authors authors={authors.filter(isEntryTypeAuthor)} />

Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ProgressBar = () => {

return (
<div className={css.progressBar}>
<LinearProgress variant="determinate" color="primary" value={readProgress} style={{ left: '0' }} />
<LinearProgress variant="determinate" value={readProgress} className={css.progressBar} />
</div>
)
}
Expand Down
22 changes: 12 additions & 10 deletions src/components/Blog/SearchFilterResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,18 @@ const SearchFilterResults = ({ allPosts, categories }: { allPosts: BlogPostEntry
</Grid>

{visibleResults.length > 0 ? (
<Grid container className={css.resultsWrapper}>
{visibleResults.map((post: any, index: number) => (
// TODO: remove the index when enough posts are available
<Grid key={`${post.fields.slug}-$${index}`} item xs={12} md={4}>
<Card {...post} />
</Grid>
))}
<>
<Grid container className={css.resultsWrapper}>
{visibleResults.map((post: any, index: number) => (
// TODO: remove the index when enough posts are available
<Grid key={`${post.fields.slug}-$${index}`} item xs={12} md={4}>
<Card {...post} />
</Grid>
))}
</Grid>

{shouldShowMoreButton && (
<Grid item xs={12} display="flex" justifyContent="center">
<Box display="flex" justifyContent="center" mt="60px">
<NextLink
href={{ query: { [PAGE_QUERY_PARAM]: page + 1 } }}
shallow
Expand All @@ -137,9 +139,9 @@ const SearchFilterResults = ({ allPosts, categories }: { allPosts: BlogPostEntry
Show more
</Button>
</NextLink>
</Grid>
</Box>
)}
</Grid>
</>
) : (
<div style={{ textAlign: 'center' }}>
<SearchIcon />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Blog/SearchFilterResults/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
border-radius: 6px;
border: 1px solid var(--mui-palette-border-light);
overflow: hidden;
margin-top: 30px;
margin-top: 40px;
}

.filterCard {
Expand All @@ -22,7 +22,7 @@
}

.resultsWrapper {
margin-top: 30px;
margin-top: 60px;
gap: 30px;
}

Expand Down
Loading

0 comments on commit 79b1982

Please sign in to comment.