@thecb/components 11.0.2 → 11.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +724 -113
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +724 -113
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +14 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +57 -18
- package/src/components/atoms/icons/SuccessfulIconMedium.js +3 -2
- package/src/util/general.js +40 -0
package/dist/index.cjs.js
CHANGED
|
@@ -6219,6 +6219,43 @@ var wrapIndex = function wrapIndex(index, length) {
|
|
|
6219
6219
|
}
|
|
6220
6220
|
};
|
|
6221
6221
|
|
|
6222
|
+
/**
|
|
6223
|
+
* Adjusts a hex color by lightening or darkening it.
|
|
6224
|
+
*
|
|
6225
|
+
* Intended for use when a satisfactory color is not available in the design system.
|
|
6226
|
+
*
|
|
6227
|
+
* @param {string} hex - The original hex color (e.g., "#3498db").
|
|
6228
|
+
* @param {number} percent - The percentage to adjust the color (0-100).
|
|
6229
|
+
* @param {string} action - The action to perform: 'lighten' or 'darken'.
|
|
6230
|
+
* @returns {string} - The adjusted hex color.
|
|
6231
|
+
* @throws {Error} - Throws an error if the action is not 'lighten' or 'darken'.
|
|
6232
|
+
*/
|
|
6233
|
+
var adjustHexColor = function adjustHexColor(hex, percent, action) {
|
|
6234
|
+
// Remove hash at the start if present
|
|
6235
|
+
hex = hex.replace(/^\s*#/, "");
|
|
6236
|
+
|
|
6237
|
+
// Parse r, g, b values
|
|
6238
|
+
var r = parseInt(hex.substring(0, 2), 16);
|
|
6239
|
+
var g = parseInt(hex.substring(2, 4), 16);
|
|
6240
|
+
var b = parseInt(hex.substring(4, 6), 16);
|
|
6241
|
+
|
|
6242
|
+
// Adjust RGB values based on the action
|
|
6243
|
+
if (action === "darken") {
|
|
6244
|
+
r = Math.max(0, Math.floor(r * (1 - percent / 100)));
|
|
6245
|
+
g = Math.max(0, Math.floor(g * (1 - percent / 100)));
|
|
6246
|
+
b = Math.max(0, Math.floor(b * (1 - percent / 100)));
|
|
6247
|
+
} else if (action === "lighten") {
|
|
6248
|
+
r = Math.min(255, Math.floor(r + (255 - r) * (percent / 100)));
|
|
6249
|
+
g = Math.min(255, Math.floor(g + (255 - g) * (percent / 100)));
|
|
6250
|
+
b = Math.min(255, Math.floor(b + (255 - b) * (percent / 100)));
|
|
6251
|
+
} else {
|
|
6252
|
+
throw new Error("Action must be either 'lighten' or 'darken'");
|
|
6253
|
+
}
|
|
6254
|
+
|
|
6255
|
+
// Convert back to hex
|
|
6256
|
+
return "#".concat(((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).padStart(6, "0"));
|
|
6257
|
+
};
|
|
6258
|
+
|
|
6222
6259
|
var general = /*#__PURE__*/Object.freeze({
|
|
6223
6260
|
__proto__: null,
|
|
6224
6261
|
noop: noop$1,
|
|
@@ -6239,7 +6276,8 @@ var general = /*#__PURE__*/Object.freeze({
|
|
|
6239
6276
|
titleCaseWord: titleCaseWord,
|
|
6240
6277
|
titleCaseString: titleCaseString,
|
|
6241
6278
|
kebabCaseString: kebabCaseString,
|
|
6242
|
-
wrapIndex: wrapIndex
|
|
6279
|
+
wrapIndex: wrapIndex,
|
|
6280
|
+
adjustHexColor: adjustHexColor
|
|
6243
6281
|
});
|
|
6244
6282
|
|
|
6245
6283
|
var _excluded$1 = ["themeValues", "weight", "color", "textWrap", "extraStyles", "hoverStyles", "onClick", "onKeyPress", "as", "dataQa", "children", "variant"];
|
|
@@ -12379,6 +12417,8 @@ var WHITE$1 = WHITE,
|
|
|
12379
12417
|
PEACOCK_BLUE$1 = PEACOCK_BLUE,
|
|
12380
12418
|
MANATEE_GREY$1 = MANATEE_GREY,
|
|
12381
12419
|
MATISSE_BLUE$1 = MATISSE_BLUE,
|
|
12420
|
+
HINT_GREEN$1 = HINT_GREEN,
|
|
12421
|
+
SEA_GREEN$1 = SEA_GREEN,
|
|
12382
12422
|
RASPBERRY$1 = RASPBERRY,
|
|
12383
12423
|
ERROR_COLOR$1 = ERROR_COLOR;
|
|
12384
12424
|
var LINK_TEXT_DECORATION$1 = LINK_TEXT_DECORATION;
|
|
@@ -12393,8 +12433,10 @@ var disabledBorderColor = {
|
|
|
12393
12433
|
tertiary: TRANSPARENT$1,
|
|
12394
12434
|
danger: MANATEE_GREY$1,
|
|
12395
12435
|
dangerSecondary: MANATEE_GREY$1,
|
|
12436
|
+
whitePrimary: MANATEE_GREY$1,
|
|
12396
12437
|
whiteSecondary: MANATEE_GREY$1,
|
|
12397
|
-
|
|
12438
|
+
greenPrimary: SEA_GREEN$1,
|
|
12439
|
+
greenSecondary: SEA_GREEN$1
|
|
12398
12440
|
};
|
|
12399
12441
|
var disabledColor = {
|
|
12400
12442
|
primary: WHITE$1,
|
|
@@ -12407,8 +12449,10 @@ var disabledColor = {
|
|
|
12407
12449
|
tertiary: MANATEE_GREY$1,
|
|
12408
12450
|
danger: WHITE$1,
|
|
12409
12451
|
dangerSecondary: MANATEE_GREY$1,
|
|
12452
|
+
whitePrimary: MANATEE_GREY$1,
|
|
12410
12453
|
whiteSecondary: MANATEE_GREY$1,
|
|
12411
|
-
|
|
12454
|
+
greenPrimary: WHITE$1,
|
|
12455
|
+
greenSecondary: SEA_GREEN$1
|
|
12412
12456
|
};
|
|
12413
12457
|
var disabledBackgroundColor = {
|
|
12414
12458
|
primary: MANATEE_GREY$1,
|
|
@@ -12421,8 +12465,10 @@ var disabledBackgroundColor = {
|
|
|
12421
12465
|
tertiary: TRANSPARENT$1,
|
|
12422
12466
|
danger: MANATEE_GREY$1,
|
|
12423
12467
|
dangerSecondary: TRANSPARENT$1,
|
|
12468
|
+
whitePrimary: TRANSPARENT$1,
|
|
12424
12469
|
whiteSecondary: TRANSPARENT$1,
|
|
12425
|
-
|
|
12470
|
+
greenPrimary: SEA_GREEN$1,
|
|
12471
|
+
greenSecondary: TRANSPARENT$1
|
|
12426
12472
|
};
|
|
12427
12473
|
var padding = {
|
|
12428
12474
|
primary: "0.75rem 1.5rem",
|
|
@@ -12435,8 +12481,10 @@ var padding = {
|
|
|
12435
12481
|
ghost: "0.65rem 0",
|
|
12436
12482
|
danger: "0.75rem 1.5rem",
|
|
12437
12483
|
dangerSecondary: "0.75rem 1.5rem",
|
|
12484
|
+
whitePrimary: "1.125rem 0.75rem",
|
|
12438
12485
|
whiteSecondary: "0.75rem 2rem",
|
|
12439
|
-
|
|
12486
|
+
greenPrimary: "0.75rem 1.5rem",
|
|
12487
|
+
greenSecondary: "0.75rem 1.5rem"
|
|
12440
12488
|
};
|
|
12441
12489
|
var color$1 = {
|
|
12442
12490
|
primary: WHITE$1,
|
|
@@ -12449,8 +12497,10 @@ var color$1 = {
|
|
|
12449
12497
|
tertiary: MATISSE_BLUE$1,
|
|
12450
12498
|
danger: WHITE$1,
|
|
12451
12499
|
dangerSecondary: ERROR_COLOR$1,
|
|
12500
|
+
whitePrimary: WHITE$1,
|
|
12452
12501
|
whiteSecondary: WHITE$1,
|
|
12453
|
-
|
|
12502
|
+
greenPrimary: WHITE$1,
|
|
12503
|
+
greenSecondary: SEA_GREEN$1
|
|
12454
12504
|
};
|
|
12455
12505
|
var fontSizeVariant = {
|
|
12456
12506
|
primary: "pS",
|
|
@@ -12464,7 +12514,9 @@ var fontSizeVariant = {
|
|
|
12464
12514
|
danger: "pS",
|
|
12465
12515
|
dangerSecondary: "pS",
|
|
12466
12516
|
whiteSecondary: "pS",
|
|
12467
|
-
whitePrimary: "pS"
|
|
12517
|
+
whitePrimary: "pS",
|
|
12518
|
+
greenPrimary: "pS",
|
|
12519
|
+
greenSecondary: "pS"
|
|
12468
12520
|
};
|
|
12469
12521
|
var fontWeight = {
|
|
12470
12522
|
primary: "600",
|
|
@@ -12478,7 +12530,9 @@ var fontWeight = {
|
|
|
12478
12530
|
danger: "600",
|
|
12479
12531
|
dangerSecondary: "600",
|
|
12480
12532
|
whiteSecondary: "600",
|
|
12481
|
-
whitePrimary: "600"
|
|
12533
|
+
whitePrimary: "600",
|
|
12534
|
+
greenPrimary: "600",
|
|
12535
|
+
greenSecondary: "600"
|
|
12482
12536
|
};
|
|
12483
12537
|
var height = {
|
|
12484
12538
|
primary: "3rem",
|
|
@@ -12491,8 +12545,10 @@ var height = {
|
|
|
12491
12545
|
tertiary: "3rem",
|
|
12492
12546
|
danger: "3rem",
|
|
12493
12547
|
dangerSecondary: "3rem",
|
|
12548
|
+
whitePrimary: "auto",
|
|
12494
12549
|
whiteSecondary: "3rem",
|
|
12495
|
-
|
|
12550
|
+
greenPrimary: "3rem",
|
|
12551
|
+
greenSecondary: "3rem"
|
|
12496
12552
|
};
|
|
12497
12553
|
var minWidth = {
|
|
12498
12554
|
primary: "130px",
|
|
@@ -12505,8 +12561,10 @@ var minWidth = {
|
|
|
12505
12561
|
tertiary: "130px",
|
|
12506
12562
|
danger: "130px",
|
|
12507
12563
|
dangerSecondary: "157px",
|
|
12564
|
+
whitePrimary: "130px",
|
|
12508
12565
|
whiteSecondary: "160px",
|
|
12509
|
-
|
|
12566
|
+
greenPrimary: "130px",
|
|
12567
|
+
greenSecondary: "130px"
|
|
12510
12568
|
};
|
|
12511
12569
|
var textDecoration = {
|
|
12512
12570
|
primary: "none",
|
|
@@ -12519,8 +12577,10 @@ var textDecoration = {
|
|
|
12519
12577
|
tertiary: "none",
|
|
12520
12578
|
danger: "none",
|
|
12521
12579
|
dangerSecondary: "none",
|
|
12580
|
+
whitePrimary: "none",
|
|
12522
12581
|
whiteSecondary: "none",
|
|
12523
|
-
|
|
12582
|
+
greenPrimary: "none",
|
|
12583
|
+
greenSecondary: "none"
|
|
12524
12584
|
};
|
|
12525
12585
|
var backgroundColor = {
|
|
12526
12586
|
primary: MATISSE_BLUE$1,
|
|
@@ -12533,8 +12593,10 @@ var backgroundColor = {
|
|
|
12533
12593
|
tertiary: TRANSPARENT$1,
|
|
12534
12594
|
danger: RASPBERRY$1,
|
|
12535
12595
|
dangerSecondary: TRANSPARENT$1,
|
|
12596
|
+
whitePrimary: TRANSPARENT$1,
|
|
12536
12597
|
whiteSecondary: TRANSPARENT$1,
|
|
12537
|
-
|
|
12598
|
+
greenPrimary: SEA_GREEN$1,
|
|
12599
|
+
greenSecondary: TRANSPARENT$1
|
|
12538
12600
|
};
|
|
12539
12601
|
var border = {
|
|
12540
12602
|
primary: "2px solid " + MATISSE_BLUE$1,
|
|
@@ -12547,8 +12609,10 @@ var border = {
|
|
|
12547
12609
|
tertiary: "none",
|
|
12548
12610
|
danger: "2px solid " + RASPBERRY$1,
|
|
12549
12611
|
dangerSecondary: "2px solid " + ERROR_COLOR$1,
|
|
12612
|
+
whitePrimary: "2px solid " + TRANSPARENT$1,
|
|
12550
12613
|
whiteSecondary: "2px solid " + WHITE$1,
|
|
12551
|
-
|
|
12614
|
+
greenPrimary: "2px solid " + SEA_GREEN$1,
|
|
12615
|
+
greenSecondary: "2px solid " + SEA_GREEN$1
|
|
12552
12616
|
};
|
|
12553
12617
|
var hoverBackgroundColor = {
|
|
12554
12618
|
primary: SAPPHIRE_BLUE$1,
|
|
@@ -12561,8 +12625,10 @@ var hoverBackgroundColor = {
|
|
|
12561
12625
|
tertiary: TRANSPARENT$1,
|
|
12562
12626
|
danger: "#BA002C",
|
|
12563
12627
|
dangerSecondary: "#FAE7EE",
|
|
12628
|
+
whitePrimary: TRANSPARENT$1,
|
|
12564
12629
|
whiteSecondary: TRANSPARENT$1,
|
|
12565
|
-
|
|
12630
|
+
greenPrimary: adjustHexColor(SEA_GREEN$1, 10, "darken"),
|
|
12631
|
+
greenSecondary: HINT_GREEN$1
|
|
12566
12632
|
};
|
|
12567
12633
|
var hoverBorderColor = {
|
|
12568
12634
|
primary: SAPPHIRE_BLUE$1,
|
|
@@ -12575,8 +12641,10 @@ var hoverBorderColor = {
|
|
|
12575
12641
|
tertiary: TRANSPARENT$1,
|
|
12576
12642
|
danger: "#BA002C",
|
|
12577
12643
|
dangerSecondary: "#B10541",
|
|
12644
|
+
whitePrimary: "2px solid " + TRANSPARENT$1,
|
|
12578
12645
|
whiteSecondary: "2px solid " + TRANSPARENT$1,
|
|
12579
|
-
|
|
12646
|
+
greenPrimary: SEA_GREEN$1,
|
|
12647
|
+
greenSecondary: SEA_GREEN$1
|
|
12580
12648
|
};
|
|
12581
12649
|
var hoverColor = {
|
|
12582
12650
|
primary: WHITE$1,
|
|
@@ -12589,8 +12657,10 @@ var hoverColor = {
|
|
|
12589
12657
|
tertiary: SAPPHIRE_BLUE$1,
|
|
12590
12658
|
danger: WHITE$1,
|
|
12591
12659
|
dangerSecondary: "#B10541",
|
|
12660
|
+
whitePrimary: WHITE$1,
|
|
12592
12661
|
whiteSecondary: WHITE$1,
|
|
12593
|
-
|
|
12662
|
+
greenPrimary: WHITE$1,
|
|
12663
|
+
greenSecondary: SEA_GREEN$1
|
|
12594
12664
|
};
|
|
12595
12665
|
var activeBackgroundColor = {
|
|
12596
12666
|
primary: PEACOCK_BLUE$1,
|
|
@@ -12603,8 +12673,10 @@ var activeBackgroundColor = {
|
|
|
12603
12673
|
tertiary: TRANSPARENT$1,
|
|
12604
12674
|
danger: "#870000",
|
|
12605
12675
|
dangerSecondary: "#FAE7EE",
|
|
12676
|
+
whitePrimary: TRANSPARENT$1,
|
|
12606
12677
|
whiteSecondary: TRANSPARENT$1,
|
|
12607
|
-
|
|
12678
|
+
greenPrimary: adjustHexColor(SEA_GREEN$1, 20, "darken"),
|
|
12679
|
+
greenSecondary: adjustHexColor(HINT_GREEN$1, 5, "darken")
|
|
12608
12680
|
};
|
|
12609
12681
|
var activeBorderColor = {
|
|
12610
12682
|
primary: PEACOCK_BLUE$1,
|
|
@@ -12617,8 +12689,10 @@ var activeBorderColor = {
|
|
|
12617
12689
|
tertiary: TRANSPARENT$1,
|
|
12618
12690
|
danger: "#870000",
|
|
12619
12691
|
dangerSecondary: "#910029",
|
|
12692
|
+
whitePrimary: "2px solid " + TRANSPARENT$1,
|
|
12620
12693
|
whiteSecondary: "2px solid " + TRANSPARENT$1,
|
|
12621
|
-
|
|
12694
|
+
greenPrimary: SEA_GREEN$1,
|
|
12695
|
+
greenSecondary: SEA_GREEN$1
|
|
12622
12696
|
};
|
|
12623
12697
|
var activeColor = {
|
|
12624
12698
|
primary: WHITE$1,
|
|
@@ -12631,8 +12705,10 @@ var activeColor = {
|
|
|
12631
12705
|
tertiary: PEACOCK_BLUE$1,
|
|
12632
12706
|
danger: WHITE$1,
|
|
12633
12707
|
dangerSecondary: "#910029",
|
|
12708
|
+
whitePrimary: WHITE$1,
|
|
12634
12709
|
whiteSecondary: WHITE$1,
|
|
12635
|
-
|
|
12710
|
+
greenPrimary: WHITE$1,
|
|
12711
|
+
greenSecondary: SEA_GREEN$1
|
|
12636
12712
|
};
|
|
12637
12713
|
var fallbackValues$1 = {
|
|
12638
12714
|
padding: padding,
|
|
@@ -19345,7 +19421,9 @@ var ArrowDownCircleIconSmall = function ArrowDownCircleIconSmall(_ref) {
|
|
|
19345
19421
|
|
|
19346
19422
|
var SuccessfulIconMedium = function SuccessfulIconMedium(_ref) {
|
|
19347
19423
|
var _ref$iconIndex = _ref.iconIndex,
|
|
19348
|
-
iconIndex = _ref$iconIndex === void 0 ? 0 : _ref$iconIndex
|
|
19424
|
+
iconIndex = _ref$iconIndex === void 0 ? 0 : _ref$iconIndex,
|
|
19425
|
+
_ref$fill = _ref.fill,
|
|
19426
|
+
fill = _ref$fill === void 0 ? SEA_GREEN : _ref$fill;
|
|
19349
19427
|
var mask0ID = "SuccessfulIconMedium-mask0-".concat(iconIndex);
|
|
19350
19428
|
var mask1ID = "SuccessfulIconMedium-mask1-".concat(iconIndex);
|
|
19351
19429
|
return /*#__PURE__*/React__default.createElement("svg", {
|
|
@@ -19358,7 +19436,7 @@ var SuccessfulIconMedium = function SuccessfulIconMedium(_ref) {
|
|
|
19358
19436
|
cx: "12",
|
|
19359
19437
|
cy: "12",
|
|
19360
19438
|
r: "12",
|
|
19361
|
-
fill:
|
|
19439
|
+
fill: fill
|
|
19362
19440
|
}), /*#__PURE__*/React__default.createElement("mask", {
|
|
19363
19441
|
id: mask0ID,
|
|
19364
19442
|
style: {
|
|
@@ -21083,7 +21161,6 @@ function _wrapNativeSuper(Class) {
|
|
|
21083
21161
|
}
|
|
21084
21162
|
|
|
21085
21163
|
// based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
|
|
21086
|
-
|
|
21087
21164
|
/**
|
|
21088
21165
|
* Parse errors.md and turn it into a simple hash of code: message
|
|
21089
21166
|
* @private
|
|
@@ -21168,84 +21245,71 @@ var ERRORS = {
|
|
|
21168
21245
|
"77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
|
|
21169
21246
|
"78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
|
|
21170
21247
|
};
|
|
21248
|
+
|
|
21171
21249
|
/**
|
|
21172
21250
|
* super basic version of sprintf
|
|
21173
21251
|
* @private
|
|
21174
21252
|
*/
|
|
21175
|
-
|
|
21176
21253
|
function format() {
|
|
21177
21254
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21178
21255
|
args[_key] = arguments[_key];
|
|
21179
21256
|
}
|
|
21180
|
-
|
|
21181
21257
|
var a = args[0];
|
|
21182
21258
|
var b = [];
|
|
21183
21259
|
var c;
|
|
21184
|
-
|
|
21185
21260
|
for (c = 1; c < args.length; c += 1) {
|
|
21186
21261
|
b.push(args[c]);
|
|
21187
21262
|
}
|
|
21188
|
-
|
|
21189
21263
|
b.forEach(function (d) {
|
|
21190
21264
|
a = a.replace(/%[a-z]/, d);
|
|
21191
21265
|
});
|
|
21192
21266
|
return a;
|
|
21193
21267
|
}
|
|
21268
|
+
|
|
21194
21269
|
/**
|
|
21195
21270
|
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
21196
21271
|
* in production mode.
|
|
21197
21272
|
* @private
|
|
21198
21273
|
*/
|
|
21199
|
-
|
|
21200
|
-
|
|
21201
21274
|
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
21202
21275
|
_inheritsLoose(PolishedError, _Error);
|
|
21203
|
-
|
|
21204
21276
|
function PolishedError(code) {
|
|
21205
21277
|
var _this;
|
|
21206
|
-
|
|
21207
21278
|
if (process.env.NODE_ENV === 'production') {
|
|
21208
21279
|
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
21209
21280
|
} else {
|
|
21210
21281
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
21211
21282
|
args[_key2 - 1] = arguments[_key2];
|
|
21212
21283
|
}
|
|
21213
|
-
|
|
21214
21284
|
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
21215
21285
|
}
|
|
21216
|
-
|
|
21217
21286
|
return _assertThisInitialized(_this);
|
|
21218
21287
|
}
|
|
21219
|
-
|
|
21220
21288
|
return PolishedError;
|
|
21221
21289
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
21222
21290
|
|
|
21223
21291
|
function colorToInt(color) {
|
|
21224
21292
|
return Math.round(color * 255);
|
|
21225
21293
|
}
|
|
21226
|
-
|
|
21227
21294
|
function convertToInt(red, green, blue) {
|
|
21228
21295
|
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
21229
21296
|
}
|
|
21230
|
-
|
|
21231
21297
|
function hslToRgb(hue, saturation, lightness, convert) {
|
|
21232
21298
|
if (convert === void 0) {
|
|
21233
21299
|
convert = convertToInt;
|
|
21234
21300
|
}
|
|
21235
|
-
|
|
21236
21301
|
if (saturation === 0) {
|
|
21237
21302
|
// achromatic
|
|
21238
21303
|
return convert(lightness, lightness, lightness);
|
|
21239
|
-
}
|
|
21240
|
-
|
|
21304
|
+
}
|
|
21241
21305
|
|
|
21306
|
+
// formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
21242
21307
|
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
21243
21308
|
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
21244
21309
|
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
21245
21310
|
var red = 0;
|
|
21246
21311
|
var green = 0;
|
|
21247
21312
|
var blue = 0;
|
|
21248
|
-
|
|
21249
21313
|
if (huePrime >= 0 && huePrime < 1) {
|
|
21250
21314
|
red = chroma;
|
|
21251
21315
|
green = secondComponent;
|
|
@@ -21265,7 +21329,6 @@ function hslToRgb(hue, saturation, lightness, convert) {
|
|
|
21265
21329
|
red = chroma;
|
|
21266
21330
|
blue = secondComponent;
|
|
21267
21331
|
}
|
|
21268
|
-
|
|
21269
21332
|
var lightnessModification = lightness - chroma / 2;
|
|
21270
21333
|
var finalRed = red + lightnessModification;
|
|
21271
21334
|
var finalGreen = green + lightnessModification;
|
|
@@ -21423,11 +21486,11 @@ var namedColorMap = {
|
|
|
21423
21486
|
yellow: 'ff0',
|
|
21424
21487
|
yellowgreen: '9acd32'
|
|
21425
21488
|
};
|
|
21489
|
+
|
|
21426
21490
|
/**
|
|
21427
21491
|
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
21428
21492
|
* @private
|
|
21429
21493
|
*/
|
|
21430
|
-
|
|
21431
21494
|
function nameToHex(color) {
|
|
21432
21495
|
if (typeof color !== 'string') return color;
|
|
21433
21496
|
var normalizedColorName = color.toLowerCase();
|
|
@@ -21442,6 +21505,7 @@ var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\
|
|
|
21442
21505
|
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
21443
21506
|
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
21444
21507
|
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
21508
|
+
|
|
21445
21509
|
/**
|
|
21446
21510
|
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
21447
21511
|
* if want to extract a color component. With the color util `toColorString` you
|
|
@@ -21453,14 +21517,11 @@ var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[
|
|
|
21453
21517
|
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
21454
21518
|
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
21455
21519
|
*/
|
|
21456
|
-
|
|
21457
21520
|
function parseToRgb(color) {
|
|
21458
21521
|
if (typeof color !== 'string') {
|
|
21459
21522
|
throw new PolishedError(3);
|
|
21460
21523
|
}
|
|
21461
|
-
|
|
21462
21524
|
var normalizedColor = nameToHex(color);
|
|
21463
|
-
|
|
21464
21525
|
if (normalizedColor.match(hexRegex)) {
|
|
21465
21526
|
return {
|
|
21466
21527
|
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
@@ -21468,7 +21529,6 @@ function parseToRgb(color) {
|
|
|
21468
21529
|
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
21469
21530
|
};
|
|
21470
21531
|
}
|
|
21471
|
-
|
|
21472
21532
|
if (normalizedColor.match(hexRgbaRegex)) {
|
|
21473
21533
|
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
21474
21534
|
return {
|
|
@@ -21478,7 +21538,6 @@ function parseToRgb(color) {
|
|
|
21478
21538
|
alpha: alpha
|
|
21479
21539
|
};
|
|
21480
21540
|
}
|
|
21481
|
-
|
|
21482
21541
|
if (normalizedColor.match(reducedHexRegex)) {
|
|
21483
21542
|
return {
|
|
21484
21543
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
@@ -21486,10 +21545,8 @@ function parseToRgb(color) {
|
|
|
21486
21545
|
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
21487
21546
|
};
|
|
21488
21547
|
}
|
|
21489
|
-
|
|
21490
21548
|
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
21491
21549
|
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
21492
|
-
|
|
21493
21550
|
return {
|
|
21494
21551
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
21495
21552
|
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
@@ -21497,9 +21554,7 @@ function parseToRgb(color) {
|
|
|
21497
21554
|
alpha: _alpha
|
|
21498
21555
|
};
|
|
21499
21556
|
}
|
|
21500
|
-
|
|
21501
21557
|
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
21502
|
-
|
|
21503
21558
|
if (rgbMatched) {
|
|
21504
21559
|
return {
|
|
21505
21560
|
red: parseInt("" + rgbMatched[1], 10),
|
|
@@ -21507,9 +21562,7 @@ function parseToRgb(color) {
|
|
|
21507
21562
|
blue: parseInt("" + rgbMatched[3], 10)
|
|
21508
21563
|
};
|
|
21509
21564
|
}
|
|
21510
|
-
|
|
21511
21565
|
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
21512
|
-
|
|
21513
21566
|
if (rgbaMatched) {
|
|
21514
21567
|
return {
|
|
21515
21568
|
red: parseInt("" + rgbaMatched[1], 10),
|
|
@@ -21518,44 +21571,32 @@ function parseToRgb(color) {
|
|
|
21518
21571
|
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
21519
21572
|
};
|
|
21520
21573
|
}
|
|
21521
|
-
|
|
21522
21574
|
var hslMatched = hslRegex.exec(normalizedColor);
|
|
21523
|
-
|
|
21524
21575
|
if (hslMatched) {
|
|
21525
21576
|
var hue = parseInt("" + hslMatched[1], 10);
|
|
21526
21577
|
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
21527
21578
|
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
21528
21579
|
var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
|
21529
21580
|
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
21530
|
-
|
|
21531
21581
|
if (!hslRgbMatched) {
|
|
21532
21582
|
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
21533
21583
|
}
|
|
21534
|
-
|
|
21535
21584
|
return {
|
|
21536
21585
|
red: parseInt("" + hslRgbMatched[1], 10),
|
|
21537
21586
|
green: parseInt("" + hslRgbMatched[2], 10),
|
|
21538
21587
|
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
21539
21588
|
};
|
|
21540
21589
|
}
|
|
21541
|
-
|
|
21542
21590
|
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
21543
|
-
|
|
21544
21591
|
if (hslaMatched) {
|
|
21545
21592
|
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
21546
|
-
|
|
21547
21593
|
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
21548
|
-
|
|
21549
21594
|
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
21550
|
-
|
|
21551
21595
|
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
21552
|
-
|
|
21553
21596
|
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
21554
|
-
|
|
21555
21597
|
if (!_hslRgbMatched) {
|
|
21556
21598
|
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
21557
21599
|
}
|
|
21558
|
-
|
|
21559
21600
|
return {
|
|
21560
21601
|
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
21561
21602
|
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
@@ -21563,10 +21604,82 @@ function parseToRgb(color) {
|
|
|
21563
21604
|
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
21564
21605
|
};
|
|
21565
21606
|
}
|
|
21566
|
-
|
|
21567
21607
|
throw new PolishedError(5);
|
|
21568
21608
|
}
|
|
21569
21609
|
|
|
21610
|
+
function rgbToHsl(color) {
|
|
21611
|
+
// make sure rgb are contained in a set of [0, 255]
|
|
21612
|
+
var red = color.red / 255;
|
|
21613
|
+
var green = color.green / 255;
|
|
21614
|
+
var blue = color.blue / 255;
|
|
21615
|
+
var max = Math.max(red, green, blue);
|
|
21616
|
+
var min = Math.min(red, green, blue);
|
|
21617
|
+
var lightness = (max + min) / 2;
|
|
21618
|
+
if (max === min) {
|
|
21619
|
+
// achromatic
|
|
21620
|
+
if (color.alpha !== undefined) {
|
|
21621
|
+
return {
|
|
21622
|
+
hue: 0,
|
|
21623
|
+
saturation: 0,
|
|
21624
|
+
lightness: lightness,
|
|
21625
|
+
alpha: color.alpha
|
|
21626
|
+
};
|
|
21627
|
+
} else {
|
|
21628
|
+
return {
|
|
21629
|
+
hue: 0,
|
|
21630
|
+
saturation: 0,
|
|
21631
|
+
lightness: lightness
|
|
21632
|
+
};
|
|
21633
|
+
}
|
|
21634
|
+
}
|
|
21635
|
+
var hue;
|
|
21636
|
+
var delta = max - min;
|
|
21637
|
+
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
21638
|
+
switch (max) {
|
|
21639
|
+
case red:
|
|
21640
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
21641
|
+
break;
|
|
21642
|
+
case green:
|
|
21643
|
+
hue = (blue - red) / delta + 2;
|
|
21644
|
+
break;
|
|
21645
|
+
default:
|
|
21646
|
+
// blue case
|
|
21647
|
+
hue = (red - green) / delta + 4;
|
|
21648
|
+
break;
|
|
21649
|
+
}
|
|
21650
|
+
hue *= 60;
|
|
21651
|
+
if (color.alpha !== undefined) {
|
|
21652
|
+
return {
|
|
21653
|
+
hue: hue,
|
|
21654
|
+
saturation: saturation,
|
|
21655
|
+
lightness: lightness,
|
|
21656
|
+
alpha: color.alpha
|
|
21657
|
+
};
|
|
21658
|
+
}
|
|
21659
|
+
return {
|
|
21660
|
+
hue: hue,
|
|
21661
|
+
saturation: saturation,
|
|
21662
|
+
lightness: lightness
|
|
21663
|
+
};
|
|
21664
|
+
}
|
|
21665
|
+
|
|
21666
|
+
/**
|
|
21667
|
+
* Returns an HslColor or HslaColor object. This utility function is only useful
|
|
21668
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
21669
|
+
* can convert a HslColor or HslaColor object back to a string.
|
|
21670
|
+
*
|
|
21671
|
+
* @example
|
|
21672
|
+
* // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
|
|
21673
|
+
* const color1 = parseToHsl('rgb(255, 0, 0)');
|
|
21674
|
+
* // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
|
|
21675
|
+
* const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
|
|
21676
|
+
*/
|
|
21677
|
+
function parseToHsl(color) {
|
|
21678
|
+
// Note: At a later stage we can optimize this function as right now a hsl
|
|
21679
|
+
// color would be parsed converted to rgb values and converted back to hsl.
|
|
21680
|
+
return rgbToHsl(parseToRgb(color));
|
|
21681
|
+
}
|
|
21682
|
+
|
|
21570
21683
|
/**
|
|
21571
21684
|
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
21572
21685
|
* @private
|
|
@@ -21575,10 +21688,8 @@ var reduceHexValue = function reduceHexValue(value) {
|
|
|
21575
21688
|
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
21576
21689
|
return "#" + value[1] + value[3] + value[5];
|
|
21577
21690
|
}
|
|
21578
|
-
|
|
21579
21691
|
return value;
|
|
21580
21692
|
};
|
|
21581
|
-
|
|
21582
21693
|
var reduceHexValue$1 = reduceHexValue;
|
|
21583
21694
|
|
|
21584
21695
|
function numberToHex(value) {
|
|
@@ -21586,6 +21697,83 @@ function numberToHex(value) {
|
|
|
21586
21697
|
return hex.length === 1 ? "0" + hex : hex;
|
|
21587
21698
|
}
|
|
21588
21699
|
|
|
21700
|
+
function colorToHex(color) {
|
|
21701
|
+
return numberToHex(Math.round(color * 255));
|
|
21702
|
+
}
|
|
21703
|
+
function convertToHex(red, green, blue) {
|
|
21704
|
+
return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
21705
|
+
}
|
|
21706
|
+
function hslToHex(hue, saturation, lightness) {
|
|
21707
|
+
return hslToRgb(hue, saturation, lightness, convertToHex);
|
|
21708
|
+
}
|
|
21709
|
+
|
|
21710
|
+
/**
|
|
21711
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
21712
|
+
*
|
|
21713
|
+
* @example
|
|
21714
|
+
* // Styles as object usage
|
|
21715
|
+
* const styles = {
|
|
21716
|
+
* background: hsl(359, 0.75, 0.4),
|
|
21717
|
+
* background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
|
|
21718
|
+
* }
|
|
21719
|
+
*
|
|
21720
|
+
* // styled-components usage
|
|
21721
|
+
* const div = styled.div`
|
|
21722
|
+
* background: ${hsl(359, 0.75, 0.4)};
|
|
21723
|
+
* background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
|
|
21724
|
+
* `
|
|
21725
|
+
*
|
|
21726
|
+
* // CSS in JS Output
|
|
21727
|
+
*
|
|
21728
|
+
* element {
|
|
21729
|
+
* background: "#b3191c";
|
|
21730
|
+
* background: "#b3191c";
|
|
21731
|
+
* }
|
|
21732
|
+
*/
|
|
21733
|
+
function hsl(value, saturation, lightness) {
|
|
21734
|
+
if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
|
|
21735
|
+
return hslToHex(value, saturation, lightness);
|
|
21736
|
+
} else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
|
|
21737
|
+
return hslToHex(value.hue, value.saturation, value.lightness);
|
|
21738
|
+
}
|
|
21739
|
+
throw new PolishedError(1);
|
|
21740
|
+
}
|
|
21741
|
+
|
|
21742
|
+
/**
|
|
21743
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
21744
|
+
*
|
|
21745
|
+
* @example
|
|
21746
|
+
* // Styles as object usage
|
|
21747
|
+
* const styles = {
|
|
21748
|
+
* background: hsla(359, 0.75, 0.4, 0.7),
|
|
21749
|
+
* background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
|
|
21750
|
+
* background: hsla(359, 0.75, 0.4, 1),
|
|
21751
|
+
* }
|
|
21752
|
+
*
|
|
21753
|
+
* // styled-components usage
|
|
21754
|
+
* const div = styled.div`
|
|
21755
|
+
* background: ${hsla(359, 0.75, 0.4, 0.7)};
|
|
21756
|
+
* background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
|
|
21757
|
+
* background: ${hsla(359, 0.75, 0.4, 1)};
|
|
21758
|
+
* `
|
|
21759
|
+
*
|
|
21760
|
+
* // CSS in JS Output
|
|
21761
|
+
*
|
|
21762
|
+
* element {
|
|
21763
|
+
* background: "rgba(179,25,28,0.7)";
|
|
21764
|
+
* background: "rgba(179,25,28,0.7)";
|
|
21765
|
+
* background: "#b3191c";
|
|
21766
|
+
* }
|
|
21767
|
+
*/
|
|
21768
|
+
function hsla$1(value, saturation, lightness, alpha) {
|
|
21769
|
+
if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
|
|
21770
|
+
return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
|
|
21771
|
+
} else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
|
21772
|
+
return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
21773
|
+
}
|
|
21774
|
+
throw new PolishedError(2);
|
|
21775
|
+
}
|
|
21776
|
+
|
|
21589
21777
|
/**
|
|
21590
21778
|
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
21591
21779
|
*
|
|
@@ -21615,7 +21803,6 @@ function rgb(value, green, blue) {
|
|
|
21615
21803
|
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
21616
21804
|
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
21617
21805
|
}
|
|
21618
|
-
|
|
21619
21806
|
throw new PolishedError(6);
|
|
21620
21807
|
}
|
|
21621
21808
|
|
|
@@ -21662,10 +21849,62 @@ function rgba$1(firstValue, secondValue, thirdValue, fourthValue) {
|
|
|
21662
21849
|
} else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
21663
21850
|
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
21664
21851
|
}
|
|
21665
|
-
|
|
21666
21852
|
throw new PolishedError(7);
|
|
21667
21853
|
}
|
|
21668
21854
|
|
|
21855
|
+
var isRgb = function isRgb(color) {
|
|
21856
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
21857
|
+
};
|
|
21858
|
+
var isRgba$1 = function isRgba(color) {
|
|
21859
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
|
21860
|
+
};
|
|
21861
|
+
var isHsl = function isHsl(color) {
|
|
21862
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
21863
|
+
};
|
|
21864
|
+
var isHsla$1 = function isHsla(color) {
|
|
21865
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
|
21866
|
+
};
|
|
21867
|
+
|
|
21868
|
+
/**
|
|
21869
|
+
* Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
|
|
21870
|
+
* This util is useful in case you only know on runtime which color object is
|
|
21871
|
+
* used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
|
|
21872
|
+
*
|
|
21873
|
+
* @example
|
|
21874
|
+
* // Styles as object usage
|
|
21875
|
+
* const styles = {
|
|
21876
|
+
* background: toColorString({ red: 255, green: 205, blue: 100 }),
|
|
21877
|
+
* background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
|
|
21878
|
+
* background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
|
|
21879
|
+
* background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
|
|
21880
|
+
* }
|
|
21881
|
+
*
|
|
21882
|
+
* // styled-components usage
|
|
21883
|
+
* const div = styled.div`
|
|
21884
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100 })};
|
|
21885
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
|
|
21886
|
+
* background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
|
|
21887
|
+
* background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
|
|
21888
|
+
* `
|
|
21889
|
+
*
|
|
21890
|
+
* // CSS in JS Output
|
|
21891
|
+
* element {
|
|
21892
|
+
* background: "#ffcd64";
|
|
21893
|
+
* background: "rgba(255,205,100,0.72)";
|
|
21894
|
+
* background: "#00f";
|
|
21895
|
+
* background: "rgba(179,25,25,0.72)";
|
|
21896
|
+
* }
|
|
21897
|
+
*/
|
|
21898
|
+
|
|
21899
|
+
function toColorString(color) {
|
|
21900
|
+
if (typeof color !== 'object') throw new PolishedError(8);
|
|
21901
|
+
if (isRgba$1(color)) return rgba$1(color);
|
|
21902
|
+
if (isRgb(color)) return rgb(color);
|
|
21903
|
+
if (isHsla$1(color)) return hsla$1(color);
|
|
21904
|
+
if (isHsl(color)) return hsl(color);
|
|
21905
|
+
throw new PolishedError(8);
|
|
21906
|
+
}
|
|
21907
|
+
|
|
21669
21908
|
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
21670
21909
|
// eslint-disable-next-line no-unused-vars
|
|
21671
21910
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -21676,14 +21915,156 @@ function curried(f, length, acc) {
|
|
|
21676
21915
|
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
21677
21916
|
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
21678
21917
|
};
|
|
21679
|
-
}
|
|
21680
|
-
|
|
21918
|
+
}
|
|
21681
21919
|
|
|
21920
|
+
// eslint-disable-next-line no-redeclare
|
|
21682
21921
|
function curry(f) {
|
|
21683
21922
|
// eslint-disable-line no-redeclare
|
|
21684
21923
|
return curried(f, f.length, []);
|
|
21685
21924
|
}
|
|
21686
21925
|
|
|
21926
|
+
/**
|
|
21927
|
+
* Changes the hue of the color. Hue is a number between 0 to 360. The first
|
|
21928
|
+
* argument for adjustHue is the amount of degrees the color is rotated around
|
|
21929
|
+
* the color wheel, always producing a positive hue value.
|
|
21930
|
+
*
|
|
21931
|
+
* @example
|
|
21932
|
+
* // Styles as object usage
|
|
21933
|
+
* const styles = {
|
|
21934
|
+
* background: adjustHue(180, '#448'),
|
|
21935
|
+
* background: adjustHue('180', 'rgba(101,100,205,0.7)'),
|
|
21936
|
+
* }
|
|
21937
|
+
*
|
|
21938
|
+
* // styled-components usage
|
|
21939
|
+
* const div = styled.div`
|
|
21940
|
+
* background: ${adjustHue(180, '#448')};
|
|
21941
|
+
* background: ${adjustHue('180', 'rgba(101,100,205,0.7)')};
|
|
21942
|
+
* `
|
|
21943
|
+
*
|
|
21944
|
+
* // CSS in JS Output
|
|
21945
|
+
* element {
|
|
21946
|
+
* background: "#888844";
|
|
21947
|
+
* background: "rgba(136,136,68,0.7)";
|
|
21948
|
+
* }
|
|
21949
|
+
*/
|
|
21950
|
+
function adjustHue(degree, color) {
|
|
21951
|
+
if (color === 'transparent') return color;
|
|
21952
|
+
var hslColor = parseToHsl(color);
|
|
21953
|
+
return toColorString(_extends$1({}, hslColor, {
|
|
21954
|
+
hue: hslColor.hue + parseFloat(degree)
|
|
21955
|
+
}));
|
|
21956
|
+
}
|
|
21957
|
+
|
|
21958
|
+
// prettier-ignore
|
|
21959
|
+
var curriedAdjustHue = curry /* ::<number | string, string, string> */(adjustHue);
|
|
21960
|
+
|
|
21961
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
21962
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
21963
|
+
}
|
|
21964
|
+
|
|
21965
|
+
/**
|
|
21966
|
+
* Returns a string value for the darkened color.
|
|
21967
|
+
*
|
|
21968
|
+
* @example
|
|
21969
|
+
* // Styles as object usage
|
|
21970
|
+
* const styles = {
|
|
21971
|
+
* background: darken(0.2, '#FFCD64'),
|
|
21972
|
+
* background: darken('0.2', 'rgba(255,205,100,0.7)'),
|
|
21973
|
+
* }
|
|
21974
|
+
*
|
|
21975
|
+
* // styled-components usage
|
|
21976
|
+
* const div = styled.div`
|
|
21977
|
+
* background: ${darken(0.2, '#FFCD64')};
|
|
21978
|
+
* background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
|
|
21979
|
+
* `
|
|
21980
|
+
*
|
|
21981
|
+
* // CSS in JS Output
|
|
21982
|
+
*
|
|
21983
|
+
* element {
|
|
21984
|
+
* background: "#ffbd31";
|
|
21985
|
+
* background: "rgba(255,189,49,0.7)";
|
|
21986
|
+
* }
|
|
21987
|
+
*/
|
|
21988
|
+
function darken(amount, color) {
|
|
21989
|
+
if (color === 'transparent') return color;
|
|
21990
|
+
var hslColor = parseToHsl(color);
|
|
21991
|
+
return toColorString(_extends$1({}, hslColor, {
|
|
21992
|
+
lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
|
21993
|
+
}));
|
|
21994
|
+
}
|
|
21995
|
+
|
|
21996
|
+
// prettier-ignore
|
|
21997
|
+
var curriedDarken = curry /* ::<number | string, string, string> */(darken);
|
|
21998
|
+
|
|
21999
|
+
/**
|
|
22000
|
+
* Decreases the intensity of a color. Its range is between 0 to 1. The first
|
|
22001
|
+
* argument of the desaturate function is the amount by how much the color
|
|
22002
|
+
* intensity should be decreased.
|
|
22003
|
+
*
|
|
22004
|
+
* @example
|
|
22005
|
+
* // Styles as object usage
|
|
22006
|
+
* const styles = {
|
|
22007
|
+
* background: desaturate(0.2, '#CCCD64'),
|
|
22008
|
+
* background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
22009
|
+
* }
|
|
22010
|
+
*
|
|
22011
|
+
* // styled-components usage
|
|
22012
|
+
* const div = styled.div`
|
|
22013
|
+
* background: ${desaturate(0.2, '#CCCD64')};
|
|
22014
|
+
* background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
22015
|
+
* `
|
|
22016
|
+
*
|
|
22017
|
+
* // CSS in JS Output
|
|
22018
|
+
* element {
|
|
22019
|
+
* background: "#b8b979";
|
|
22020
|
+
* background: "rgba(184,185,121,0.7)";
|
|
22021
|
+
* }
|
|
22022
|
+
*/
|
|
22023
|
+
function desaturate(amount, color) {
|
|
22024
|
+
if (color === 'transparent') return color;
|
|
22025
|
+
var hslColor = parseToHsl(color);
|
|
22026
|
+
return toColorString(_extends$1({}, hslColor, {
|
|
22027
|
+
saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
|
22028
|
+
}));
|
|
22029
|
+
}
|
|
22030
|
+
|
|
22031
|
+
// prettier-ignore
|
|
22032
|
+
var curriedDesaturate = curry /* ::<number | string, string, string> */(desaturate);
|
|
22033
|
+
|
|
22034
|
+
/**
|
|
22035
|
+
* Returns a string value for the lightened color.
|
|
22036
|
+
*
|
|
22037
|
+
* @example
|
|
22038
|
+
* // Styles as object usage
|
|
22039
|
+
* const styles = {
|
|
22040
|
+
* background: lighten(0.2, '#CCCD64'),
|
|
22041
|
+
* background: lighten('0.2', 'rgba(204,205,100,0.7)'),
|
|
22042
|
+
* }
|
|
22043
|
+
*
|
|
22044
|
+
* // styled-components usage
|
|
22045
|
+
* const div = styled.div`
|
|
22046
|
+
* background: ${lighten(0.2, '#FFCD64')};
|
|
22047
|
+
* background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
|
|
22048
|
+
* `
|
|
22049
|
+
*
|
|
22050
|
+
* // CSS in JS Output
|
|
22051
|
+
*
|
|
22052
|
+
* element {
|
|
22053
|
+
* background: "#e5e6b1";
|
|
22054
|
+
* background: "rgba(229,230,177,0.7)";
|
|
22055
|
+
* }
|
|
22056
|
+
*/
|
|
22057
|
+
function lighten(amount, color) {
|
|
22058
|
+
if (color === 'transparent') return color;
|
|
22059
|
+
var hslColor = parseToHsl(color);
|
|
22060
|
+
return toColorString(_extends$1({}, hslColor, {
|
|
22061
|
+
lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
|
22062
|
+
}));
|
|
22063
|
+
}
|
|
22064
|
+
|
|
22065
|
+
// prettier-ignore
|
|
22066
|
+
var curriedLighten = curry /* ::<number | string, string, string> */(lighten);
|
|
22067
|
+
|
|
21687
22068
|
/**
|
|
21688
22069
|
* Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
|
|
21689
22070
|
*
|
|
@@ -21710,25 +22091,21 @@ function curry(f) {
|
|
|
21710
22091
|
* background: "rgba(63, 0, 191, 0.75)";
|
|
21711
22092
|
* }
|
|
21712
22093
|
*/
|
|
21713
|
-
|
|
21714
22094
|
function mix$1(weight, color, otherColor) {
|
|
21715
22095
|
if (color === 'transparent') return otherColor;
|
|
21716
22096
|
if (otherColor === 'transparent') return color;
|
|
21717
22097
|
if (weight === 0) return otherColor;
|
|
21718
22098
|
var parsedColor1 = parseToRgb(color);
|
|
21719
|
-
|
|
21720
22099
|
var color1 = _extends$1({}, parsedColor1, {
|
|
21721
22100
|
alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
|
|
21722
22101
|
});
|
|
21723
|
-
|
|
21724
22102
|
var parsedColor2 = parseToRgb(otherColor);
|
|
21725
|
-
|
|
21726
22103
|
var color2 = _extends$1({}, parsedColor2, {
|
|
21727
22104
|
alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
|
|
21728
|
-
});
|
|
21729
|
-
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
21730
|
-
|
|
22105
|
+
});
|
|
21731
22106
|
|
|
22107
|
+
// The formula is copied from the original Sass implementation:
|
|
22108
|
+
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
21732
22109
|
var alphaDelta = color1.alpha - color2.alpha;
|
|
21733
22110
|
var x = parseFloat(weight) * 2 - 1;
|
|
21734
22111
|
var y = x * alphaDelta === -1 ? x : x + alphaDelta;
|
|
@@ -21742,14 +22119,218 @@ function mix$1(weight, color, otherColor) {
|
|
|
21742
22119
|
alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
|
|
21743
22120
|
};
|
|
21744
22121
|
return rgba$1(mixedColor);
|
|
21745
|
-
}
|
|
21746
|
-
|
|
22122
|
+
}
|
|
21747
22123
|
|
|
21748
|
-
|
|
21749
|
-
/* ::<number | string, string, string, string> */
|
|
21750
|
-
(mix$1);
|
|
22124
|
+
// prettier-ignore
|
|
22125
|
+
var curriedMix = curry /* ::<number | string, string, string, string> */(mix$1);
|
|
21751
22126
|
var mix$1$1 = curriedMix;
|
|
21752
22127
|
|
|
22128
|
+
/**
|
|
22129
|
+
* Increases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
22130
|
+
*
|
|
22131
|
+
*
|
|
22132
|
+
* @example
|
|
22133
|
+
* // Styles as object usage
|
|
22134
|
+
* const styles = {
|
|
22135
|
+
* background: opacify(0.1, 'rgba(255, 255, 255, 0.9)');
|
|
22136
|
+
* background: opacify(0.2, 'hsla(0, 0%, 100%, 0.5)'),
|
|
22137
|
+
* background: opacify('0.5', 'rgba(255, 0, 0, 0.2)'),
|
|
22138
|
+
* }
|
|
22139
|
+
*
|
|
22140
|
+
* // styled-components usage
|
|
22141
|
+
* const div = styled.div`
|
|
22142
|
+
* background: ${opacify(0.1, 'rgba(255, 255, 255, 0.9)')};
|
|
22143
|
+
* background: ${opacify(0.2, 'hsla(0, 0%, 100%, 0.5)')},
|
|
22144
|
+
* background: ${opacify('0.5', 'rgba(255, 0, 0, 0.2)')},
|
|
22145
|
+
* `
|
|
22146
|
+
*
|
|
22147
|
+
* // CSS in JS Output
|
|
22148
|
+
*
|
|
22149
|
+
* element {
|
|
22150
|
+
* background: "#fff";
|
|
22151
|
+
* background: "rgba(255,255,255,0.7)";
|
|
22152
|
+
* background: "rgba(255,0,0,0.7)";
|
|
22153
|
+
* }
|
|
22154
|
+
*/
|
|
22155
|
+
function opacify(amount, color) {
|
|
22156
|
+
if (color === 'transparent') return color;
|
|
22157
|
+
var parsedColor = parseToRgb(color);
|
|
22158
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
22159
|
+
var colorWithAlpha = _extends$1({}, parsedColor, {
|
|
22160
|
+
alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
|
22161
|
+
});
|
|
22162
|
+
return rgba$1(colorWithAlpha);
|
|
22163
|
+
}
|
|
22164
|
+
|
|
22165
|
+
// prettier-ignore
|
|
22166
|
+
var curriedOpacify = curry /* ::<number | string, string, string> */(opacify);
|
|
22167
|
+
|
|
22168
|
+
/**
|
|
22169
|
+
* Increases the intensity of a color. Its range is between 0 to 1. The first
|
|
22170
|
+
* argument of the saturate function is the amount by how much the color
|
|
22171
|
+
* intensity should be increased.
|
|
22172
|
+
*
|
|
22173
|
+
* @example
|
|
22174
|
+
* // Styles as object usage
|
|
22175
|
+
* const styles = {
|
|
22176
|
+
* background: saturate(0.2, '#CCCD64'),
|
|
22177
|
+
* background: saturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
22178
|
+
* }
|
|
22179
|
+
*
|
|
22180
|
+
* // styled-components usage
|
|
22181
|
+
* const div = styled.div`
|
|
22182
|
+
* background: ${saturate(0.2, '#FFCD64')};
|
|
22183
|
+
* background: ${saturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
22184
|
+
* `
|
|
22185
|
+
*
|
|
22186
|
+
* // CSS in JS Output
|
|
22187
|
+
*
|
|
22188
|
+
* element {
|
|
22189
|
+
* background: "#e0e250";
|
|
22190
|
+
* background: "rgba(224,226,80,0.7)";
|
|
22191
|
+
* }
|
|
22192
|
+
*/
|
|
22193
|
+
function saturate(amount, color) {
|
|
22194
|
+
if (color === 'transparent') return color;
|
|
22195
|
+
var hslColor = parseToHsl(color);
|
|
22196
|
+
return toColorString(_extends$1({}, hslColor, {
|
|
22197
|
+
saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
|
22198
|
+
}));
|
|
22199
|
+
}
|
|
22200
|
+
|
|
22201
|
+
// prettier-ignore
|
|
22202
|
+
var curriedSaturate = curry /* ::<number | string, string, string> */(saturate);
|
|
22203
|
+
|
|
22204
|
+
/**
|
|
22205
|
+
* Sets the hue of a color to the provided value. The hue range can be
|
|
22206
|
+
* from 0 and 359.
|
|
22207
|
+
*
|
|
22208
|
+
* @example
|
|
22209
|
+
* // Styles as object usage
|
|
22210
|
+
* const styles = {
|
|
22211
|
+
* background: setHue(42, '#CCCD64'),
|
|
22212
|
+
* background: setHue('244', 'rgba(204,205,100,0.7)'),
|
|
22213
|
+
* }
|
|
22214
|
+
*
|
|
22215
|
+
* // styled-components usage
|
|
22216
|
+
* const div = styled.div`
|
|
22217
|
+
* background: ${setHue(42, '#CCCD64')};
|
|
22218
|
+
* background: ${setHue('244', 'rgba(204,205,100,0.7)')};
|
|
22219
|
+
* `
|
|
22220
|
+
*
|
|
22221
|
+
* // CSS in JS Output
|
|
22222
|
+
* element {
|
|
22223
|
+
* background: "#cdae64";
|
|
22224
|
+
* background: "rgba(107,100,205,0.7)";
|
|
22225
|
+
* }
|
|
22226
|
+
*/
|
|
22227
|
+
function setHue(hue, color) {
|
|
22228
|
+
if (color === 'transparent') return color;
|
|
22229
|
+
return toColorString(_extends$1({}, parseToHsl(color), {
|
|
22230
|
+
hue: parseFloat(hue)
|
|
22231
|
+
}));
|
|
22232
|
+
}
|
|
22233
|
+
|
|
22234
|
+
// prettier-ignore
|
|
22235
|
+
var curriedSetHue = curry /* ::<number | string, string, string> */(setHue);
|
|
22236
|
+
|
|
22237
|
+
/**
|
|
22238
|
+
* Sets the lightness of a color to the provided value. The lightness range can be
|
|
22239
|
+
* from 0 and 1.
|
|
22240
|
+
*
|
|
22241
|
+
* @example
|
|
22242
|
+
* // Styles as object usage
|
|
22243
|
+
* const styles = {
|
|
22244
|
+
* background: setLightness(0.2, '#CCCD64'),
|
|
22245
|
+
* background: setLightness('0.75', 'rgba(204,205,100,0.7)'),
|
|
22246
|
+
* }
|
|
22247
|
+
*
|
|
22248
|
+
* // styled-components usage
|
|
22249
|
+
* const div = styled.div`
|
|
22250
|
+
* background: ${setLightness(0.2, '#CCCD64')};
|
|
22251
|
+
* background: ${setLightness('0.75', 'rgba(204,205,100,0.7)')};
|
|
22252
|
+
* `
|
|
22253
|
+
*
|
|
22254
|
+
* // CSS in JS Output
|
|
22255
|
+
* element {
|
|
22256
|
+
* background: "#4d4d19";
|
|
22257
|
+
* background: "rgba(223,224,159,0.7)";
|
|
22258
|
+
* }
|
|
22259
|
+
*/
|
|
22260
|
+
function setLightness(lightness, color) {
|
|
22261
|
+
if (color === 'transparent') return color;
|
|
22262
|
+
return toColorString(_extends$1({}, parseToHsl(color), {
|
|
22263
|
+
lightness: parseFloat(lightness)
|
|
22264
|
+
}));
|
|
22265
|
+
}
|
|
22266
|
+
|
|
22267
|
+
// prettier-ignore
|
|
22268
|
+
var curriedSetLightness = curry /* ::<number | string, string, string> */(setLightness);
|
|
22269
|
+
|
|
22270
|
+
/**
|
|
22271
|
+
* Sets the saturation of a color to the provided value. The saturation range can be
|
|
22272
|
+
* from 0 and 1.
|
|
22273
|
+
*
|
|
22274
|
+
* @example
|
|
22275
|
+
* // Styles as object usage
|
|
22276
|
+
* const styles = {
|
|
22277
|
+
* background: setSaturation(0.2, '#CCCD64'),
|
|
22278
|
+
* background: setSaturation('0.75', 'rgba(204,205,100,0.7)'),
|
|
22279
|
+
* }
|
|
22280
|
+
*
|
|
22281
|
+
* // styled-components usage
|
|
22282
|
+
* const div = styled.div`
|
|
22283
|
+
* background: ${setSaturation(0.2, '#CCCD64')};
|
|
22284
|
+
* background: ${setSaturation('0.75', 'rgba(204,205,100,0.7)')};
|
|
22285
|
+
* `
|
|
22286
|
+
*
|
|
22287
|
+
* // CSS in JS Output
|
|
22288
|
+
* element {
|
|
22289
|
+
* background: "#adad84";
|
|
22290
|
+
* background: "rgba(228,229,76,0.7)";
|
|
22291
|
+
* }
|
|
22292
|
+
*/
|
|
22293
|
+
function setSaturation(saturation, color) {
|
|
22294
|
+
if (color === 'transparent') return color;
|
|
22295
|
+
return toColorString(_extends$1({}, parseToHsl(color), {
|
|
22296
|
+
saturation: parseFloat(saturation)
|
|
22297
|
+
}));
|
|
22298
|
+
}
|
|
22299
|
+
|
|
22300
|
+
// prettier-ignore
|
|
22301
|
+
var curriedSetSaturation = curry /* ::<number | string, string, string> */(setSaturation);
|
|
22302
|
+
|
|
22303
|
+
/**
|
|
22304
|
+
* Shades a color by mixing it with black. `shade` can produce
|
|
22305
|
+
* hue shifts, where as `darken` manipulates the luminance channel and therefore
|
|
22306
|
+
* doesn't produce hue shifts.
|
|
22307
|
+
*
|
|
22308
|
+
* @example
|
|
22309
|
+
* // Styles as object usage
|
|
22310
|
+
* const styles = {
|
|
22311
|
+
* background: shade(0.25, '#00f')
|
|
22312
|
+
* }
|
|
22313
|
+
*
|
|
22314
|
+
* // styled-components usage
|
|
22315
|
+
* const div = styled.div`
|
|
22316
|
+
* background: ${shade(0.25, '#00f')};
|
|
22317
|
+
* `
|
|
22318
|
+
*
|
|
22319
|
+
* // CSS in JS Output
|
|
22320
|
+
*
|
|
22321
|
+
* element {
|
|
22322
|
+
* background: "#00003f";
|
|
22323
|
+
* }
|
|
22324
|
+
*/
|
|
22325
|
+
|
|
22326
|
+
function shade(percentage, color) {
|
|
22327
|
+
if (color === 'transparent') return color;
|
|
22328
|
+
return mix$1$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
|
22329
|
+
}
|
|
22330
|
+
|
|
22331
|
+
// prettier-ignore
|
|
22332
|
+
var curriedShade = curry /* ::<number | string, string, string> */(shade);
|
|
22333
|
+
|
|
21753
22334
|
/**
|
|
21754
22335
|
* Tints a color by mixing it with white. `tint` can produce
|
|
21755
22336
|
* hue shifts, where as `lighten` manipulates the luminance channel and therefore
|
|
@@ -21776,14 +22357,52 @@ var mix$1$1 = curriedMix;
|
|
|
21776
22357
|
function tint(percentage, color) {
|
|
21777
22358
|
if (color === 'transparent') return color;
|
|
21778
22359
|
return mix$1$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
|
21779
|
-
}
|
|
21780
|
-
|
|
22360
|
+
}
|
|
21781
22361
|
|
|
21782
|
-
|
|
21783
|
-
/* ::<number | string, string, string> */
|
|
21784
|
-
(tint);
|
|
22362
|
+
// prettier-ignore
|
|
22363
|
+
var curriedTint = curry /* ::<number | string, string, string> */(tint);
|
|
21785
22364
|
var curriedTint$1 = curriedTint;
|
|
21786
22365
|
|
|
22366
|
+
/**
|
|
22367
|
+
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
22368
|
+
*
|
|
22369
|
+
*
|
|
22370
|
+
* @example
|
|
22371
|
+
* // Styles as object usage
|
|
22372
|
+
* const styles = {
|
|
22373
|
+
* background: transparentize(0.1, '#fff'),
|
|
22374
|
+
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
22375
|
+
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
22376
|
+
* }
|
|
22377
|
+
*
|
|
22378
|
+
* // styled-components usage
|
|
22379
|
+
* const div = styled.div`
|
|
22380
|
+
* background: ${transparentize(0.1, '#fff')};
|
|
22381
|
+
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')};
|
|
22382
|
+
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')};
|
|
22383
|
+
* `
|
|
22384
|
+
*
|
|
22385
|
+
* // CSS in JS Output
|
|
22386
|
+
*
|
|
22387
|
+
* element {
|
|
22388
|
+
* background: "rgba(255,255,255,0.9)";
|
|
22389
|
+
* background: "rgba(255,255,255,0.8)";
|
|
22390
|
+
* background: "rgba(255,0,0,0.3)";
|
|
22391
|
+
* }
|
|
22392
|
+
*/
|
|
22393
|
+
function transparentize(amount, color) {
|
|
22394
|
+
if (color === 'transparent') return color;
|
|
22395
|
+
var parsedColor = parseToRgb(color);
|
|
22396
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
22397
|
+
var colorWithAlpha = _extends$1({}, parsedColor, {
|
|
22398
|
+
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
22399
|
+
});
|
|
22400
|
+
return rgba$1(colorWithAlpha);
|
|
22401
|
+
}
|
|
22402
|
+
|
|
22403
|
+
// prettier-ignore
|
|
22404
|
+
var curriedTransparentize = curry /* ::<number | string, string, string> */(transparentize);
|
|
22405
|
+
|
|
21787
22406
|
var linkColor = MATISSE_BLUE;
|
|
21788
22407
|
var fallbackValues$8 = {
|
|
21789
22408
|
linkColor: linkColor
|
|
@@ -23102,32 +23721,19 @@ var toIndexedObject = function (it) {
|
|
|
23102
23721
|
return indexedObject(requireObjectCoercible(it));
|
|
23103
23722
|
};
|
|
23104
23723
|
|
|
23105
|
-
var documentAll = typeof document == 'object' && document.all;
|
|
23106
|
-
|
|
23107
23724
|
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
|
|
23108
|
-
|
|
23109
|
-
var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
|
|
23110
|
-
|
|
23111
|
-
var documentAll_1 = {
|
|
23112
|
-
all: documentAll,
|
|
23113
|
-
IS_HTMLDDA: IS_HTMLDDA
|
|
23114
|
-
};
|
|
23115
|
-
|
|
23116
|
-
var documentAll$1 = documentAll_1.all;
|
|
23725
|
+
var documentAll = typeof document == 'object' && document.all;
|
|
23117
23726
|
|
|
23118
23727
|
// `IsCallable` abstract operation
|
|
23119
23728
|
// https://tc39.es/ecma262/#sec-iscallable
|
|
23120
|
-
|
|
23121
|
-
|
|
23729
|
+
// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
|
|
23730
|
+
var isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
|
|
23731
|
+
return typeof argument == 'function' || argument === documentAll;
|
|
23122
23732
|
} : function (argument) {
|
|
23123
23733
|
return typeof argument == 'function';
|
|
23124
23734
|
};
|
|
23125
23735
|
|
|
23126
|
-
var
|
|
23127
|
-
|
|
23128
|
-
var isObject = documentAll_1.IS_HTMLDDA ? function (it) {
|
|
23129
|
-
return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll$2;
|
|
23130
|
-
} : function (it) {
|
|
23736
|
+
var isObject = function (it) {
|
|
23131
23737
|
return typeof it == 'object' ? it !== null : isCallable(it);
|
|
23132
23738
|
};
|
|
23133
23739
|
|
|
@@ -23263,10 +23869,10 @@ var shared = createCommonjsModule(function (module) {
|
|
|
23263
23869
|
(module.exports = function (key, value) {
|
|
23264
23870
|
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
|
23265
23871
|
})('versions', []).push({
|
|
23266
|
-
version: '3.
|
|
23872
|
+
version: '3.35.1',
|
|
23267
23873
|
mode: 'global',
|
|
23268
|
-
copyright: '© 2014-
|
|
23269
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
23874
|
+
copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
|
|
23875
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.35.1/LICENSE',
|
|
23270
23876
|
source: 'https://github.com/zloirock/core-js'
|
|
23271
23877
|
});
|
|
23272
23878
|
});
|
|
@@ -23563,7 +24169,7 @@ var TEMPLATE = String(String).split('String');
|
|
|
23563
24169
|
|
|
23564
24170
|
var makeBuiltIn = module.exports = function (value, name, options) {
|
|
23565
24171
|
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
|
|
23566
|
-
name = '[' + replace($String(name), /^Symbol\(([^)]*)\)
|
|
24172
|
+
name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
|
|
23567
24173
|
}
|
|
23568
24174
|
if (options && options.getter) name = 'get ' + name;
|
|
23569
24175
|
if (options && options.setter) name = 'set ' + name;
|
|
@@ -23651,7 +24257,8 @@ var min$1 = Math.min;
|
|
|
23651
24257
|
// `ToLength` abstract operation
|
|
23652
24258
|
// https://tc39.es/ecma262/#sec-tolength
|
|
23653
24259
|
var toLength = function (argument) {
|
|
23654
|
-
|
|
24260
|
+
var len = toIntegerOrInfinity(argument);
|
|
24261
|
+
return len > 0 ? min$1(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
23655
24262
|
};
|
|
23656
24263
|
|
|
23657
24264
|
// `LengthOfArrayLike` abstract operation
|
|
@@ -23811,7 +24418,7 @@ var _export = function (options, source) {
|
|
|
23811
24418
|
} else if (STATIC) {
|
|
23812
24419
|
target = global_1[TARGET] || defineGlobalProperty(TARGET, {});
|
|
23813
24420
|
} else {
|
|
23814
|
-
target =
|
|
24421
|
+
target = global_1[TARGET] && global_1[TARGET].prototype;
|
|
23815
24422
|
}
|
|
23816
24423
|
if (target) for (key in source) {
|
|
23817
24424
|
sourceProperty = source[key];
|
|
@@ -24074,11 +24681,15 @@ var functionUncurryThisAccessor = function (object, key, method) {
|
|
|
24074
24681
|
} catch (error) { /* empty */ }
|
|
24075
24682
|
};
|
|
24076
24683
|
|
|
24684
|
+
var isPossiblePrototype = function (argument) {
|
|
24685
|
+
return isObject(argument) || argument === null;
|
|
24686
|
+
};
|
|
24687
|
+
|
|
24077
24688
|
var $String$4 = String;
|
|
24078
24689
|
var $TypeError$6 = TypeError;
|
|
24079
24690
|
|
|
24080
24691
|
var aPossiblePrototype = function (argument) {
|
|
24081
|
-
if (
|
|
24692
|
+
if (isPossiblePrototype(argument)) return argument;
|
|
24082
24693
|
throw new $TypeError$6("Can't set " + $String$4(argument) + ' as a prototype');
|
|
24083
24694
|
};
|
|
24084
24695
|
|