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.

Commit 02c7efb

Browse files
suthesankSuthesanSean Ho
authored
Suthesh/fix-dots-nextline (#2077)
* fix dots * added comment * split featured and non featured video query * Update src/pages/academy/components/video-banner/_DBanner.js Co-authored-by: Sean Ho <[email protected]> Co-authored-by: Suthesan <[email protected]> Co-authored-by: Sean Ho <[email protected]>
1 parent 32c7834 commit 02c7efb

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

src/common/utility.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,13 @@ export const getVideoObject = (video_data) => {
287287
}
288288
}
289289

290+
// remove spaces before appending "..." on truncated strings
291+
const getLimit = (input, limit) => {
292+
if (input[limit - 1] === ' ') {
293+
return limit - 1
294+
}
295+
return limit
296+
}
297+
290298
export const truncateString = (input, limit) =>
291-
input.length > limit ? `${input.substring(0, limit)}...` : input
299+
input.length > limit ? `${input.substring(0, getLimit(input, limit))}...` : input

src/pages/academy/_video-banner.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ import PropTypes from 'prop-types'
33
import Dbanner from './components/video-banner/_DBanner'
44
import { Flex } from 'components/containers'
55

6-
const DVideoBanner = ({ video_list_data }) => {
6+
const DVideoBanner = ({ featured_video_list_data, non_featured_video_list_data }) => {
77
return (
88
<Flex>
9-
{video_list_data && video_list_data.length && <Dbanner video_list={video_list_data} />}
9+
{non_featured_video_list_data && non_featured_video_list_data.length && (
10+
<Dbanner
11+
featured_video_list={featured_video_list_data}
12+
non_featured_video_list={non_featured_video_list_data}
13+
/>
14+
)}
1015
</Flex>
1116
)
1217
}
1318

1419
DVideoBanner.propTypes = {
15-
video_list_data: PropTypes.array,
20+
featured_video_list_data: PropTypes.array,
21+
non_featured_video_list_data: PropTypes.array,
1622
}
1723

1824
export default DVideoBanner

src/pages/academy/components/video-banner/_DBanner.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ const StyledDot = styled.img`
7070
margin: 0 10px 4px;
7171
`
7272

73-
const Dbanner = ({ video_list }) => {
73+
const Dbanner = ({ featured_video_list, non_featured_video_list }) => {
7474
const [show, setShow] = useState(false)
7575
const handleCloseVideo = () => setShow(false)
7676
const handleOpenVideo = () => setShow(true)
77-
const featured_video = video_list.find((v) => v.featured)
78-
const filtered_video = video_list.filter((v) => v !== featured_video)
77+
78+
let featured_video
79+
if (featured_video_list && featured_video_list.length) {
80+
featured_video = featured_video_list[0]
81+
} else {
82+
featured_video = non_featured_video_list[0]
83+
non_featured_video_list.shift()
84+
}
7985

8086
const {
8187
published_date,
@@ -158,7 +164,7 @@ const Dbanner = ({ video_list }) => {
158164
</Header>
159165
</Flex>
160166
</Flex>
161-
<VideoCarousel carousel_items={filtered_video} />
167+
<VideoCarousel carousel_items={non_featured_video_list} />
162168
</Container>
163169
</ParentWrapper>
164170
{show && <VideoPlayer video_src={video_url} closeVideo={handleCloseVideo} />}
@@ -167,7 +173,8 @@ const Dbanner = ({ video_list }) => {
167173
}
168174

169175
Dbanner.propTypes = {
170-
video_list: PropTypes.array,
176+
featured_video_list: PropTypes.array,
177+
non_featured_video_list: PropTypes.array,
171178
}
172179

173180
export default Dbanner

src/pages/academy/index.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,29 @@ export const query = graphql`
7979
}
8080
}
8181
}
82+
featured_video: videos(
83+
filter: { status: { _eq: "published" }, featured: { _eq: true } }
84+
sort: "-published_date"
85+
limit: 1
86+
) {
87+
video_title
88+
published_date
89+
video_description
90+
video_duration
91+
featured
92+
video_thumbnail {
93+
id
94+
title
95+
}
96+
video_file {
97+
id
98+
}
99+
tags {
100+
tags_id {
101+
tag_name
102+
}
103+
}
104+
}
82105
recent: blog(
83106
filter: { status: { _eq: "published" } }
84107
sort: "-published_date"
@@ -161,7 +184,8 @@ const DerivBlog = ({ data }) => {
161184

162185
const recent_data = data.directus.recent
163186
const featured_data = data.directus.featured
164-
const video_list_data = data.directus.videos
187+
const non_featured_video_list_data = data.directus.videos
188+
const featured_video_list_data = data.directus.featured_video
165189

166190
return (
167191
<Layout type="academy" is_ppc_redirect={true}>
@@ -196,7 +220,10 @@ const DerivBlog = ({ data }) => {
196220
</Carousel>
197221
</MainWrapper>
198222
<RecentFeaturedPosts recent_data={recent_data} featured_data={featured_data} />
199-
<DVideoBanner video_list_data={video_list_data} />
223+
<DVideoBanner
224+
featured_video_list_data={featured_video_list_data}
225+
non_featured_video_list_data={non_featured_video_list_data}
226+
/>
200227
<MarketNews data={market_news_data} />
201228
<Container>
202229
<Flex

0 commit comments

Comments
 (0)