Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(style): Improve search bar input focus + styling #8955

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions datahub-web-react/src/app/search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useHistory } from 'react-router';
import { AutoCompleteResultForEntity, EntityType, FacetFilterInput, ScenarioType } from '../../types.generated';
import EntityRegistry from '../entity/EntityRegistry';
import filterSearchQuery from './utils/filterSearchQuery';
import { ANTD_GRAY, ANTD_GRAY_V2 } from '../entity/shared/constants';
import { ANTD_GRAY, ANTD_GRAY_V2, REDESIGN_COLORS } from '../entity/shared/constants';
import { getEntityPath } from '../entity/shared/containers/profile/utils';
import { EXACT_SEARCH_PREFIX } from './utils/constants';
import { useListRecommendationsQuery } from '../../graphql/recommendations.generated';
Expand All @@ -20,7 +20,6 @@ import RecommendedOption from './autoComplete/RecommendedOption';
import SectionHeader, { EntityTypeLabel } from './autoComplete/SectionHeader';
import { useUserContext } from '../context/useUserContext';
import { navigateToSearchUrl } from './utils/navigateToSearchUrl';
import { getQuickFilterDetails } from './autoComplete/quickFilters/utils';
import ViewAllSearchItem from './ViewAllSearchItem';
import { ViewSelect } from '../entity/view/select/ViewSelect';
import { combineSiblingsInAutoComplete } from './utils/combineSiblingsInAutoComplete';
Expand All @@ -39,13 +38,14 @@ const StyledSearchBar = styled(Input)`
&&& {
border-radius: 70px;
height: 40px;
font-size: 20px;
color: ${ANTD_GRAY[7]};
background-color: ${ANTD_GRAY_V2[2]};
}
> .ant-input {
font-size: 14px;
color: ${ANTD_GRAY[7]};
background-color: ${ANTD_GRAY_V2[2]};
border: 2px solid transparent;
&:focus-within {
border: 1.5px solid ${REDESIGN_COLORS.BLUE};
}
}
> .ant-input::placeholder {
color: ${ANTD_GRAY_V2[10]};
Expand Down Expand Up @@ -203,23 +203,16 @@ export const SearchBar = ({
const { quickFilters, selectedQuickFilter, setSelectedQuickFilter } = useQuickFiltersContext();

const autoCompleteQueryOptions = useMemo(() => {
const query = suggestions.length ? effectiveQuery : '';
const selectedQuickFilterLabel =
showQuickFilters && selectedQuickFilter
? getQuickFilterDetails(selectedQuickFilter, entityRegistry).label
: '';
const text = query || selectedQuickFilterLabel;

if (!text) return [];
if (effectiveQuery === '') return [];

return [
{
value: `${EXACT_SEARCH_PREFIX}${text}`,
label: <ViewAllSearchItem searchTarget={text} />,
value: `${EXACT_SEARCH_PREFIX}${effectiveQuery}`,
label: <ViewAllSearchItem searchTarget={effectiveQuery} />,
type: EXACT_AUTOCOMPLETE_OPTION_TYPE,
},
];
}, [showQuickFilters, suggestions.length, effectiveQuery, selectedQuickFilter, entityRegistry]);
}, [effectiveQuery]);

const autoCompleteEntityOptions = useMemo(() => {
return suggestions.map((suggestion: AutoCompleteResultForEntity) => {
Expand Down Expand Up @@ -296,6 +289,22 @@ export const SearchBar = ({
}
}

const searchInputRef = useRef(null);

useEffect(() => {
const handleKeyDown = (event) => {
// Support command-k to select the search bar.
// 75 is the keyCode for 'k'
if ((event.metaKey || event.ctrlKey) && event.keyCode === 75) {
(searchInputRef?.current as any)?.focus();
}
};
document.addEventListener('keydown', handleKeyDown);
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, []);

return (
<AutoCompleteContainer style={style} ref={searchBarWrapperRef}>
<StyledAutoComplete
Expand Down Expand Up @@ -399,6 +408,7 @@ export const SearchBar = ({
/>
</>
}
ref={searchInputRef}
/>
</StyledAutoComplete>
</AutoCompleteContainer>
Expand Down
28 changes: 14 additions & 14 deletions datahub-web-react/src/app/shared/admin/HeaderLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ export function HeaderLinks(props: Props) {
</Link>
</LinkWrapper>
)}
{showIngestion && (
<LinkWrapper>
<Link to="/ingestion">
<Button id={HOME_PAGE_INGESTION_ID} type="text">
<Tooltip title="Connect DataHub to your organization's data sources">
<NavTitleContainer>
<ApiOutlined />
<NavTitleText>Ingestion</NavTitleText>
</NavTitleContainer>
</Tooltip>
</Button>
</Link>
</LinkWrapper>
)}
<Dropdown
trigger={['click']}
overlay={
Expand Down Expand Up @@ -145,6 +131,20 @@ export function HeaderLinks(props: Props) {
</Button>
</LinkWrapper>
</Dropdown>
{showIngestion && (
<LinkWrapper>
<Link to="/ingestion">
<Button id={HOME_PAGE_INGESTION_ID} type="text">
<Tooltip title="Connect DataHub to your organization's data sources">
<NavTitleContainer>
<ApiOutlined />
<NavTitleText>Ingestion</NavTitleText>
</NavTitleContainer>
</Tooltip>
</Button>
</Link>
</LinkWrapper>
)}
{showSettings && (
<LinkWrapper style={{ marginRight: 12 }}>
<Link to="/settings">
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/conf/theme/theme_dark.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"homepageMessage": "Find data you can count(*) on"
},
"search": {
"searchbarMessage": "Search Datasets, People, & more..."
"searchbarMessage": "Search Tables, Dashboards, People, & more..."
},
"menu": {
"items": [
Expand All @@ -52,4 +52,4 @@
]
}
}
}
}
4 changes: 2 additions & 2 deletions datahub-web-react/src/conf/theme/theme_light.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"homepageMessage": "Find data you can count on"
},
"search": {
"searchbarMessage": "Search Datasets, People, & more..."
"searchbarMessage": "Search Tables, Dashboards, People, & more..."
},
"menu": {
"items": [
Expand All @@ -60,4 +60,4 @@
]
}
}
}
}
Loading