refactor: use PostsGrid for rendering related episodes

This commit is contained in:
Hossein Mehrabi 2023-08-25 00:08:06 +03:30
parent b6dffda933
commit 1498382776
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1

View File

@ -1,9 +1,8 @@
import { LPE } from '@/types/lpe.types'
import { Button, Typography } from '@acid-info/lsd-react'
import styled from '@emotion/styled'
import { useState } from 'react'
import { LPE } from '@/types/lpe.types'
import { PostCard } from '@/components/PostCard'
import { Grid, GridItem } from '@/components/Grid/Grid'
import { PostsGrid } from '../../PostsGrid'
type props = {
podcastSlug: string
@ -24,18 +23,25 @@ const RelatedEpisodes = ({ podcastSlug, relatedEpisodes }: props) => {
return (
<Container>
<Typography>More Episodes</Typography>
<EpisodeCards>
{relatedEpisodes.slice(0, showIndex).map((episode, idx: number) => (
<PostCardContainer className="w-8" key={'related-episode' + idx}>
<PostCard
size="xsmall"
displayPodcastShow={false}
contentType={LPE.PostTypes.Podcast}
data={{ ...PostCard.toData(episode), tags: [] }}
/>
</PostCardContainer>
))}
</EpisodeCards>
<PostsGrid
displayPodcastShow={false}
posts={relatedEpisodes.slice(0, showIndex)}
pattern={[{ cols: 2, size: 'xsmall' }]}
breakpoints={[
{
breakpoint: 'xs',
pattern: [{ cols: 1, size: 'small' }],
},
{
breakpoint: 'sm',
pattern: [{ cols: 1, size: 'small' }],
},
{
breakpoint: 'md',
pattern: [{ cols: 2, size: 'small' }],
},
]}
/>
{relatedEpisodes?.length > 4 && (
<ShowButton onClick={toggleShowMore}>
{showMore ? 'Show less' : 'Show more'}
@ -53,17 +59,9 @@ const Container = styled.div`
flex-direction: column;
`
const EpisodeCards = styled(Grid)`
gap: 0 16px;
`
const ShowButton = styled(Button)`
height: 40px;
margin-top: 24px;
`
const PostCardContainer = styled(GridItem)`
padding-top: 24px;
`
export default RelatedEpisodes