-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathSearch.tsx
More file actions
33 lines (29 loc) · 840 Bytes
/
Search.tsx
File metadata and controls
33 lines (29 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as React from 'react'
import styled from 'styled-components'
import { ComponentType } from '../types'
export const SearchInput = styled.input`
color: white;
padding: 1px 8px;
border: 1px solid white;
border-radius: 10px;
font-size: 16px;
font-family: serif;
width: 100%;
box-sizing: border-box;
background: transparent;
`
export function Search(props: { value: string, onChange(value: string): void, component?: ComponentType }) {
const Component = props.component || SearchInput
return (
<Component
value={props.value}
onInput={(e: React.FormEvent<HTMLInputElement>) => {
props.onChange((e.target as HTMLInputElement).value)
}}
onPointerDown={(e: React.PointerEvent) => {
e.stopPropagation()
}}
data-testid="context-menu-search-input"
/>
)
}