Skip to content

Commit

Permalink
feat(MainFeed): Add dynamic single line display in MainFeed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kechicode committed Jan 7, 2025
1 parent 8fe8233 commit 9c7b48b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/views/Home/Channel/Page/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ const ChannelCarousel = ({ items }: ChannelCarouselProps) => {
</div>
</section>
<footer className={styles.footer}>
<section className={styles.dots}>
<section
className={classnames(['page-channel-carousel-dots', styles.dots])}
>
{slicedItems?.map((_, index) => (
<Dot
key={index}
Expand Down
16 changes: 14 additions & 2 deletions src/views/Home/Feed/MainFeed/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NetworkStatus } from 'apollo-client'
import { useContext, useEffect, useRef } from 'react'
import { useContext, useEffect, useRef, useState } from 'react'

import { analytics, mergeConnections } from '~/common/utils'
import {
Expand All @@ -11,6 +11,7 @@ import {
Media,
QueryError,
SpinnerBlock,
useNativeEventListener,
usePublicQuery,
ViewerContext,
} from '~/components'
Expand Down Expand Up @@ -235,6 +236,17 @@ const MainFeed = ({ feedSortType: sortBy }: MainFeedProps) => {
link: `${host}/#channel=28`,
},
]

const [showSingleLine, setShowSingleLine] = useState(false)

useNativeEventListener('scroll', () => {
if (window.scrollY > 85) {
setShowSingleLine(true)
} else {
setShowSingleLine(false)
}
})

/**
* Data Fetching
*/
Expand Down Expand Up @@ -364,7 +376,7 @@ const MainFeed = ({ feedSortType: sortBy }: MainFeedProps) => {
<List>
<Media lessThan="lg">
<ChannelCarousel items={items} />
<SingleLine items={items} />
{showSingleLine && <SingleLine items={items} />}
</Media>
{isHottestFeed && <Announcements />}
{mixFeed.map((edge, i) => {
Expand Down

0 comments on commit 9c7b48b

Please sign in to comment.