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 f02f3bf

Browse files
author
NikitaK-deriv
authored
NikitaK/Add new share buttons on preview page (#2734)
* add new share button in preview in Deriv Academy * deploy issue fix * return back... * refactoring size check function
1 parent 24acf30 commit f02f3bf

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

src/pages/academy/blog/posts/preview/index.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import {
1616
SideBarContainer,
1717
Tag,
1818
PreviewContainer,
19-
SocialComponentsWrapper,
20-
LeftSocialComponents,
21-
RightSocialComponents,
2219
DesktopWrapper,
2320
MobileWrapper,
2421
StickyBreadCrumbsWrapper,
@@ -36,9 +33,17 @@ import { convertDate, isBrowser, getMinRead, truncateString } from 'common/utili
3633
import { useBrowserResize } from 'components/hooks/use-browser-resize'
3734
import { cms_assets_end_point, cms_end_point } from 'common/constants'
3835
import RightArrow from 'images/svg/tools/black-right-arrow.svg'
36+
import { useWindowSize } from 'components/hooks/use-window-size'
37+
38+
export const getTruncateLength = () => {
39+
const size = useWindowSize()
40+
if (size.width < 400) return 15
41+
else if (size.width < 475) return 30
42+
else return 60
43+
}
3944

4045
const BlogPreview = () => {
41-
const [is_mobile] = useBrowserResize(992)
46+
const [is_mobile] = useBrowserResize(972)
4247
const [prevScrollPos, setPrevScrollPos] = useState(0)
4348
const [visible, setVisible] = useState(true)
4449
const [isMounted, setMounted] = useState(false)
@@ -136,9 +141,10 @@ const BlogPreview = () => {
136141
<StyledImg src={RightArrow} height="16" width="16" />
137142
<StyledBreadcrumbsTitle>
138143
{is_mobile
139-
? truncateString(article_title, 30)
144+
? truncateString(article_title, getTruncateLength())
140145
: article_title}
141146
</StyledBreadcrumbsTitle>
147+
<SocialSharing />
142148
</Flex>
143149
</BreadcrumbsWrapper>
144150
</StickyBreadCrumbsWrapper>
@@ -283,13 +289,6 @@ const BlogPreview = () => {
283289
{footer_banner_details?.imgSrcDesktop && (
284290
<Banner detailsPreviewObj={footer_banner_details} />
285291
)}
286-
<SocialComponentsWrapper>
287-
<LeftSocialComponents />
288-
<RightSocialComponents>
289-
<SocialSharing />
290-
</RightSocialComponents>
291-
</SocialComponentsWrapper>
292-
293292
{side_banner_data_details && (
294293
<Show.Mobile>
295294
<Flex mt="24px">

src/templates/article.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ import { convertDate, getMinRead, truncateString } from 'common/utility'
3939
import { useBrowserResize } from 'components/hooks/use-browser-resize'
4040
import { usePageLoaded } from 'components/hooks/use-page-loaded'
4141
import RightArrow from 'images/svg/tools/black-right-arrow.svg'
42+
import { getTruncateLength } from 'pages/academy/blog/posts/preview'
4243

4344
type ArticlesTemplateProps = {
4445
data: ArticleQuery
4546
}
4647

4748
const ArticlesTemplate = ({ data }: ArticlesTemplateProps) => {
48-
const [is_mobile] = useBrowserResize(475)
49-
const [is_little_mobile] = useBrowserResize(400)
49+
const [is_mobile] = useBrowserResize(992)
5050
const [prevScrollPos, setPrevScrollPos] = useState(0)
5151
const [visible, setVisible] = useState(true)
5252
const [is_mounted] = usePageLoaded()
@@ -127,12 +127,6 @@ const ArticlesTemplate = ({ data }: ArticlesTemplateProps) => {
127127
og_description: og_description ? og_description : meta_description,
128128
}
129129

130-
const getTruncateLength = () => {
131-
if (is_little_mobile) return 15
132-
else if (is_mobile) return 30
133-
else return 60
134-
}
135-
136130
return (
137131
<Layout type="academy" margin_top={'14.4'}>
138132
<SEO

0 commit comments

Comments
 (0)