@damian-buho/support-ukraine 1.1.1 → 1.2.0
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.js +14 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ var charitiesSchema = {
|
|
|
53
53
|
var charities_default = [{ "id": "united24", "name": "United24", "tagline": "Official fundraising platform of Ukraine", "url": "https://u24.gov.ua", "tags": ["humanitarian"] }, { "id": "come-back-alive", "name": "Come Back Alive", "tagline": "Supporting the Ukrainian Armed Forces since 2014", "url": "https://www.comebackalive.in.ua", "tags": ["military"] }, { "id": "razom-for-ukraine", "name": "Razom for Ukraine", "tagline": "Emergency response and humanitarian aid", "url": "https://www.razomforukraine.org", "tags": ["humanitarian"] }, { "id": "ukrainian-red-cross", "name": "Ukrainian Red Cross", "tagline": "Humanitarian assistance in conflict zones", "url": "https://redcross.org.ua/en/", "tags": ["humanitarian"] }, { "id": "nova-ukraine", "name": "Nova Ukraine", "tagline": "Humanitarian aid and advocacy", "url": "https://novaukraine.org", "tags": ["humanitarian"] }, { "id": "voices-of-children", "name": "Voices of Children", "tagline": "Psychological support for children affected by war", "url": "https://voices.org.ua/en/", "tags": ["humanitarian"] }, { "id": "prytula-foundation", "name": "Prytula Foundation", "tagline": "Defence technology and equipment for Ukraine", "url": "https://prytulafoundation.org/en", "tags": ["military"] }, { "id": "army-of-drones", "name": "Army of Drones", "tagline": "Reconnaissance drones for the frontline", "url": "https://armyofdrones.com", "tags": ["military"] }, { "id": "world-central-kitchen", "name": "World Central Kitchen", "tagline": "Fresh meals for people in conflict zones", "url": "https://wck.org/relief/activation-chefs-for-ukraine/", "tags": ["humanitarian"] }, { "id": "cats-of-kyiv", "name": "Cats of Kyiv", "tagline": "Cat shelter rescuing and rehoming cats in Kyiv", "url": "https://cats.kiev.ua", "tags": ["animals"] }, { "id": "uanimals", "name": "UAnimals", "tagline": "Animal rescue and advocacy organization in Ukraine", "url": "https://uanimals.org", "tags": ["animals"] }, { "id": "hospitallers", "name": "Hospitallers", "tagline": "Ukrainian voluntary paramedics providing first aid and evacuation", "url": "https://www.hospitallers.org.uk", "tags": ["humanitarian"] }, { "id": "sternenko-fund", "name": "Sternenko Fund", "tagline": "FPV drone supply for Ukrainian defence forces", "url": "https://www.sternenkofund.org", "tags": ["military"] }, { "id": "life-robots-ukraine", "name": "Life Robots Ukraine", "tagline": "Robots for demining Ukraine", "url": "https://liferobots.com.ua", "tags": ["humanitarian"] }, { "id": "sirius-shelter", "name": "Sirius", "tagline": "Ukraine's largest animal shelter for dogs and cats", "url": "https://dogcat.com.ua", "tags": ["animals"] }];
|
|
54
54
|
|
|
55
55
|
// src/styles.scss
|
|
56
|
-
var styles_default = "header.support-ukraine-block{margin:0;padding:0;
|
|
56
|
+
var styles_default = ":host{display:block;margin:0;padding:0;border:none;font-size:16px;width:100%;min-height:2.5rem;line-height:1.4;box-sizing:border-box;z-index:2147483647}header.support-ukraine-block{margin:0;padding:0;border:none;border-radius:0;width:100%;min-height:2.5rem;display:flex;align-items:center;justify-content:center;font-family:system-ui,-apple-system,sans-serif;text-decoration:none;box-sizing:border-box;line-height:1.4;overflow:visible;background:#0057b7 none}@media(prefers-color-scheme: dark){header.support-ukraine-block{background-color:gold}}header.support-ukraine-block--shift,header.support-ukraine-block--replace{position:relative}header.support-ukraine-block--overlap{position:fixed;top:0;left:0}header.support-ukraine-block .support-ukraine-block__link{display:inline-flex;align-items:center;flex-wrap:wrap;gap:0 .25em;text-decoration:none;flex:1;height:100%;justify-content:flex-start;text-align:left;padding:.5rem 1rem;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px hsla(0,0%,100%,.4)}}header.support-ukraine-block .support-ukraine-block__link:hover{opacity:.9}header.support-ukraine-block .support-ukraine-block__flag{white-space:nowrap}header.support-ukraine-block .support-ukraine-block__prefix,header.support-ukraine-block .support-ukraine-block__info,header.support-ukraine-block .support-ukraine-block__colon,header.support-ukraine-block .support-ukraine-block__tagline{min-width:0}header.support-ukraine-block .support-ukraine-block__more{display:inline-flex;align-items:center;text-decoration:none;padding:.5rem 1rem;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4);white-space:nowrap;opacity:.8}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__more{color:#000;text-shadow:0 1px 2px hsla(0,0%,100%,.4)}}header.support-ukraine-block .support-ukraine-block__more:hover{opacity:1}header.support-ukraine-block .support-ukraine-block__more-ellipsis{display:none}header.support-ukraine-block .support-ukraine-block__name{font-weight:bold}@media(max-width: 58rem){header.support-ukraine-block .support-ukraine-block__prefix,header.support-ukraine-block .support-ukraine-block__name,header.support-ukraine-block .support-ukraine-block__colon,header.support-ukraine-block .support-ukraine-block__more{display:none}}@media(max-width: 35rem){header.support-ukraine-block .support-ukraine-block__name,header.support-ukraine-block .support-ukraine-block__colon{display:initial}header.support-ukraine-block .support-ukraine-block__tagline{display:none}}[dir=rtl] header.support-ukraine-block .support-ukraine-block__link{text-align:right;justify-content:flex-end}[dir=rtl] header.support-ukraine-block .support-ukraine-block__more{text-align:right}[data-theme=dark] header.support-ukraine-block{background-color:gold}[data-theme=dark] header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px hsla(0,0%,100%,.4)}[data-theme=dark] header.support-ukraine-block .support-ukraine-block__more{color:#000;text-shadow:0 1px 2px hsla(0,0%,100%,.4)}[data-theme=light] header.support-ukraine-block{background-color:#0057b7}[data-theme=light] header.support-ukraine-block .support-ukraine-block__link{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}[data-theme=light] header.support-ukraine-block .support-ukraine-block__more{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}";
|
|
57
57
|
|
|
58
58
|
// src/locales/index.ts
|
|
59
59
|
var localeLoaders = {
|
|
@@ -168,15 +168,15 @@ function randomItem(items) {
|
|
|
168
168
|
}
|
|
169
169
|
return items[Math.floor(Math.random() * items.length)];
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function injectShadowStyles(shadowRoot) {
|
|
172
172
|
const id = `${CSS_PREFIX}-styles`;
|
|
173
|
-
if (
|
|
173
|
+
if (shadowRoot.querySelector(`#${id}`)) {
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
const style =
|
|
176
|
+
const style = shadowRoot.ownerDocument.createElement("style");
|
|
177
177
|
style.id = id;
|
|
178
178
|
style.textContent = styles_default;
|
|
179
|
-
|
|
179
|
+
shadowRoot.append(style);
|
|
180
180
|
}
|
|
181
181
|
async function supportUkraineBlock(options = {}) {
|
|
182
182
|
const {
|
|
@@ -187,7 +187,6 @@ async function supportUkraineBlock(options = {}) {
|
|
|
187
187
|
isInConsole = true,
|
|
188
188
|
locale: requestedLocale
|
|
189
189
|
} = options;
|
|
190
|
-
injectStyles();
|
|
191
190
|
const lang = detectLocale(requestedLocale);
|
|
192
191
|
const messages = await loadLocale(lang);
|
|
193
192
|
const localizedCharities = mergeCharities(DEFAULT_CHARITIES, messages);
|
|
@@ -211,6 +210,9 @@ async function supportUkraineBlock(options = {}) {
|
|
|
211
210
|
seen.add(charity.url);
|
|
212
211
|
});
|
|
213
212
|
}
|
|
213
|
+
const host = document.createElement("div");
|
|
214
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
215
|
+
injectShadowStyles(shadow);
|
|
214
216
|
const banner = document.createElement("header");
|
|
215
217
|
banner.className = `${CSS_PREFIX} ${CSS_PREFIX}--${mode}`;
|
|
216
218
|
banner.lang = lang;
|
|
@@ -257,21 +259,22 @@ async function supportUkraineBlock(options = {}) {
|
|
|
257
259
|
moreEllipsis.textContent = "\u2026";
|
|
258
260
|
moreLink.append(moreText, moreEllipsis);
|
|
259
261
|
banner.append(moreLink);
|
|
262
|
+
shadow.append(banner);
|
|
260
263
|
const mount = options.element ?? document.body;
|
|
261
264
|
if (mode === "replace") {
|
|
262
|
-
const placeholder = mount.querySelector(`
|
|
265
|
+
const placeholder = mount.querySelector(`div[data-support-ukraine]`);
|
|
263
266
|
if (placeholder) {
|
|
264
|
-
placeholder.replaceWith(
|
|
267
|
+
placeholder.replaceWith(host);
|
|
265
268
|
} else {
|
|
266
|
-
mount.prepend(
|
|
269
|
+
mount.prepend(host);
|
|
267
270
|
}
|
|
268
271
|
} else {
|
|
269
|
-
mount.prepend(
|
|
272
|
+
mount.prepend(host);
|
|
270
273
|
}
|
|
271
274
|
if (isInConsole) {
|
|
272
275
|
console.info("[support-ukraine] banner", `${charity.name}: ${charity.tagline}`, charity.url);
|
|
273
276
|
}
|
|
274
|
-
return
|
|
277
|
+
return host;
|
|
275
278
|
}
|
|
276
279
|
export {
|
|
277
280
|
DEFAULT_CHARITIES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@damian-buho/support-ukraine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Browser library that adds a Ukraine-support charity banner to any website.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"eslint-plugin-unicorn": "71.1.0",
|
|
71
71
|
"globals": "17.7.0",
|
|
72
72
|
"js-yaml": "5.2.1",
|
|
73
|
-
"prettier": "3.9.
|
|
73
|
+
"prettier": "3.9.5",
|
|
74
74
|
"sass": "1.101.0",
|
|
75
75
|
"tsup": "8.5.1",
|
|
76
76
|
"typescript": "6.0.3",
|