Source

styledComponents/getTriangleCss.js

"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var macro_1 = require("styled-components/macro");
/**
 * Source: http://apps.eky.hk/css-triangle-generator/
 *
 * @param {string} direction
 * @param {string} color
 * @param {number} width
 * @param {number} height
 * @category styledComponents
 * @module getTriangleCss
 */
var getTriangleCss = function (direction, color, width, height) {
    if (direction === void 0) { direction = 'down'; }
    if (color === void 0) { color = '#333'; }
    if (width === void 0) { width = 20; }
    if (height === void 0) { height = 20; }
    return (0, macro_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n  width: 0;\n  height: 0;\n  border-style: solid;\n  ", "\n"], ["\n  width: 0;\n  height: 0;\n  border-style: solid;\n  ", "\n"])), function () {
        switch (direction) {
            case 'right':
                return (0, macro_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n          border-width: ", "px 0 ", "px ", "px;\n          border-color: transparent transparent transparent ", ";\n        "], ["\n          border-width: ", "px 0 ", "px ", "px;\n          border-color: transparent transparent transparent ", ";\n        "])), height / 2, height / 2, width, color);
            case 'left':
                return (0, macro_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n          border-width: ", "px ", "px ", "px 0;\n          border-color: transparent ", " transparent transparent;\n        "], ["\n          border-width: ", "px ", "px ", "px 0;\n          border-color: transparent ", " transparent transparent;\n        "])), height / 2, width, height / 2, color);
            case 'up':
                return (0, macro_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n          border-width: 0 ", "px ", "px ", "px;\n          border-color: transparent transparent ", " transparent;\n        "], ["\n          border-width: 0 ", "px ", "px ", "px;\n          border-color: transparent transparent ", " transparent;\n        "])), width / 2, height, width / 2, color);
            case 'down':
            default:
                return (0, macro_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n          border-width: ", "px ", "px 0 ", "px;\n          border-color: ", " transparent transparent transparent;\n        "], ["\n          border-width: ", "px ", "px 0 ", "px;\n          border-color: ", " transparent transparent transparent;\n        "])), height, width / 2, width / 2, color);
        }
    });
};
exports.default = getTriangleCss;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;