PHP 8.2.30
Preview: triangle.js Size: 3.66 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/polished/lib/mixins/triangle.js

"use strict";

exports.__esModule = true;
exports["default"] = triangle;
var _getValueAndUnit = _interopRequireDefault(require("../helpers/getValueAndUnit"));
var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getBorderWidth = function getBorderWidth(pointingDirection, height, width) {
  var fullWidth = "" + width[0] + (width[1] || '');
  var halfWidth = "" + width[0] / 2 + (width[1] || '');
  var fullHeight = "" + height[0] + (height[1] || '');
  var halfHeight = "" + height[0] / 2 + (height[1] || '');
  switch (pointingDirection) {
    case 'top':
      return "0 " + halfWidth + " " + fullHeight + " " + halfWidth;
    case 'topLeft':
      return fullWidth + " " + fullHeight + " 0 0";
    case 'left':
      return halfHeight + " " + fullWidth + " " + halfHeight + " 0";
    case 'bottomLeft':
      return fullWidth + " 0 0 " + fullHeight;
    case 'bottom':
      return fullHeight + " " + halfWidth + " 0 " + halfWidth;
    case 'bottomRight':
      return "0 0 " + fullWidth + " " + fullHeight;
    case 'right':
      return halfHeight + " 0 " + halfHeight + " " + fullWidth;
    case 'topRight':
    default:
      return "0 " + fullWidth + " " + fullHeight + " 0";
  }
};
var getBorderColor = function getBorderColor(pointingDirection, foregroundColor) {
  switch (pointingDirection) {
    case 'top':
    case 'bottomRight':
      return {
        borderBottomColor: foregroundColor
      };
    case 'right':
    case 'bottomLeft':
      return {
        borderLeftColor: foregroundColor
      };
    case 'bottom':
    case 'topLeft':
      return {
        borderTopColor: foregroundColor
      };
    case 'left':
    case 'topRight':
      return {
        borderRightColor: foregroundColor
      };
    default:
      throw new _errors["default"](59);
  }
};

/**
 * CSS to represent triangle with any pointing direction with an optional background color.
 *
 * @example
 * // Styles as object usage
 *
 * const styles = {
 *   ...triangle({ pointingDirection: 'right', width: '100px', height: '100px', foregroundColor: 'red' })
 * }
 *
 *
 * // styled-components usage
 * const div = styled.div`
 *   ${triangle({ pointingDirection: 'right', width: '100px', height: '100px', foregroundColor: 'red' })}
 *
 *
 * // CSS as JS Output
 *
 * div: {
 *  'borderColor': 'transparent transparent transparent red',
 *  'borderStyle': 'solid',
 *  'borderWidth': '50px 0 50px 100px',
 *  'height': '0',
 *  'width': '0',
 * }
 */
function triangle(_ref) {
  var pointingDirection = _ref.pointingDirection,
    height = _ref.height,
    width = _ref.width,
    foregroundColor = _ref.foregroundColor,
    _ref$backgroundColor = _ref.backgroundColor,
    backgroundColor = _ref$backgroundColor === void 0 ? 'transparent' : _ref$backgroundColor;
  var widthAndUnit = (0, _getValueAndUnit["default"])(width);
  var heightAndUnit = (0, _getValueAndUnit["default"])(height);
  if (isNaN(heightAndUnit[0]) || isNaN(widthAndUnit[0])) {
    throw new _errors["default"](60);
  }
  return _extends({
    width: '0',
    height: '0',
    borderColor: backgroundColor
  }, getBorderColor(pointingDirection, foregroundColor), {
    borderStyle: 'solid',
    borderWidth: getBorderWidth(pointingDirection, heightAndUnit, widthAndUnit)
  });
}
module.exports = exports.default;

Directory Contents

Dirs: 0 × Files: 48

Name Size Perms Modified Actions
162 B lrw-r--r-- 2026-02-28 00:31:10
Edit Download
2.54 KB lrw-r--r-- 2026-02-28 00:30:16
Edit Download
1.96 KB lrw-r--r-- 2026-02-28 00:28:52
Edit Download
120 B lrw-r--r-- 2026-02-28 00:31:12
Edit Download
703 B lrw-r--r-- 2026-02-28 00:30:22
Edit Download
627 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
123 B lrw-r--r-- 2026-02-28 00:31:12
Edit Download
699 B lrw-r--r-- 2026-02-28 00:30:24
Edit Download
649 B lrw-r--r-- 2026-02-28 00:29:04
Edit Download
179 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
1.39 KB lrw-r--r-- 2026-02-28 00:30:28
Edit Download
1.04 KB lrw-r--r-- 2026-02-28 00:29:12
Edit Download
299 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
4.46 KB lrw-r--r-- 2026-02-28 00:30:30
Edit Download
2.56 KB lrw-r--r-- 2026-02-28 00:29:16
Edit Download
412 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
4.11 KB lrw-r--r-- 2026-02-28 00:30:30
Edit Download
3.54 KB lrw-r--r-- 2026-02-28 00:29:18
Edit Download
105 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
719 B lrw-r--r-- 2026-02-28 00:30:34
Edit Download
692 B lrw-r--r-- 2026-02-28 00:29:30
Edit Download
113 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
1018 B lrw-r--r-- 2026-02-28 00:30:34
Edit Download
986 B lrw-r--r-- 2026-02-28 00:29:32
Edit Download
71 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
1.13 KB lrw-r--r-- 2026-02-28 00:30:34
Edit Download
1022 B lrw-r--r-- 2026-02-28 00:29:32
Edit Download
274 B lrw-r--r-- 2026-02-28 00:31:16
Edit Download
1.98 KB lrw-r--r-- 2026-02-28 00:30:40
Edit Download
1.59 KB lrw-r--r-- 2026-02-28 00:29:40
Edit Download
114 B lrw-r--r-- 2026-02-28 00:31:20
Edit Download
3.40 KB lrw-r--r-- 2026-02-28 00:30:44
Edit Download
3.73 KB lrw-r--r-- 2026-02-28 00:29:46
Edit Download
290 B lrw-r--r-- 2026-02-28 00:31:20
Edit Download
2.18 KB lrw-r--r-- 2026-02-28 00:30:56
Edit Download
1.62 KB lrw-r--r-- 2026-02-28 00:29:52
Edit Download
233 B lrw-r--r-- 2026-02-28 00:31:22
Edit Download
2.21 KB lrw-r--r-- 2026-02-28 00:30:58
Edit Download
1.58 KB lrw-r--r-- 2026-02-28 00:29:56
Edit Download
166 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
2.36 KB lrw-r--r-- 2026-02-28 00:31:00
Edit Download
2.38 KB lrw-r--r-- 2026-02-28 00:30:02
Edit Download
281 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
3.66 KB lrw-r--r-- 2026-02-28 00:31:02
Edit Download
3.01 KB lrw-r--r-- 2026-02-28 00:30:06
Edit Download
118 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
743 B lrw-r--r-- 2026-02-28 00:31:04
Edit Download
675 B lrw-r--r-- 2026-02-28 00:30:06
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).