Skip to content

Commit b982fb3

Browse files
authored
Merge pull request #244 from medyo/feat/feed-v2
Feat/feed v2
2 parents 8d48cd0 + e5be506 commit b982fb3

38 files changed

Lines changed: 1248 additions & 203 deletions

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"react-easy-sort": "^1.5.1",
2323
"react-error-boundary": "^3.1.4",
2424
"react-icons": "^5.2.1",
25+
"react-infinite-scroll-hook": "^6.0.0",
2526
"react-markdown": "^7.0.1",
2627
"react-modal": "^3.12.1",
2728
"react-responsive": "^10.0.1",

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import clsx from 'clsx'
12
import { useEffect, useLayoutEffect, useState } from 'react'
23
import { DNDLayout } from 'src/components/Layout'
34
import {
@@ -30,6 +31,7 @@ export const App = () => {
3031
maxVisibleCards,
3132
setAdvStatus,
3233
isDNDModeActive,
34+
layout,
3335
DNDDuration,
3436
setDNDDuration,
3537
} = useUserPreferences()
@@ -80,7 +82,11 @@ export const App = () => {
8082
<OnboardingModal showOnboarding={showOnboarding} setShowOnboarding={setShowOnboarding} />
8183
)}
8284

83-
<div className="layoutLayers hideScrollBar">
85+
<div
86+
className={clsx(
87+
'layoutLayers hideScrollBar',
88+
layout === 'cards' ? 'cardsLayout' : 'gridLayout'
89+
)}>
8490
{isDNDModeActive() && <DNDLayout />}
8591
<AppContentLayout />
8692
</div>

src/assets/App.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,13 @@ a {
411411
}
412412
.rowCover {
413413
border-radius: 4px;
414-
display: block;
414+
display: flex;
415+
align-items: center;
416+
justify-content: center;
415417
width: 100%;
416418
min-height: auto;
417419
object-fit: cover;
420+
418421
aspect-ratio: 16/9;
419422
background-color: var(--placeholder-background-color);
420423
margin-bottom: 12px;
@@ -492,6 +495,11 @@ a {
492495
font-size: 12px;
493496
}
494497

498+
.rowDetails .rowItem.verticalAligned {
499+
display: inline-flex;
500+
align-items: center;
501+
gap: 4px;
502+
}
495503
.rowDescription .rowItem {
496504
font-size: 12px;
497505
}
@@ -1235,11 +1243,16 @@ Producthunt item
12351243
justify-content: center;
12361244
}
12371245

1238-
.layoutLayers {
1246+
.layoutLayers.cardsLayout {
12391247
margin-left: 1%;
12401248
margin-right: 1%;
12411249
}
12421250

1251+
.layoutLayers.gridLayout {
1252+
margin-top: 1%;
1253+
box-shadow: 0px -10px 20px -15px var(--card-border-color);
1254+
}
1255+
12431256
.Cards {
12441257
padding-bottom: 20px;
12451258
}

src/components/Elements/Card/Card.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export const Card = ({
7575
{badge && <span className="blockHeaderBadge">{badge}</span>}
7676
</div>
7777

78-
{canAdsLoad && adsConfig.enabled && withAds && <AdvBanner />}
78+
{canAdsLoad && adsConfig.enabled && withAds && (
79+
<div className="ad-wrapper blockRow">
80+
<AdvBanner />
81+
</div>
82+
)}
7983

8084
<div className="blockContent scrollable">{children}</div>
8185
</div>
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react'
2+
import { Feed } from 'src/features/feed'
23
import { DesktopBreakpoint } from 'src/providers/DesktopBreakpoint'
34
import { MobileBreakpoint } from 'src/providers/MobileBreakpoint'
45
import { useUserPreferences } from 'src/stores/preferences'
@@ -8,23 +9,30 @@ import { MobileCards } from './MobileCards'
89
import { ScrollCardsNavigator } from './ScrollCardsNavigator'
910

1011
export const AppContentLayout = () => {
11-
const { cards, userCustomCards } = useUserPreferences()
12+
const { cards, userCustomCards, layout } = useUserPreferences()
1213
const [selectedCard, setSelectedCard] = useState(cards[0])
1314

1415
return (
1516
<>
1617
<main className="AppContent">
17-
<ScrollCardsNavigator />
18-
<DesktopBreakpoint>
19-
<DesktopCards cards={cards} userCustomCards={userCustomCards} />
20-
</DesktopBreakpoint>
21-
<MobileBreakpoint>
22-
<div className="Cards HorizontalScroll">
23-
<MobileCards selectedCard={selectedCard} />
24-
</div>
25-
</MobileBreakpoint>
18+
{layout === 'grid' ? (
19+
<Feed />
20+
) : (
21+
<>
22+
<ScrollCardsNavigator />
23+
<DesktopBreakpoint>
24+
<DesktopCards cards={cards} userCustomCards={userCustomCards} />
25+
</DesktopBreakpoint>
26+
<MobileBreakpoint>
27+
<div className="Cards HorizontalScroll">
28+
<MobileCards selectedCard={selectedCard} />
29+
</div>
30+
</MobileBreakpoint>
31+
<BottomNavigation selectedCard={selectedCard} setSelectedCard={setSelectedCard} />
32+
</>
33+
)}
2634
</main>
27-
<BottomNavigation selectedCard={selectedCard} setSelectedCard={setSelectedCard} />
35+
2836
</>
2937
)
3038
}

src/components/placeholders/AdPlaceholder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export const AdPlaceholder = ({ className = '' }: { className?: string }) => {
1+
export const AdPlaceholder = () => {
22
return (
3-
<div className={'cardPlaceholder adCardPlaceholder'}>
3+
<div className="cardPlaceholder adCardPlaceholder">
44
<span className="image" />
55
<div className="cardContent">
66
<span className="line" />

src/config/supportedCards.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ export const SUPPORTED_CARDS: SupportedCardType[] = [
126126
label: 'Powered by AI',
127127
component: AICard,
128128
type: 'supported',
129-
badge: 'ALPHA',
129+
badge: 'BETA',
130130
},
131131
]

src/features/adv/api/getAd.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { Ad } from '../types'
55

66
const getAd = async (
77
keywords: string[],
8+
feed: boolean = false,
89
aditionalAdQueries: { [key: string]: string } | undefined
910
): Promise<Ad | null> => {
10-
let params = { keywords: keywords.join(',') }
11+
let params = { keywords: keywords.join(','), feed: feed ? 'true' : 'false' }
1112
if (aditionalAdQueries) {
1213
params = { ...params, ...aditionalAdQueries }
1314
}
@@ -18,13 +19,14 @@ type QueryFnType = typeof getAd
1819

1920
type UseGetAdOptions = {
2021
keywords: string[]
22+
feed?: boolean
2123
config?: QueryConfig<QueryFnType>
2224
aditionalAdQueries: { [key: string]: string } | undefined
2325
}
24-
export const useGetAd = ({ keywords, config, aditionalAdQueries }: UseGetAdOptions) => {
26+
export const useGetAd = ({ keywords, feed, config, aditionalAdQueries }: UseGetAdOptions) => {
2527
return useQuery<ExtractFnReturnType<QueryFnType>>({
2628
...config,
2729
queryKey: ['ad', keywords.join(',')],
28-
queryFn: () => getAd(keywords, aditionalAdQueries),
30+
queryFn: () => getAd(keywords, feed, aditionalAdQueries),
2931
})
3032
}

0 commit comments

Comments
 (0)