UNPKG

@elastic/eui

Version:

Elastic UI Component Library

35 lines (34 loc) 2.1 kB
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import { css } from '@emotion/react'; import { logicalCSS, logicalSizeCSS, mathWithUnits } from '../../global_styling/functions'; /** * Arrow clipping/transform/positioning CSS shared between EuiPopover and EuiToolTip */ export var _popoverArrowStyles = function _popoverArrowStyles(_ref, arrowSize) { var euiTheme = _ref.euiTheme, colorMode = _ref.colorMode, highContrastMode = _ref.highContrastMode; var hasBorder = colorMode === 'DARK'; var arrowOffset = mathWithUnits([arrowSize, euiTheme.border.width.thin // account for 1px pseudo element border on panel ], function (x, y) { return highContrastMode ? x / -2 : x / -2 - y; }); var arrowBorderRadius = mathWithUnits(euiTheme.border.radius.small, function (x) { return x / 2; }); return { _arrowStyles: "\n position: absolute;\n z-index: 1;\n ".concat(logicalSizeCSS(arrowSize), "\n border-radius: ").concat(arrowBorderRadius, ";\n /* Use clip-path to ensure that arrows don't overlap into popover content */\n clip-path: polygon(0 0, 100% 100%, 0 100%);\n transform-origin: center;\n ").concat(hasBorder ? "border: ".concat(euiTheme.border.thin, ";") : '', "\n "), positions: { top: /*#__PURE__*/css(logicalCSS('margin-top', arrowOffset), " transform:rotate(-45deg);;label:top;"), bottom: /*#__PURE__*/css(logicalCSS('bottom', 0), " ", logicalCSS('margin-bottom', arrowOffset), " transform:rotate(135deg);;label:bottom;"), left: /*#__PURE__*/css(logicalCSS('margin-left', arrowOffset), " transform:rotate(-135deg);;label:left;"), right: /*#__PURE__*/css(logicalCSS('right', 0), " ", logicalCSS('margin-right', arrowOffset), " transform:rotate(45deg);;label:right;") } }; };