Skip to content

Commit 5e7998c

Browse files
authored
update InputSearch to have the search Icon (#693)
* update InputSearch to have the search Icon * update tests and other components affected by InputSearch
1 parent 81d03eb commit 5e7998c

File tree

8 files changed

+165
-2
lines changed

8 files changed

+165
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
### Change
1818

1919
- move path for InlineInputText now under Form/Inputs
20+
- update InputSearch to display search icon
2021
- `ArrowDropDown` and `ArrowDropUp` Icons renamed to `ArrowUp` and `ArrowDown`
2122
- `CacheRefesh` Icon update
2223
- `Confirm` no longer displays a `Close` `IconButton` in the header
2324

25+
2426
## [0.7.24] - 2020-03-12
2527

2628
### Added

packages/components/src/Form/Inputs/Combobox/ComboboxInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const ComboboxInputInternal = forwardRef(
169169
<InputSearch
170170
{...rest}
171171
{...inputEvents}
172+
hideSearchIcon
172173
ref={ref}
173174
value={inputValue}
174175
readOnly={readOnly}

packages/components/src/Form/Inputs/InputChips/InputChipsBase.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const InputChipsBaseInternal = forwardRef(
9494

9595
return (
9696
<InputSearch
97+
hideSearchIcon
9798
ref={ref}
9899
value={inputValue}
99100
onChange={handleInputChange}

packages/components/src/Form/Inputs/InputSearch/InputSearch.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ test('InputSearch default', () => {
4040
assertSnapshot(<InputSearch />)
4141
})
4242

43+
test('InputSearch hideSearchIcon removes the icon', () => {
44+
assertSnapshot(<InputSearch hideSearchIcon />)
45+
})
46+
4347
test('InputSearch displays placeholder', () => {
4448
const wrapper = mountWithTheme(<InputSearch placeholder="Type your search" />)
4549
expect(wrapper.props().children.props.placeholder).toEqual('Type your search')

packages/components/src/Form/Inputs/InputSearch/InputSearch.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
} from '../InputText'
5151
import { useControlWarn, useForkedRef, useWrapEvent } from '../../../utils'
5252
import { Flex } from '../../../Layout'
53+
import { Icon } from '../../../Icon'
5354
import { InputSearchControls } from './InputSearchControls'
5455

5556
const getHeight = (
@@ -71,6 +72,10 @@ export interface InputSearchProps extends InputTextProps {
7172
* hides clear button and summary text
7273
*/
7374
hideControls?: boolean
75+
/**
76+
* hides search Icon
77+
*/
78+
hideSearchIcon?: boolean
7479
/**
7580
* overrides the internal logic that shows the clear icon when there's a value
7681
*/
@@ -95,6 +100,11 @@ export interface InputSearchProps extends InputTextProps {
95100
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void
96101
}
97102

103+
export const SearchIcon = styled(Icon)`
104+
color: ${props => props.theme.colors.palette.charcoal400};
105+
padding-left: ${props => props.theme.space.small};
106+
`
107+
98108
const InputSearchComponent = forwardRef(
99109
(
100110
{
@@ -112,6 +122,7 @@ const InputSearchComponent = forwardRef(
112122
className,
113123
defaultValue,
114124
hideControls = false,
125+
hideSearchIcon = false,
115126
showClear,
116127
summary,
117128
value: controlledValue = '',
@@ -197,6 +208,7 @@ const InputSearchComponent = forwardRef(
197208
{...omit(props, inputPropKeys)}
198209
{...mouseHandlers}
199210
>
211+
{!hideSearchIcon && <SearchIcon name="Search" size={30} />}
200212
{children ? (
201213
<Flex alignItems="flex-start" flexWrap="wrap">
202214
{children}

packages/components/src/Form/Inputs/InputSearch/__snapshots__/InputSearch.test.tsx.snap

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,145 @@ exports[`InputSearch default 1`] = `
1515
display: flex;
1616
}
1717
18+
.c2 {
19+
width: 30px;
20+
height: 30px;
21+
-webkit-align-items: center;
22+
-webkit-box-align: center;
23+
-ms-flex-align: center;
24+
align-items: center;
25+
display: -webkit-inline-box;
26+
display: -webkit-inline-flex;
27+
display: -ms-inline-flexbox;
28+
display: inline-flex;
29+
}
30+
31+
.c4 {
32+
height: 36px;
33+
}
34+
35+
.c4:hover {
36+
border-color: #C1C6CC;
37+
}
38+
39+
.c4:focus,
40+
.c4:focus-within {
41+
border-color: #9785F2;
42+
box-shadow: 0 0 0 2px #E8E5FF;
43+
outline: none;
44+
}
45+
46+
.c6 {
47+
border-radius: 0.25rem;
48+
border: solid 1px;
49+
border-color: #DEE1E5;
50+
height: 36px;
51+
padding-right: 0.75rem;
52+
padding-left: 0.75rem;
53+
padding-top: 0rem;
54+
padding-bottom: 0rem;
55+
font-size: 0.875rem;
56+
color: #343C42;
57+
}
58+
59+
.c6:focus {
60+
outline: none;
61+
}
62+
63+
.c3 {
64+
color: #939BA5;
65+
padding-left: 0.75rem;
66+
}
67+
68+
.c1 {
69+
-webkit-align-items: center;
70+
-webkit-box-align: center;
71+
-ms-flex-align: center;
72+
align-items: center;
73+
background-color: #FFFFFF;
74+
}
75+
76+
.c1:hover {
77+
border-color: #C1C6CC;
78+
}
79+
80+
.c1:focus-within {
81+
border-color: #9785F2;
82+
box-shadow: 0 0 0 2px #E8E5FF;
83+
outline: none;
84+
}
85+
86+
.c1 .c5 {
87+
border: none;
88+
-webkit-appearance: none;
89+
-moz-appearance: none;
90+
appearance: none;
91+
background: transparent;
92+
box-shadow: none;
93+
-webkit-flex: 1;
94+
-ms-flex: 1;
95+
flex: 1;
96+
width: 100%;
97+
height: calc(36px - 6px);
98+
}
99+
100+
.c1 .c5::-webkit-search-decoration,
101+
.c1 .c5::-webkit-search-cancel-button,
102+
.c1 .c5::-webkit-search-results-button,
103+
.c1 .c5::-webkit-search-results-decoration {
104+
-webkit-appearance: none;
105+
-moz-appearance: none;
106+
appearance: none;
107+
}
108+
109+
<div
110+
className="c0 c1"
111+
fontSize="small"
112+
onMouseDown={[Function]}
113+
>
114+
<div
115+
className="c2 c3"
116+
size={30}
117+
>
118+
<svg
119+
fill="currentColor"
120+
height="100%"
121+
viewBox="0 0 24 24"
122+
width="100%"
123+
>
124+
<title>
125+
Search
126+
</title>
127+
<path
128+
d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
129+
fill="currentColor"
130+
/>
131+
</svg>
132+
</div>
133+
<input
134+
className="c4 c5 c6"
135+
onChange={[Function]}
136+
type="text"
137+
value=""
138+
/>
139+
</div>
140+
`;
141+
142+
exports[`InputSearch hideSearchIcon removes the icon 1`] = `
143+
.c0 {
144+
border-radius: 0.25rem;
145+
border: solid 1px;
146+
border-color: #DEE1E5;
147+
padding-top: 2px;
148+
padding-bottom: 2px;
149+
padding-right: 0.25rem;
150+
font-size: 0.875rem;
151+
display: -webkit-box;
152+
display: -webkit-flex;
153+
display: -ms-flexbox;
154+
display: flex;
155+
}
156+
18157
.c2 {
19158
height: 36px;
20159
}

packages/components/src/Menu/MenuSearch/MenuSearch.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const MenuSearch: FC<MenuSearchProps> = ({ menuRef, ...props }) => {
4848
>
4949
<ObserveKeys except={[]} only={['down', 'up']}>
5050
<InputSearch
51+
hideSearchIcon
5152
borderRadius={0}
5253
border="none"
5354
borderBottom={`1px solid ${palette.charcoal200}`}

packages/www/src/documentation/components/forms/input-search.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ propsOf: InputSearch
55
figma: file/2MG6DoSjk4IaLnjjFCnKFf/Forms
66
---
77

8-
The `<InputSearch />` component renders a single search input element. You can add a placeholder, and a starter value, also a summary text and a closing button associated with it. To remove the button and summary use the hideControls option. If you are building a menu you probably want to use `<MenuSearch />`.
8+
The `<InputSearch />` component renders a single search input element. You can add a placeholder, and a starter value, also a summary text and a closing button associated with it. To remove the button and summary use the hideControls option. If you are building a menu you probably want to use `<MenuSearch />`. If you don't want to see the search `Icon` use the prop `hideSearchIcon`
99

1010
```jsx
1111
<InputSearch placeholder="Type your search" />
1212
<Divider my="medium" />
1313
<InputSearch placeholder="Type your search" value="test search" />
14-
<Divider my="medium" />
14+
<Divider my="medium"/>
1515
<InputSearch
1616
width="50%"
1717
placeholder="Type your search"
@@ -24,6 +24,9 @@ The `<InputSearch />` component renders a single search input element. You can a
2424
value="test search 1"
2525
hideControls
2626
/>
27+
<Divider my="medium"/>
28+
<InputSearch hideSearchIcon placeholder="No search icon here" />
29+
2730
```
2831

2932
## Controlled Example

0 commit comments

Comments
 (0)