1 | import { DOM as E } from "react"
|
2 | import createReactClass from "create-react-class"
|
3 |
|
4 |
|
5 |
|
6 | const Tip = createReactClass({
|
7 | displayName: "tip",
|
8 | render () {
|
9 | const { direction } = this.props
|
10 | const size = this.props.size || 24
|
11 | const isPortrait = direction === "up" || direction === "down"
|
12 | const mainLength = size
|
13 | const crossLength = size * 2
|
14 | const points = (
|
15 | direction === "up" ? `0,${mainLength} ${mainLength},0, ${crossLength},${mainLength}`
|
16 | : direction === "down" ? `0,0 ${mainLength},${mainLength}, ${crossLength},0`
|
17 | : direction === "left" ? `${mainLength},0 0,${mainLength}, ${mainLength},${crossLength}`
|
18 | : `0,0 ${mainLength},${mainLength}, 0,${crossLength}`
|
19 | )
|
20 | const props = {
|
21 | className: "Popover-tip",
|
22 | width: isPortrait ? crossLength : mainLength,
|
23 | height: isPortrait ? mainLength : crossLength,
|
24 | }
|
25 | const triangle = (
|
26 | E.svg(props,
|
27 | E.polygon({
|
28 | className: "Popover-tipShape",
|
29 | points,
|
30 | })
|
31 | )
|
32 | )
|
33 | return (
|
34 | triangle
|
35 | )
|
36 | },
|
37 | })
|
38 |
|
39 |
|
40 | export {
|
41 | Tip as default,
|
42 | }
|