Merge pull request #16367 from IlyaSavich/customizable-search-list-item-icon
Pass search item to icon component, pass icon as component to search list item
This commit is contained in:
@@ -37,7 +37,7 @@ const useStyles = makeStyles({
|
||||
* @public
|
||||
*/
|
||||
export type TechDocsSearchResultListItemProps = {
|
||||
icon?: ReactNode;
|
||||
icon?: ReactNode | ((result: any) => ReactNode);
|
||||
result?: any;
|
||||
highlight?: ResultHighlight;
|
||||
rank?: number;
|
||||
@@ -151,7 +151,11 @@ export const TechDocsSearchResultListItem = (
|
||||
const ListItemWrapper = ({ children }: PropsWithChildren<{}>) =>
|
||||
asListItem ? (
|
||||
<>
|
||||
{icon && <ListItemIcon>{icon}</ListItemIcon>}
|
||||
{icon && (
|
||||
<ListItemIcon>
|
||||
{typeof icon === 'function' ? icon(result) : icon}
|
||||
</ListItemIcon>
|
||||
)}
|
||||
<div className={classes.flexContainer}>{children}</div>
|
||||
</>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user