Skip to content

Commit

Permalink
feat: introduce multi search component
Browse files Browse the repository at this point in the history
  • Loading branch information
annarieger committed May 23, 2023
1 parent 513d41a commit 4140d57
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ import {
import {
setLogoPath
} from './store/logoPath';
import {
setSearchEngines
} from './store/searchEngines';
import {
createReducer,
store
Expand Down Expand Up @@ -210,15 +213,20 @@ const setApplicationToStore = async (application?: Application) => {
store.dispatch(setLogoPath(application.clientConfig.theme.logoPath));
}

// nominatim search is active by default
store.dispatch(setSearchEngines(['nominatim']));

if (application.toolConfig && application.toolConfig.length > 0) {
const availableTools: string[] = [];
application.toolConfig
.map((tool: DefaultApplicationToolConfig) => {
if (tool.config.visible) {
if (tool.config.visible && tool.name !== 'search') {
availableTools.push(tool.name);
}
if (tool.name === 'search' && tool.config.engines.length > 0) {
store.dispatch(setSearchEngines(tool.config.engines));
}
});

store.dispatch(setAvailableTools(availableTools));
}
};
Expand Down
4 changes: 0 additions & 4 deletions src/components/Header/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
flex: 1;
display: flex;
justify-content: center;

.react-geo-nominatimsearch.ant-select-auto-complete {
width: 60%;
}
}

&.right-items {
Expand Down
5 changes: 2 additions & 3 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
HeaderPlacementOrientation,
isHeaderIntegration
} from '../../plugin';

import BasicNominatimSearch from '../BasicNominatimSearch';
import SearchField from '../SearchField';

import UserMenu from '../UserMenu';

Expand Down Expand Up @@ -67,7 +66,7 @@ export const Header: React.FC<HeaderProps> = ({

const getCenterItems = () => {
const items = [
<BasicNominatimSearch
<SearchField
key="search"
/>
];
Expand Down
58 changes: 58 additions & 0 deletions src/components/MultiSearch/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.search {

position: relative;

span.ant-input-group-addon {
background-color: var(--secondaryColor);

span.anticon {
color: var(--primaryColor);
}
}

>div {
.search-result-div {
box-shadow: var(--componentShadow);
margin-top: 2px;
top: unset;
width: 100%;

.ant-collapse {

overflow-y: unset;

.ant-collapse-header {
line-height: unset;
border-bottom: solid 1px var(--secondaryColor);
background-color: color-mix(in srgb, var(--secondaryColor) 15%, white);
}

.ant-collapse-content {
max-height: 25vh;
overflow-y: auto;

.ant-list-item {
justify-content: flex-start;

.result-prefix:not(:empty) {
width: 130px;

.ant-tag {
width: 100%;
text-align: center;
}
}
}
}

}

}

.no-search-result-div {
background-color: white;
position: absolute;
width: 100%;
}
}
}
30 changes: 30 additions & 0 deletions src/components/MultiSearch/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

import {
render
} from '@testing-library/react';

import { createReduxWrapper } from '../../utils/testUtils';

import MultiSearch from './index';

describe('<MultiSearch />', () => {

it('is defined', () => {
expect(MultiSearch).not.toBeUndefined();
});

it('can be rendered', () => {
const {
container
} = render(
<MultiSearch
useNominatim={true}
/>, {
wrapper: createReduxWrapper()
}
);
expect(container).toBeVisible();
});

});
Loading

0 comments on commit 4140d57

Please sign in to comment.