|
1 | 1 | import React, { useEffect, useState } from 'react'; |
2 | 2 | import { |
| 3 | + Breadcrumb, |
| 4 | + BreadcrumbItem, |
3 | 5 | Button, |
4 | | - Content, |
5 | 6 | Flex, |
6 | 7 | FlexItem, |
7 | 8 | Label, |
8 | 9 | Stack, |
9 | 10 | StackItem, |
10 | 11 | } from '@patternfly/react-core'; |
| 12 | +import './SearchResultItem.scss'; |
11 | 13 | import { |
12 | | - AngleRightIcon, |
13 | 14 | BookOpenIcon, |
14 | 15 | BookmarkIcon, |
15 | 16 | CloudIcon, |
@@ -151,91 +152,55 @@ const SearchResultItem: React.FC<{ |
151 | 152 | } |
152 | 153 | }; |
153 | 154 |
|
154 | | - const renderBreadcrumb = () => { |
155 | | - const getBreadcrumbConfig = (type: SearchResult['type']) => { |
156 | | - switch (type) { |
157 | | - case 'documentation': |
158 | | - return { |
159 | | - tabType: intl.formatMessage(messages.breadcrumbLearn), |
160 | | - sectionTitle: intl.formatMessage(messages.contentTypeDocumentation), |
161 | | - icon: <BookOpenIcon />, |
162 | | - }; |
163 | | - case 'quickstart': |
164 | | - return { |
165 | | - tabType: intl.formatMessage(messages.breadcrumbLearn), |
166 | | - sectionTitle: intl.formatMessage(messages.contentTypeQuickstarts), |
167 | | - icon: <BookmarkIcon />, |
168 | | - }; |
169 | | - case 'api': |
170 | | - return { |
171 | | - tabType: intl.formatMessage(messages.breadcrumbApis), |
172 | | - sectionTitle: intl.formatMessage( |
173 | | - messages.breadcrumbApiDocumentation |
174 | | - ), |
175 | | - icon: <VectorSquareIcon />, |
176 | | - }; |
177 | | - case 'kb': |
178 | | - return { |
179 | | - tabType: intl.formatMessage(messages.breadcrumbKnowledgeBase), |
180 | | - sectionTitle: intl.formatMessage( |
181 | | - messages.breadcrumbKnowledgeBaseArticles |
182 | | - ), |
183 | | - icon: <LightbulbIcon />, |
184 | | - }; |
185 | | - case 'support': |
186 | | - return { |
187 | | - tabType: intl.formatMessage(messages.breadcrumbSupport), |
188 | | - sectionTitle: intl.formatMessage(messages.breadcrumbSupportTickets), |
189 | | - icon: <HeadsetIcon />, |
190 | | - }; |
191 | | - case 'service': |
192 | | - return { |
193 | | - tabType: null, |
194 | | - sectionTitle: intl.formatMessage( |
195 | | - messages.breadcrumbHybridCloudService |
196 | | - ), |
197 | | - icon: <CloudIcon className="pf-v6-u-color-blue-400" />, |
198 | | - }; |
199 | | - default: |
200 | | - return { tabType: null, sectionTitle: type, icon: null }; |
201 | | - } |
202 | | - }; |
203 | | - |
204 | | - const config = getBreadcrumbConfig(result.type); |
205 | | - |
206 | | - return ( |
207 | | - <Flex |
208 | | - alignItems={{ default: 'alignItemsCenter' }} |
209 | | - spaceItems={{ default: 'spaceItemsXs' }} |
210 | | - > |
211 | | - {config.icon && ( |
212 | | - <FlexItem> |
213 | | - <span className="pf-v6-u-font-size-sm pf-v6-u-color-200"> |
214 | | - {config.icon} |
215 | | - </span> |
216 | | - </FlexItem> |
217 | | - )} |
218 | | - {config.tabType && ( |
219 | | - <> |
220 | | - <FlexItem> |
221 | | - <Content component="small" className="pf-v6-u-color-200"> |
222 | | - {config.tabType} |
223 | | - </Content> |
224 | | - </FlexItem> |
225 | | - <FlexItem> |
226 | | - <AngleRightIcon className="pf-v6-u-font-size-sm pf-v6-u-color-200" /> |
227 | | - </FlexItem> |
228 | | - </> |
229 | | - )} |
230 | | - <FlexItem> |
231 | | - <Content component="small" className="pf-v6-u-color-200"> |
232 | | - {config.sectionTitle} |
233 | | - </Content> |
234 | | - </FlexItem> |
235 | | - </Flex> |
236 | | - ); |
| 155 | + const getBreadcrumbConfig = (type: SearchResult['type']) => { |
| 156 | + switch (type) { |
| 157 | + case 'documentation': |
| 158 | + return { |
| 159 | + tabType: intl.formatMessage(messages.breadcrumbLearn), |
| 160 | + sectionTitle: intl.formatMessage(messages.contentTypeDocumentation), |
| 161 | + icon: <BookOpenIcon />, |
| 162 | + }; |
| 163 | + case 'quickstart': |
| 164 | + return { |
| 165 | + tabType: intl.formatMessage(messages.breadcrumbLearn), |
| 166 | + sectionTitle: intl.formatMessage(messages.contentTypeQuickstarts), |
| 167 | + icon: <BookmarkIcon />, |
| 168 | + }; |
| 169 | + case 'api': |
| 170 | + return { |
| 171 | + tabType: intl.formatMessage(messages.breadcrumbApis), |
| 172 | + sectionTitle: intl.formatMessage(messages.breadcrumbApiDocumentation), |
| 173 | + icon: <VectorSquareIcon />, |
| 174 | + }; |
| 175 | + case 'kb': |
| 176 | + return { |
| 177 | + tabType: intl.formatMessage(messages.breadcrumbKnowledgeBase), |
| 178 | + sectionTitle: intl.formatMessage( |
| 179 | + messages.breadcrumbKnowledgeBaseArticles |
| 180 | + ), |
| 181 | + icon: <LightbulbIcon />, |
| 182 | + }; |
| 183 | + case 'support': |
| 184 | + return { |
| 185 | + tabType: intl.formatMessage(messages.breadcrumbSupport), |
| 186 | + sectionTitle: intl.formatMessage(messages.breadcrumbSupportTickets), |
| 187 | + icon: <HeadsetIcon />, |
| 188 | + }; |
| 189 | + case 'service': |
| 190 | + return { |
| 191 | + tabType: null, |
| 192 | + sectionTitle: intl.formatMessage( |
| 193 | + messages.breadcrumbHybridCloudService |
| 194 | + ), |
| 195 | + icon: <CloudIcon className="pf-v6-u-color-blue-400" />, |
| 196 | + }; |
| 197 | + default: |
| 198 | + return { tabType: null, sectionTitle: type, icon: null }; |
| 199 | + } |
237 | 200 | }; |
238 | 201 |
|
| 202 | + const config = getBreadcrumbConfig(result.type); |
| 203 | + |
239 | 204 | return ( |
240 | 205 | <Flex |
241 | 206 | alignItems={{ default: 'alignItemsFlexStart' }} |
@@ -306,7 +271,26 @@ const SearchResultItem: React.FC<{ |
306 | 271 | justifyContent={{ default: 'justifyContentSpaceBetween' }} |
307 | 272 | alignItems={{ default: 'alignItemsCenter' }} |
308 | 273 | > |
309 | | - <FlexItem>{renderBreadcrumb()}</FlexItem> |
| 274 | + <FlexItem> |
| 275 | + <Flex |
| 276 | + alignItems={{ default: 'alignItemsCenter' }} |
| 277 | + spaceItems={{ default: 'spaceItemsSm' }} |
| 278 | + > |
| 279 | + {config.icon && ( |
| 280 | + <FlexItem className="pf-v6-u-font-size-sm pf-v6-u-color-200"> |
| 281 | + {config.icon} |
| 282 | + </FlexItem> |
| 283 | + )} |
| 284 | + <FlexItem> |
| 285 | + <Breadcrumb className="lr-c-search-result-breadcrumb"> |
| 286 | + {config.tabType && ( |
| 287 | + <BreadcrumbItem>{config.tabType}</BreadcrumbItem> |
| 288 | + )} |
| 289 | + <BreadcrumbItem>{config.sectionTitle}</BreadcrumbItem> |
| 290 | + </Breadcrumb> |
| 291 | + </FlexItem> |
| 292 | + </Flex> |
| 293 | + </FlexItem> |
310 | 294 | {result.bundleTags && result.bundleTags.length > 0 && ( |
311 | 295 | <FlexItem> |
312 | 296 | <Flex spaceItems={{ default: 'spaceItemsXs' }}> |
|
0 commit comments