Skip to content

Commit

Permalink
back button on left side
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Sep 2, 2023
1 parent e13d2f1 commit 7a2f13f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 44 deletions.
13 changes: 8 additions & 5 deletions src/sidebar/search/AddressInput.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@
}

.fullscreen .inputContainer {
grid-gap: 0.5rem;
grid-template-columns: auto 1fr;
}

.fullscreen .smallList {
grid-column: 2 / 2;
}

.fullscreen .btnClose {
display: flex;
align-self: stretch;
justify-self: stretch;
align-items: center;
display: block;
margin: 0;
padding: 5px 15px 5px 5px;
}
}

Expand Down
71 changes: 37 additions & 34 deletions src/sidebar/search/AddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Autocomplete, {
SelectCurrentLocationItem,
} from '@/sidebar/search/AddressInputAutocomplete'

import ArrowBack from './arrow_back.svg'
import styles from './AddressInput.module.css'
import Api, { getApi } from '@/api/Api'
import { tr } from '@/translation/Translation'
Expand Down Expand Up @@ -132,6 +133,15 @@ export default function AddressInput(props: AddressInputProps) {
: {},
].join(' ')}
>
<PlainButton
className={styles.btnClose}
onClick={() => {
setHasFocus(false)
hideSuggestions()
}}
>
<ArrowBack/>
</PlainButton>
<input
style={props.moveStartIndex == props.index ? { borderWidth: '2px', margin: '-1px' } : {}}
className={styles.input}
Expand Down Expand Up @@ -163,40 +173,31 @@ export default function AddressInput(props: AddressInputProps) {
type == QueryPointType.From ? 'from_hint' : type == QueryPointType.To ? 'to_hint' : 'via_hint'
)}
/>
<PlainButton
className={styles.btnClose}
onClick={() => {
setHasFocus(false)
hideSuggestions()
}}
>
{tr('back_to_map')}
</PlainButton>
</div>

{autocompleteItems.length > 0 && (
<ResponsiveAutocomplete inputRef={searchInput.current!} isSmallScreen={isSmallScreen}>
<Autocomplete
items={autocompleteItems}
highlightedItem={autocompleteItems[highlightedResult]}
setPointerDown={setPointerDownOnSuggestion}
onSelect={item => {
setHasFocus(false)
if (item instanceof GeocodingItem) {
hideSuggestions()
props.onAddressSelected(item.toText(), item.point, item.bbox)
} else if (item instanceof SelectCurrentLocationItem) {
hideSuggestions()
onCurrentLocationSelected(props.onAddressSelected)
} else if (item instanceof MoreResultsItem) {
// do not hide autocomplete items
const coordinate = textToCoordinate(item.search)
if (!coordinate) geocoder.request(item.search, 'nominatim')
}
}}
/>
</ResponsiveAutocomplete>
)}
{autocompleteItems.length > 0 && (
<ResponsiveAutocomplete inputRef={searchInput.current!} isSmallScreen={isSmallScreen}>
<Autocomplete
items={autocompleteItems}
highlightedItem={autocompleteItems[highlightedResult]}
setPointerDown={setPointerDownOnSuggestion}
onSelect={item => {
setHasFocus(false)
if (item instanceof GeocodingItem) {
hideSuggestions()
props.onAddressSelected(item.toText(), item.point, item.bbox)
} else if (item instanceof SelectCurrentLocationItem) {
hideSuggestions()
onCurrentLocationSelected(props.onAddressSelected)
} else if (item instanceof MoreResultsItem) {
// do not hide autocomplete items
const coordinate = textToCoordinate(item.search)
if (!coordinate) geocoder.request(item.search, 'nominatim')
}
}}
/>
</ResponsiveAutocomplete>
)}
</div>
</div>
)
}
Expand All @@ -206,7 +207,9 @@ function ResponsiveAutocomplete({ inputRef, children, isSmallScreen }: { inputRe
return (
<>
{isSmallScreen ? (
children
<div className={styles.smallList}>
{children}
</div>
) : (
<PopUp inputElement={inputRef} keepClearAtBottom={270}>
{children}
Expand Down
6 changes: 1 addition & 5 deletions src/sidebar/search/AddressInputAutocomplete.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.autocompleteItem:not(:last-child) {
border-bottom: 1px lightgray solid;
}

.selectableItem {
display: block;
width: 100%;
Expand Down Expand Up @@ -61,6 +57,6 @@
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
font-size: small;
font-size: x-small;
color: #5b616a;
}
1 change: 1 addition & 0 deletions src/sidebar/search/arrow_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7a2f13f

Please sign in to comment.