@dizmo/dcs-client-library 4.2.1 → 4.2.2
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.
|
@@ -140,7 +140,7 @@ class AllocationElement extends HTMLElement {
|
|
|
140
140
|
this.shadowRoot.innerHTML = `
|
|
141
141
|
<style>${this.getStyles()}</style>
|
|
142
142
|
<div class="container">
|
|
143
|
-
${this.buildItemElement(item)}
|
|
143
|
+
${this.buildItemElement(item, {}, this.getAttribute("leafType") || "resource")}
|
|
144
144
|
<div class="info-section">${infoRows}</div>
|
|
145
145
|
</div>
|
|
146
146
|
`;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Shared web component that can display resource, package, need, and event items.
|
|
2
2
|
import { ItemType } from "../types/types";
|
|
3
|
+
const packageIconLight = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#424142" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
|
|
4
|
+
const packageIconDark = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#ffffff" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
|
|
5
|
+
const needBadgeIcon = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M477.28-240q21.96 0 37.3-15.34 15.33-15.33 15.33-37.32 0-21.99-15.33-37.18-15.34-15.18-37.3-15.18-21.95 0-37.29 15.18-15.34 15.19-15.34 37.18 0 21.99 15.34 37.32Q455.33-240 477.28-240ZM483.28-646.98q23.07 0 40.15 14.91 17.07 14.91 17.07 37.27 0 20.8-12.66 37.08-12.67 16.29-28.71 30.33-23 20-40.62 44.24-17.62 24.24-17.62 54.24 0 14.81 11.15 24.86Q463.2-394 478.07-394q15.93 0 27.15-10.6 11.21-10.6 15.17-26.31 4.48-20.05 17.64-35.71 13.17-15.66 28.45-29.95 23-21.76 39.02-48.11 16.02-26.36 16.02-58.12 0-51.48-41.14-84.58t-95.9-33.1q-38.96 0-73.82 16.48-34.86 16.48-53.81 49.96-7.48 12.71-4.76 27.16 2.73 14.45 14.71 21.95 14.72 8.71 30.8 5.35 16.07-3.35 27.03-17.83 10.52-14.05 26.09-21.81 15.58-7.76 32.56-7.76Z"/></svg>')}`;
|
|
3
6
|
class ItemElement extends HTMLElement {
|
|
4
7
|
constructor() {
|
|
5
8
|
super();
|
|
@@ -115,6 +118,23 @@ class ItemElement extends HTMLElement {
|
|
|
115
118
|
.invert {
|
|
116
119
|
filter: invert(1);
|
|
117
120
|
}
|
|
121
|
+
.need-badge {
|
|
122
|
+
position: absolute;
|
|
123
|
+
bottom: -3px;
|
|
124
|
+
right: -3px;
|
|
125
|
+
width: 16px;
|
|
126
|
+
height: 16px;
|
|
127
|
+
border-radius: 50%;
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
align-items: center;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
}
|
|
134
|
+
.need-badge img {
|
|
135
|
+
width: 100%;
|
|
136
|
+
height: 100%;
|
|
137
|
+
}
|
|
118
138
|
</style>
|
|
119
139
|
<div class="item">
|
|
120
140
|
${showLeftImage
|
|
@@ -131,7 +151,8 @@ class ItemElement extends HTMLElement {
|
|
|
131
151
|
</div>
|
|
132
152
|
<button class="item_button not-invert" id="open-item-btn" itemid="${itemId}"
|
|
133
153
|
template="${template}" icolor="${color}"${color ? ` style="background-color: ${color} !important"` : ""}>
|
|
134
|
-
<img class="item_button-image${invertIcon(color)}" loading="lazy" src="${iconUrl}" />
|
|
154
|
+
<img class="item_button-image${iconUrl ? invertIcon(color) : ""}" loading="lazy" src="${iconUrl || getDefaultIcon(itemType, color)}" />
|
|
155
|
+
${itemType === ItemType.Need ? `<div class="need-badge" style="background-color: ${isIconInverted(color) ? "#ffffff" : "#000000"};"><img src="${needBadgeIcon}" style="${isIconInverted(color) ? "" : "filter: invert(1);"}"></div>` : ""}
|
|
135
156
|
</button>
|
|
136
157
|
</div>
|
|
137
158
|
`;
|
|
@@ -154,6 +175,14 @@ const formatDateToLocale = (dateString) => {
|
|
|
154
175
|
return dateString;
|
|
155
176
|
}
|
|
156
177
|
};
|
|
178
|
+
const getDefaultIcon = (itemType, color) => {
|
|
179
|
+
if (itemType === ItemType.Package) {
|
|
180
|
+
const isInverted = invertIcon(color) === " invert";
|
|
181
|
+
return isInverted ? packageIconDark : packageIconLight;
|
|
182
|
+
}
|
|
183
|
+
return "";
|
|
184
|
+
};
|
|
185
|
+
const isIconInverted = (color) => invertIcon(color) === " invert";
|
|
157
186
|
const invertIcon = (backgroundColor) => {
|
|
158
187
|
if (!backgroundColor ||
|
|
159
188
|
backgroundColor === "transparent" ||
|
package/dist/types/types.d.ts
CHANGED