-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathtip.js
30 lines (27 loc) · 899 Bytes
/
tip.js
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
import React from "react"
const Tip = props => {
const { direction } = props
const size = props.size || 24
const isPortrait = direction === "up" || direction === "down"
const mainLength = size
const crossLength = size * 2
const points =
direction === "up"
? `0,${mainLength} ${mainLength},0, ${crossLength},${mainLength}`
: direction === "down"
? `0,0 ${mainLength},${mainLength}, ${crossLength},0`
: direction === "left"
? `${mainLength},0 0,${mainLength}, ${mainLength},${crossLength}`
: `0,0 ${mainLength},${mainLength}, 0,${crossLength}`
const svgProps = {
className: "Popover-tip",
width: isPortrait ? crossLength : mainLength,
height: isPortrait ? mainLength : crossLength,
}
return (
<svg {...svgProps}>
<polygon className="Popover-tipShape" points={points} />
</svg>
)
}
export default Tip