UNPKG

2.48 kBJavaScriptView Raw
1/*
2 * Copyright 2017 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as React from "react";
17import * as Classes from "../../common/classes";
18import { DISPLAYNAME_PREFIX } from "../../common/props";
19import { getPosition } from "./popperUtils";
20// these paths come from the Core Kit Sketch file
21// https://github.com/palantir/blueprint/blob/develop/resources/sketch/Core%20Kit.sketch
22var SVG_SHADOW_PATH = "M8.11 6.302c1.015-.936 1.887-2.922 1.887-4.297v26c0-1.378" +
23 "-.868-3.357-1.888-4.297L.925 17.09c-1.237-1.14-1.233-3.034 0-4.17L8.11 6.302z";
24var SVG_ARROW_PATH = "M8.787 7.036c1.22-1.125 2.21-3.376 2.21-5.03V0v30-2.005" +
25 "c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z";
26/** Modifier helper function to compute arrow rotate() transform */
27function getArrowAngle(placement) {
28 if (placement == null) {
29 return 0;
30 }
31 // can only be top/left/bottom/right - auto is resolved internally
32 switch (getPosition(placement)) {
33 case "top":
34 return -90;
35 case "left":
36 return 180;
37 case "bottom":
38 return 90;
39 default:
40 return 0;
41 }
42}
43export var PopoverArrow = function (_a) {
44 var _b = _a.arrowProps, ref = _b.ref, style = _b.style, placement = _a.placement;
45 return (React.createElement("div", { className: Classes.POPOVER_ARROW, ref: ref, style: style.left == null || isNaN(+style.left) ? {} : style },
46 React.createElement("svg", { viewBox: "0 0 30 30", style: { transform: "rotate(" + getArrowAngle(placement) + "deg)" } },
47 React.createElement("path", { className: Classes.POPOVER_ARROW + "-border", d: SVG_SHADOW_PATH }),
48 React.createElement("path", { className: Classes.POPOVER_ARROW + "-fill", d: SVG_ARROW_PATH }))));
49};
50PopoverArrow.displayName = DISPLAYNAME_PREFIX + ".PopoverArrow";
51//# sourceMappingURL=popoverArrow.js.map
\No newline at end of file