UNPKG

1.74 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.hexToRgb = hexToRgb;
7exports.expandBorderStyles = expandBorderStyles;
8exports.ellipsisText = void 0;
9
10/*
11Copyright (c) 2018-2020 Uber Technologies, Inc.
12
13This source code is licensed under the MIT license found in the
14LICENSE file in the root directory of this source tree.
15*/
16function hexToRgb() {
17 var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
18 var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1';
19 var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
20 hex = hex.replace(shorthandRegex, function (m, r, g, b) {
21 return r + r + g + g + b + b;
22 });
23 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
24 return result ? "rgba(".concat(parseInt(result[1], 16), ", ").concat(parseInt(result[2], 16), ", ").concat(parseInt(result[3], 16), ", ").concat(alpha, ")") : null;
25}
26
27var ellipsisText = {
28 overflow: 'hidden',
29 textOverflow: 'ellipsis',
30 whiteSpace: 'nowrap',
31 wordWrap: 'normal'
32};
33exports.ellipsisText = ellipsisText;
34
35function expandBorderStyles(borderStyles) {
36 return {
37 borderTopWidth: borderStyles.borderWidth,
38 borderTopStyle: borderStyles.borderStyle,
39 borderTopColor: borderStyles.borderColor,
40 borderBottomWidth: borderStyles.borderWidth,
41 borderBottomStyle: borderStyles.borderStyle,
42 borderBottomColor: borderStyles.borderColor,
43 borderLeftWidth: borderStyles.borderWidth,
44 borderLeftStyle: borderStyles.borderStyle,
45 borderLeftColor: borderStyles.borderColor,
46 borderRightWidth: borderStyles.borderWidth,
47 borderRightStyle: borderStyles.borderStyle,
48 borderRightColor: borderStyles.borderColor
49 };
50}
\No newline at end of file