forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datahub-project:master' into master
- Loading branch information
Showing
43 changed files
with
1,197 additions
and
964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
datahub-web-react/src/app/glossary/GloassarySearchResultItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Create a new component called SearchResultItem.js | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import Highlight from 'react-highlighter'; | ||
import styled from 'styled-components/macro'; | ||
import { Entity } from '../../types.generated'; | ||
import { IconStyleType } from '../entity/Entity'; | ||
import { ANTD_GRAY } from '../entity/shared/constants'; | ||
import ParentEntities from '../search/filters/ParentEntities'; | ||
import { getParentGlossary } from './utils'; | ||
import EntityRegistry from '../entity/EntityRegistry'; | ||
|
||
type Props = { | ||
entity: Entity; | ||
entityRegistry: EntityRegistry; | ||
query: string; | ||
onResultClick: () => void; | ||
}; | ||
|
||
const SearchResult = styled(Link)` | ||
color: #262626; | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
height: 100%; | ||
padding: 6px 8px; | ||
width: 100%; | ||
&:hover { | ||
background-color: ${ANTD_GRAY[3]}; | ||
color: #262626; | ||
} | ||
`; | ||
|
||
const IconWrapper = styled.span``; | ||
|
||
const highlightMatchStyle = { | ||
fontWeight: 'bold', | ||
background: 'none', | ||
padding: 0, | ||
}; | ||
|
||
function GlossarySearchResultItem({ entity, entityRegistry, query, onResultClick }: Props) { | ||
return ( | ||
<SearchResult to={entityRegistry.getEntityUrl(entity.type, entity.urn)} onClick={onResultClick}> | ||
<IconWrapper>{entityRegistry.getIcon(entity.type, 12, IconStyleType.TAB_VIEW)}</IconWrapper> | ||
<div> | ||
<ParentEntities parentEntities={getParentGlossary(entity, entityRegistry)} /> | ||
<Highlight matchStyle={highlightMatchStyle} search={query}> | ||
{entityRegistry.getDisplayName(entity.type, entity)} | ||
</Highlight> | ||
</div> | ||
</SearchResult> | ||
); | ||
} | ||
|
||
export default GlossarySearchResultItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.