Skip to content

Commit 79b51b4

Browse files
committed
add Search icon with configurable color and size
fix #13
1 parent 13e1ed7 commit 79b51b4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/autocomplete/autocomplete.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
rgba(0, 0, 0, 0) 0px 0px 0px 0px,
3333
rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
3434

35+
--search-icon-color: var(--gray-500);
36+
--search-icon-size: 20px;
37+
3538
--loading-color: var(--gray-500);
3639
--loading-size: 31px;
3740

@@ -83,7 +86,11 @@
8386
display: block;
8487
width: 100%;
8588
border: 1px solid var(--input-border-color);
86-
padding: 13px 55px 13px 12px; /* 12 + 31 + 12 = 55, loading spinner is 31 wide */;
89+
padding:
90+
13px
91+
calc(12px + var(--loading-size) + 12px)
92+
13px
93+
calc(12px + var(--search-icon-size) + 9px);
8794
border-radius: var(--border-radius);
8895
appearance: none;
8996
-webkit-appearance: none;
@@ -101,6 +108,15 @@
101108
stroke: var(--loading-color);
102109
}
103110

111+
.search-icon {
112+
position: absolute;
113+
color: var(--search-icon-color);
114+
left: 12px;
115+
top: calc((var(--input-height) - var(--search-icon-size)) / 2);
116+
width: var(--search-icon-size);
117+
height: var(--search-icon-size);
118+
}
119+
104120
.results {
105121
font-size: 16px;
106122
position: absolute;

src/autocomplete/autocomplete.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createAutocomplete } from '@geocodeearth/core-js'
44
import debounce from 'lodash.debounce'
55
import css from './autocomplete.css'
66
import strings from '../strings'
7-
import { LocationMarker, Loading } from '../icons'
7+
import { LocationMarker, Loading, Search as SearchIcon } from '../icons'
88
import escape from '../escape'
99

1010
const emptyResults = {
@@ -153,6 +153,7 @@ export default ({
153153
<label {...getLabelProps()} className='label'>{placeholder}</label>
154154

155155
<div {...getComboboxProps()} >
156+
<SearchIcon className='search-icon' />
156157
<input {...getInputProps({ref: inputRef})} spellCheck={false} placeholder={placeholder} className='input' />
157158
{isLoading && <Loading className={'loading'} />}
158159
</div>

src/icons.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export const LocationMarker = ({className}) =>
1212
<path fillRule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" clipRule="evenodd" />
1313
</svg>
1414

15+
16+
export const Search = ({className}) =>
17+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="currentColor" fill="none" className={className}>
18+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
19+
</svg>
20+
1521
/**
1622
* SVG Loaders (github.com/SamHerbert/SVG-Loaders)
1723
* Copyright (c) 2014 Sam Herbert

0 commit comments

Comments
 (0)