-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathselect-icon-clear.tsx
62 lines (55 loc) · 1.49 KB
/
select-icon-clear.tsx
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react'
import useTheme from '../use-theme'
interface Props {
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void
}
const SelectIconClear: React.FC<Props> = ({ onClick }) => {
const theme = useTheme()
const clickHandler = (event: React.MouseEvent<HTMLDivElement>) => {
event.preventDefault()
event.stopPropagation()
event.nativeEvent.stopImmediatePropagation()
onClick && onClick(event)
}
return (
<div onClick={clickHandler} className="clear-icon">
<svg
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
fill="none"
shapeRendering="geometricPrecision"
>
<path d="M18 6L6 18" />
<path d="M6 6l12 12" />
</svg>
<style jsx>{`
.clear-icon {
padding: 0 0 0 0.5em;
margin: 0;
display: inline-flex;
align-items: center;
height: 100%;
cursor: pointer;
box-sizing: border-box;
transition: color 150ms ease 0s;
color: ${theme.palette.accents_3};
visibility: visible;
opacity: 1;
}
.clear-icon:hover {
color: ${theme.palette.foreground};
}
svg {
color: currentColor;
width: 1em;
height: 1em;
}
`}</style>
</div>
)
}
const MemoSelectIconClear = React.memo(SelectIconClear)
export default MemoSelectIconClear