source: frontend/node_modules/tailwindcss/lib/util/withAlphaVariable.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.0 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", {
3 value: true
4});
5function _export(target, all) {
6 for(var name in all)Object.defineProperty(target, name, {
7 enumerable: true,
8 get: all[name]
9 });
10}
11_export(exports, {
12 withAlphaValue: function() {
13 return withAlphaValue;
14 },
15 default: function() {
16 return withAlphaVariable;
17 }
18});
19const _color = require("./color");
20function withAlphaValue(color, alphaValue, defaultValue) {
21 if (typeof color === "function") {
22 return color({
23 opacityValue: alphaValue
24 });
25 }
26 let parsed = (0, _color.parseColor)(color, {
27 loose: true
28 });
29 if (parsed === null) {
30 return defaultValue;
31 }
32 return (0, _color.formatColor)({
33 ...parsed,
34 alpha: alphaValue
35 });
36}
37function withAlphaVariable({ color , property , variable }) {
38 let properties = [].concat(property);
39 if (typeof color === "function") {
40 return {
41 [variable]: "1",
42 ...Object.fromEntries(properties.map((p)=>{
43 return [
44 p,
45 color({
46 opacityVariable: variable,
47 opacityValue: `var(${variable}, 1)`
48 })
49 ];
50 }))
51 };
52 }
53 const parsed = (0, _color.parseColor)(color);
54 if (parsed === null) {
55 return Object.fromEntries(properties.map((p)=>[
56 p,
57 color
58 ]));
59 }
60 if (parsed.alpha !== undefined) {
61 // Has an alpha value, return color as-is
62 return Object.fromEntries(properties.map((p)=>[
63 p,
64 color
65 ]));
66 }
67 return {
68 [variable]: "1",
69 ...Object.fromEntries(properties.map((p)=>{
70 return [
71 p,
72 (0, _color.formatColor)({
73 ...parsed,
74 alpha: `var(${variable}, 1)`
75 })
76 ];
77 }))
78 };
79}
Note: See TracBrowser for help on using the repository browser.