-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jj--incidents-oss-v1
- Loading branch information
Showing
71 changed files
with
2,366 additions
and
1,435 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { Theme } from './conf/theme/types'; | ||
import defaultThemeConfig from './conf/theme/theme_light.config.json'; | ||
import { CustomThemeContext } from './customThemeContext'; | ||
|
||
const CustomThemeProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [currentTheme, setTheme] = useState<Theme>(defaultThemeConfig); | ||
|
||
useEffect(() => { | ||
if (import.meta.env.DEV) { | ||
import(/* @vite-ignore */ `./conf/theme/${import.meta.env.REACT_APP_THEME_CONFIG}`).then((theme) => { | ||
setTheme(theme); | ||
}); | ||
} else { | ||
// Send a request to the server to get the theme config. | ||
fetch(`/assets/conf/theme/${import.meta.env.REACT_APP_THEME_CONFIG}`) | ||
.then((response) => response.json()) | ||
.then((theme) => { | ||
setTheme(theme); | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<CustomThemeContext.Provider value={{ theme: currentTheme, updateTheme: setTheme }}> | ||
<ThemeProvider theme={currentTheme}>{children}</ThemeProvider> | ||
</CustomThemeContext.Provider> | ||
); | ||
}; | ||
|
||
export default CustomThemeProvider; |
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; |
Oops, something went wrong.