Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

feat: replace vertical carousel with overflow scroll #2155

Merged
4 commits merged into from Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 79 additions & 106 deletions src/pages/academy/_recent-featured-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,9 @@ import {
} from './components/recent-featured-posts/_style'
import { StandardImgWrapper } from './common/_styles'
import { convertDate, getAssetUrl } from 'common/utility'
import { QueryImage, Carousel, Tabs, Header } from 'components/elements'
import { QueryImage, Tabs, Header } from 'components/elements'
import { localize, WithIntl, Localize } from 'components/localization'

// Settings for carousel
const settings = {
options: {
axis: 'y',
align: 'start',
slidesToScroll: 3,
},
view_port: {
height: 'auto',
},
vertical_container: {
flexDirection: 'column',
height: '464px',
width: '100%',
},
}

const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
const recents = recent_data.slice(1)
const headline_recent = recent_data[0]
Expand Down Expand Up @@ -105,50 +88,45 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
</RedirectLink>
</LeftContent>
<RightContent>
<Carousel {...settings}>
{recents.map((article) => {
return (
<RedirectLink
to={`/academy/blog/posts/${article.slug}`}
key={article.slug}
>
<SmallArticle>
<SmallArticleLeftContent>
<StandardImgWrapper
width="143px"
height="85.8px"
tabletL_width="113px"
tabletL_height="68px"
>
<QueryImage
className="standard-query-img"
data={article?.main_image?.imageFile}
alt={
article?.main_image?.description ||
''
}
/>
</StandardImgWrapper>
</SmallArticleLeftContent>
<SmallArticleRightContent>
<SmallArticleTopContent>
<Header as="p" type="paragraph-1">
{article.blog_title}
</Header>
</SmallArticleTopContent>
<SmallArticleDateTimeDesktop>
{article?.published_date &&
convertDate(article?.published_date)}
<DotIcon src={Dot} />
{article.read_time_in_minutes}{' '}
<Localize translate_text="min read" />
</SmallArticleDateTimeDesktop>
</SmallArticleRightContent>
</SmallArticle>
</RedirectLink>
)
})}
</Carousel>
{recents.map((article) => {
return (
<RedirectLink
to={`/academy/blog/posts/${article.slug}`}
key={article.slug}
>
<SmallArticle>
<SmallArticleLeftContent>
<StandardImgWrapper
width="143px"
height="85.8px"
tabletL_width="113px"
tabletL_height="68px"
>
<QueryImage
className="standard-query-img"
data={article?.main_image?.imageFile}
alt={article?.main_image?.description || ''}
/>
</StandardImgWrapper>
</SmallArticleLeftContent>
<SmallArticleRightContent>
<SmallArticleTopContent>
<Header as="p" type="paragraph-1">
{article.blog_title}
</Header>
</SmallArticleTopContent>
<SmallArticleDateTimeDesktop>
{article?.published_date &&
convertDate(article?.published_date)}
<DotIcon src={Dot} />
{article.read_time_in_minutes}{' '}
<Localize translate_text="min read" />
</SmallArticleDateTimeDesktop>
</SmallArticleRightContent>
</SmallArticle>
</RedirectLink>
)
})}
</RightContent>
</ArticleContentWrapper>
</Tabs.Panel>
Expand Down Expand Up @@ -192,50 +170,45 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
</RedirectLink>
</LeftContent>
<RightContent>
<Carousel {...settings}>
{featureds.map((article) => {
return (
<RedirectLink
to={`/academy/blog/posts/${article.slug}`}
key={article.slug}
>
<SmallArticle>
<SmallArticleLeftContent>
<StandardImgWrapper
width="143px"
height="85.8px"
tabletL_width="113px"
tabletL_height="68px"
>
<QueryImage
className="standard-query-img"
data={article.main_image.imageFile}
alt={
article?.main_image?.description ||
''
}
/>
</StandardImgWrapper>
</SmallArticleLeftContent>
<SmallArticleRightContent>
<SmallArticleTopContent>
<Header as="p" type="paragraph-1">
{article.blog_title}
</Header>
</SmallArticleTopContent>
<SmallArticleDateTimeDesktop>
{article?.published_date &&
convertDate(article?.published_date)}
<DotIcon src={Dot} />
{article.read_time_in_minutes}{' '}
<Localize translate_text="min read" />
</SmallArticleDateTimeDesktop>
</SmallArticleRightContent>
</SmallArticle>
</RedirectLink>
)
})}
</Carousel>
{featureds.map((article) => {
return (
<RedirectLink
to={`/academy/blog/posts/${article.slug}`}
key={article.slug}
>
<SmallArticle>
<SmallArticleLeftContent>
<StandardImgWrapper
width="143px"
height="85.8px"
tabletL_width="113px"
tabletL_height="68px"
>
<QueryImage
className="standard-query-img"
data={article.main_image.imageFile}
alt={article?.main_image?.description || ''}
/>
</StandardImgWrapper>
</SmallArticleLeftContent>
<SmallArticleRightContent>
<SmallArticleTopContent>
<Header as="p" type="paragraph-1">
{article.blog_title}
</Header>
</SmallArticleTopContent>
<SmallArticleDateTimeDesktop>
{article?.published_date &&
convertDate(article?.published_date)}
<DotIcon src={Dot} />
{article.read_time_in_minutes}{' '}
<Localize translate_text="min read" />
</SmallArticleDateTimeDesktop>
</SmallArticleRightContent>
</SmallArticle>
</RedirectLink>
)
})}
</RightContent>
</ArticleContentWrapper>
</Tabs.Panel>
Expand Down
17 changes: 15 additions & 2 deletions src/pages/academy/components/recent-featured-posts/_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ export const LeftContent = styled(Flex)`
`

export const RightContent = styled(Flex)`
flex-direction: column;
justify-content: start;
@media ${device.laptopM} {
flex-direction: column;
max-height: 464px;
padding-right: 8px;
overflow: hidden auto;

@media ${device.desktopL} {
max-height: 600px;
}
@media (max-width: 1280px) {
max-height: 432px;
}
`

Expand Down Expand Up @@ -73,6 +81,11 @@ export const MainArticle = styled(Flex)`
transform: scale(1.02);
}

@media ${device.desktopL} {
width: 1000px;
max-height: 600px;
}

@media (max-width: 1280px) {
width: 720px;
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/academy/components/video-banner/_DBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const ParentWrapper = styled(Flex)`
background-size: cover;
height: auto;
padding: 160px 0 80px;
max-width: 1600px;

@media ${device.tabletL} {
/* prettier-ignore */
Expand Down
8 changes: 4 additions & 4 deletions src/pages/academy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const query = graphql`
recent: blog(
filter: { status: { _eq: "published" } }
sort: "-published_date"
limit: 6
limit: 8
) {
id
main_image {
Expand Down Expand Up @@ -220,7 +220,7 @@ export const query = graphql`
recent_eu: blog(
filter: { status: { _eq: "published" }, hide_for_eu: { _eq: false } }
sort: "-published_date"
limit: 6
limit: 8
) {
id
main_image {
Expand Down Expand Up @@ -249,7 +249,7 @@ export const query = graphql`
featured: blog(
filter: { status: { _eq: "published" }, featured: { _eq: true } }
sort: "-published_date"
limit: 6
limit: 8
) {
id
main_image {
Expand Down Expand Up @@ -281,7 +281,7 @@ export const query = graphql`
hide_for_eu: { _eq: false }
}
sort: "-published_date"
limit: 6
limit: 8
) {
id
main_image {
Expand Down