@@ -3,7 +3,6 @@ import React, { useMemo } from 'react';
33import type { Keyword } from '../../graphql/keywords' ;
44import type { TagCategory } from '../../graphql/feedSettings' ;
55import useFeedSettings from '../../hooks/useFeedSettings' ;
6- import { TagTopList } from '../cards/Leaderboard/TagTopList' ;
76import { ExploreCategorySection } from './ExploreCategorySection' ;
87import { ExploreTopicSearch } from './ExploreTopicSearch' ;
98import { useChipBarNavigation } from './useChipBarNavigation' ;
@@ -19,7 +18,6 @@ interface ExploreTopicsPageProps {
1918 trendingTags : Keyword [ ] ;
2019 popularTags : Keyword [ ] ;
2120 tagsCategories : TagCategory [ ] ;
22- isLoading ?: boolean ;
2321}
2422
2523const scrollToCategory = ( id : string ) : void => {
@@ -28,12 +26,14 @@ const scrollToCategory = (id: string): void => {
2826 ?. scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
2927} ;
3028
29+ const toTagValues = ( items ?: Keyword [ ] ) : string [ ] =>
30+ items ?. map ( ( item ) => item . value ) . filter ( Boolean ) ?? [ ] ;
31+
3132export function ExploreTopicsPage ( {
3233 tags,
3334 trendingTags,
3435 popularTags,
3536 tagsCategories,
36- isLoading = false ,
3737} : ExploreTopicsPageProps ) : ReactElement {
3838 const { feedSettings } = useFeedSettings ( ) ;
3939 const { ref : categoryNavRef , onKeyDown : onCategoryNavKeyDown } =
@@ -59,6 +59,37 @@ export function ExploreTopicsPage({
5959 [ tags ] ,
6060 ) ;
6161
62+ // The trending / popular / recently-added lists, shaped like categories so
63+ // they render with the same flat column treatment as the directory below.
64+ const featuredLists = useMemo < TagCategory [ ] > ( ( ) => {
65+ const lists : TagCategory [ ] = [ ] ;
66+ if ( trendingTags ?. length ) {
67+ lists . push ( {
68+ id : 'trending-tags' ,
69+ title : 'Trending tags' ,
70+ emoji : '🔥' ,
71+ tags : toTagValues ( trendingTags ) ,
72+ } ) ;
73+ }
74+ if ( popularTags ?. length ) {
75+ lists . push ( {
76+ id : 'popular-tags' ,
77+ title : 'Popular tags' ,
78+ emoji : '⭐' ,
79+ tags : toTagValues ( popularTags ) ,
80+ } ) ;
81+ }
82+ if ( recentlyAddedTags ?. length ) {
83+ lists . push ( {
84+ id : 'recently-added-tags' ,
85+ title : 'Recently added tags' ,
86+ emoji : '🆕' ,
87+ tags : toTagValues ( recentlyAddedTags ) ,
88+ } ) ;
89+ }
90+ return lists ;
91+ } , [ trendingTags , popularTags , recentlyAddedTags ] ) ;
92+
6293 const recommendedTags = useMemo (
6394 ( ) => popularTags ?. slice ( 0 , 5 ) . map ( ( tag ) => tag . value ) ?? [ ] ,
6495 [ popularTags ] ,
@@ -119,6 +150,20 @@ export function ExploreTopicsPage({
119150
120151 < div className = "my-10 h-px w-full bg-border-subtlest-tertiary" />
121152
153+ { /* Featured — trending / popular / recently added, flat link columns. */ }
154+ { featuredLists . length > 0 && (
155+ < div className = "grid w-full grid-cols-1 gap-x-10 tablet:grid-cols-2 laptop:grid-cols-3" >
156+ { featuredLists . map ( ( list ) => (
157+ < ExploreCategorySection key = { list . id } category = { list } />
158+ ) ) }
159+ </ div >
160+ ) }
161+
162+ { /* Border separating the featured lists from the full directory. */ }
163+ { featuredLists . length > 0 && categories . length > 0 && (
164+ < div className = "mb-10 mt-2 h-px w-full bg-border-subtlest-tertiary" />
165+ ) }
166+
122167 { /* Directory — categories as columns of topic links. */ }
123168 { categories . length > 0 && (
124169 < div className = "w-full columns-1 gap-x-10 tablet:columns-2 laptop:columns-3" >
@@ -127,39 +172,6 @@ export function ExploreTopicsPage({
127172 ) ) }
128173 </ div >
129174 ) }
130-
131- { /* Featured leaderboards */ }
132- < section className = "mt-6 w-full" >
133- < Typography
134- tag = { TypographyTag . H2 }
135- type = { TypographyType . Title2 }
136- color = { TypographyColor . Primary }
137- bold
138- className = "mb-6 text-center"
139- >
140- Trending on daily.dev
141- </ Typography >
142- < div className = "grid auto-rows-fr grid-cols-1 gap-0 tablet:grid-cols-2 tablet:gap-6 laptopL:grid-cols-3" >
143- < TagTopList
144- containerProps = { { title : 'Trending tags' } }
145- items = { trendingTags }
146- isLoading = { isLoading }
147- />
148- < TagTopList
149- containerProps = { { title : 'Popular tags' } }
150- items = { popularTags }
151- isLoading = { isLoading }
152- />
153- < TagTopList
154- containerProps = { {
155- title : 'Recently added tags' ,
156- className : 'col-span-1 tablet:col-span-2 laptopL:col-span-1' ,
157- } }
158- items = { recentlyAddedTags }
159- isLoading = { isLoading }
160- />
161- </ div >
162- </ section >
163175 </ div >
164176 ) ;
165177}
0 commit comments