@@ -82,28 +82,65 @@ export const CustomCatalog: React.FC = () => {
8282 setFilteredQuickStarts ( result ) ;
8383 } ;
8484
85- const [ bookmarked , setBookmarked ] = React . useState < string [ ] > ( [ ] )
85+ const [ bookmarked , setBookmarked ] = React . useState < string [ ] > ( [ ] ) ;
8686
8787 const CatalogWithSections = React . useMemo (
8888 ( ) => (
8989 < >
90+ { bookmarked . length > 0 && (
91+ < QuickStartCatalogSection >
92+ < TextContent >
93+ < Text component = "h2" > Bookmarked</ Text >
94+ < Text component = "p" className = "catalog-sub" >
95+ Bookmarked examples
96+ </ Text >
97+ </ TextContent >
98+ < Gallery className = "pfext-quick-start-catalog__gallery" hasGutter >
99+ { allQuickStarts
100+ . filter ( ( quickStart : QuickStart ) => bookmarked . includes ( quickStart . metadata . name ) )
101+ . map ( ( quickStart : QuickStart ) => {
102+ const {
103+ metadata : { name : id } ,
104+ } = quickStart ;
105+
106+ return (
107+ < GalleryItem key = { id } className = "pfext-quick-start-catalog__gallery-item" >
108+ < QuickStartTile
109+ action = { {
110+ onClick : ( e : React . SyntheticEvent ) => {
111+ e . preventDefault ( ) ;
112+ e . stopPropagation ( ) ;
113+ setBookmarked ( ( prev ) => {
114+ if ( prev . includes ( id ) ) {
115+ return prev . filter ( ( bookmark ) => bookmark !== id ) ;
116+ }
117+
118+ return [ ...prev , id ] ;
119+ } ) ;
120+ } ,
121+ icon : bookmarked . includes ( id ) ? BookmarkIcon : OutlinedBookmarkIcon ,
122+ 'aria-label' : 'bookmark' ,
123+ } }
124+ quickStart = { quickStart }
125+ isActive = { id === activeQuickStartID }
126+ status = { getQuickStartStatus ( allQuickStartStates , id ) }
127+ />
128+ </ GalleryItem >
129+ ) ;
130+ } ) }
131+ </ Gallery >
132+ </ QuickStartCatalogSection >
133+ ) }
90134 < QuickStartCatalogSection >
91135 < TextContent >
92- < Text component = "h2" > Bookmarkable </ Text >
136+ < Text component = "h2" > Instructional </ Text >
93137 < Text component = "p" className = "catalog-sub" >
94- Bookmarkable examples
138+ Instructional examples
95139 </ Text >
96140 </ TextContent >
97141 < Gallery className = "pfext-quick-start-catalog__gallery" hasGutter >
98142 { allQuickStarts
99143 . filter ( ( quickStart : QuickStart ) => quickStart . metadata . instructional )
100- . map ( ( quickStart : QuickStart ) => ( {
101- ...quickStart ,
102- metadata : {
103- ...quickStart . metadata ,
104- id : `${ quickStart . metadata . name } -bookmar`
105- }
106- } ) )
107144 . map ( ( quickStart : QuickStart ) => {
108145 const {
109146 metadata : { name : id } ,
@@ -118,14 +155,14 @@ export const CustomCatalog: React.FC = () => {
118155 e . stopPropagation ( ) ;
119156 setBookmarked ( ( prev ) => {
120157 if ( prev . includes ( id ) ) {
121- return prev . filter ( ( bookmark ) => bookmark !== id )
158+ return prev . filter ( ( bookmark ) => bookmark !== id ) ;
122159 }
123160
124161 return [ ...prev , id ] ;
125162 } ) ;
126163 } ,
127164 icon : bookmarked . includes ( id ) ? BookmarkIcon : OutlinedBookmarkIcon ,
128- 'aria-label' : 'bookmark'
165+ 'aria-label' : 'bookmark' ,
129166 } }
130167 quickStart = { quickStart }
131168 isActive = { id === activeQuickStartID }
@@ -136,33 +173,6 @@ export const CustomCatalog: React.FC = () => {
136173 } ) }
137174 </ Gallery >
138175 </ QuickStartCatalogSection >
139- < QuickStartCatalogSection >
140- < TextContent >
141- < Text component = "h2" > Instructional</ Text >
142- < Text component = "p" className = "catalog-sub" >
143- Instructional examples
144- </ Text >
145- </ TextContent >
146- < Gallery className = "pfext-quick-start-catalog__gallery" hasGutter >
147- { allQuickStarts
148- . filter ( ( quickStart : QuickStart ) => quickStart . metadata . instructional )
149- . map ( ( quickStart : QuickStart ) => {
150- const {
151- metadata : { name : id } ,
152- } = quickStart ;
153-
154- return (
155- < GalleryItem key = { id } className = "pfext-quick-start-catalog__gallery-item" >
156- < QuickStartTile
157- quickStart = { quickStart }
158- isActive = { id === activeQuickStartID }
159- status = { getQuickStartStatus ( allQuickStartStates , id ) }
160- />
161- </ GalleryItem >
162- ) ;
163- } ) }
164- </ Gallery >
165- </ QuickStartCatalogSection >
166176 < QuickStartCatalogSection >
167177 < TextContent >
168178 < Text component = "h2" > Real-world examples</ Text >
@@ -181,6 +191,21 @@ export const CustomCatalog: React.FC = () => {
181191 return (
182192 < GalleryItem key = { id } className = "pfext-quick-start-catalog__gallery-item" >
183193 < QuickStartTile
194+ action = { {
195+ onClick : ( e : React . SyntheticEvent ) => {
196+ e . preventDefault ( ) ;
197+ e . stopPropagation ( ) ;
198+ setBookmarked ( ( prev ) => {
199+ if ( prev . includes ( id ) ) {
200+ return prev . filter ( ( bookmark ) => bookmark !== id ) ;
201+ }
202+
203+ return [ ...prev , id ] ;
204+ } ) ;
205+ } ,
206+ icon : bookmarked . includes ( id ) ? BookmarkIcon : OutlinedBookmarkIcon ,
207+ 'aria-label' : 'bookmark' ,
208+ } }
184209 quickStart = { quickStart }
185210 isActive = { id === activeQuickStartID }
186211 status = { getQuickStartStatus ( allQuickStartStates , id ) }
0 commit comments