@damian-buho/support-ukraine 1.5.2 → 1.6.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/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ The entire block is a clickable link to the charity's donation page.
|
|
|
77
77
|
|---------------|-------------------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------|
|
|
78
78
|
| `element` | `HTMLElement` | `document.body` | Target mount element for the banner |
|
|
79
79
|
| `mode` | `'shift' \| 'overlap' \| 'replace'` | `'shift'` | `'shift'` pushes page content down, `'overlap'` floats on top, `'replace'` swaps a same-class placeholder element |
|
|
80
|
-
| `fontSize` | `string` | `'
|
|
80
|
+
| `fontSize` | `string` | `'87.5%'` | Banner font size; `%` anchors to the widget's own 16px host box, ignoring document root scaling |
|
|
81
81
|
| `tags` | `CharityTag[]` | _(all)_ | Filter charities by category: `'military'`, `'humanitarian'`, `'animals'` |
|
|
82
82
|
| `dontRepeat` | `boolean` | `true` | Avoid repeating charities across page loads using `localStorage` |
|
|
83
83
|
| `isInConsole` | `boolean` | `true` | Log the selected charity to the dev console |
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var K=["military","humanitarian","animals"];function c(t,e){if(!t)throw new Error(e)}function _(t,e){c(typeof t=="string",`${e} must be a string`),c(t.length>0,`${e} must not be empty`)}function oe(t,e){_(t,e);try{new URL(t)}catch{throw new Error(`${e} must be a valid URL`)}}function ie(t){return c(K.includes(t),`Invalid tag: ${String(t)}. Must be one of: ${K.join(", ")}`),t}function Y(t){c(t!==null&&typeof t=="object","Charity must be an object");let e=t;return _(e.id,"id"),_(e.name,"name"),_(e.tagline,"tagline"),oe(e.url,"url"),c(Array.isArray(e.tags),"tags must be an array"),c(e.tags.length>0,"tags must not be empty"),{id:e.id,name:e.name,tagline:e.tagline,url:e.url,tags:e.tags.map(r=>ie(r))}}var se={parse:Y},I={parse(t){return c(Array.isArray(t),"Charities must be an array"),t.map(e=>Y(e))}};var J=[{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"]},{id:"dignitas",name:"Dignitas",tagline:"Technology and support for Ukrainian defenders and veterans",url:"https://dignitas.fund",tags:["military"]},{id:"leleka",name:"Leleka Foundation",tagline:"Tactical medical supplies for Ukraine's frontline medics",url:"https://leleka.care/en",tags:["humanitarian"]},{id:"superhumans",name:"Superhumans Center",tagline:"Prosthetics, surgery, and rehabilitation for war survivors",url:"https://superhumans.com/en/",tags:["humanitarian"]}];var W=":host{display:block;margin:0;padding:0;border:none;font-size:16px;width:100%;min-height:2.5em;line-height:1.4;box-sizing:border-box;z-index:2147483647}.support-ukraine-block__visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0}header.support-ukraine-block{margin:0;padding:0;border:none;border-radius:0;width:100%;min-height:2.5em;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--refreshing .support-ukraine-block__link{opacity: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:.5em 1em;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}@media(prefers-reduced-motion: no-preference){header.support-ukraine-block .support-ukraine-block__link{transition:opacity .2s ease-in-out}}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__link:hover{opacity:.9}header.support-ukraine-block .support-ukraine-block__link:focus-visible{outline:2px solid #fff;outline-offset:-2px}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:.5em 1em;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 rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__more:hover{opacity:1}header.support-ukraine-block .support-ukraine-block__more:focus-visible{outline:2px solid #fff;outline-offset:-2px}header.support-ukraine-block .support-ukraine-block__more-ellipsis{display:none}header.support-ukraine-block .support-ukraine-block__refresh{display:inline-flex;align-items:center;background:none;border:none;text-decoration:none;padding:.5em .5em .5em 1em;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4);white-space:nowrap;opacity:.8;cursor:pointer;font-size:inherit;line-height:1}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__refresh{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__refresh:hover{opacity:1}header.support-ukraine-block .support-ukraine-block__refresh:focus-visible{outline:2px solid #fff;outline-offset:-2px}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,header.support-ukraine-block .support-ukraine-block__refresh{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}[dir=rtl] header.support-ukraine-block .support-ukraine-block__refresh{text-align:right}:host-context([data-theme=dark]) header.support-ukraine-block{background-color:gold}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__more{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__refresh{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=light]) header.support-ukraine-block{background-color:#0057b7}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__link{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__more{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__refresh{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}";var z={en:()=>import("./en-USDD4ZER.js"),es:()=>import("./es-AKIYXMKC.js"),fr:()=>import("./fr-7VL4S5JP.js"),de:()=>import("./de-SJGBM5DD.js"),pt:()=>import("./pt-JUS6AZJJ.js"),it:()=>import("./it-ZDMFUBOR.js"),pl:()=>import("./pl-N6U3K6J6.js"),nl:()=>import("./nl-BA3NAP2X.js"),sv:()=>import("./sv-AJXCXYD3.js"),uk:()=>import("./uk-UNLQFM5K.js"),ar:()=>import("./ar-HMIC6E5B.js"),zh:()=>import("./zh-F25PPVQF.js"),hi:()=>import("./hi-QEIYAT2C.js"),th:()=>import("./th-2W7FWPOF.js"),ja:()=>import("./ja-6734QCRR.js"),ko:()=>import("./ko-5UGWT3BY.js")},F=["ar"];function u(t){let e=(t.split("-",1)[0]??"").toLowerCase();return Object.hasOwn(z,e)?e:"en"}var X=new Map;function M(t){if(t)return u(t);if(typeof navigator<"u"&&navigator.languages)for(let e of navigator.languages){let r=u(e);if(r!=="en")return r}if(typeof navigator<"u"&&navigator.language){let e=u(navigator.language);if(e!=="en")return e}return"en"}async function w(t){let e=u(t),r=X.get(e);if(r)return r;try{let o=await z[e]();return X.set(e,o.default),o.default}catch{if(e!=="en")return w("en");throw new Error(`[support-ukraine] Failed to load locale "${e}"`)}}function j(t,e){return t.map(r=>{let o=e.charities[r.id];return o?.tagline?{...r,tagline:o.tagline}:r})}function H(t){let e=u(t);return F.includes(e)}function le(t,e){return`\u{1F1FA}\u{1F1E6} ${e.supportUkraine} ${t.name}: ${t.tagline}`}var pe=I.parse(J),n="support-ukraine-block",te="support-ukraine-seen",ce="\u27F3",Q=`${n}__visually-hidden`;function ue(){try{let t=localStorage.getItem(te);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function de(t){try{localStorage.setItem(te,JSON.stringify([...t]))}catch{}}function Z(t){let e=ue();t(e),de(e)}function me(t){if(t.length===0)throw new Error("randomItem: cannot pick from an empty array");return t[Math.floor(Math.random()*t.length)]}function ee(t,e){let r=t;e&&Z(p=>{let k=r.filter(L=>!p.has(L.url));k.length>0?r=k:p.clear()});let o=me(r);return e&&Z(p=>{p.add(o.url)}),o}function he(t){let e=`${n}-styles`;if(t.querySelector(`#${e}`))return;let r=t.ownerDocument.createElement("style");r.id=e,r.textContent=W,t.append(r)}async function Ce(t={}){let{mode:e="shift",fontSize:r="0.875rem",tags:o,dontRepeat:p=!0,isInConsole:k=!0,showRefreshButton:L=!1,autoRefreshInterval:O=0,showRefreshAnimation:re=!1,locale:ae}=t,v=M(ae),d=await w(v),C=j(pe,d),f=o&&o.length>0?C.filter(a=>a.tags.some(ne=>o.includes(ne))):C;f.length===0&&(f=C);let m=ee(f,p),h=document.createElement("div"),B=h.attachShadow({mode:"open"});he(B);let i=document.createElement("header");i.className=`${n} ${n}--${e}`,i.lang=v,H(v)&&i.setAttribute("dir","rtl");let s=document.createElement("a");s.className=`${n}__link`,s.href=m.url,s.target="_blank",s.rel="noopener noreferrer",s.style.fontSize=r;let D=`${n}-link-new-tab`,g=document.createElement("span");g.id=D,g.className=Q,g.textContent=d.opensInNewTab,s.setAttribute("aria-describedby",D);let S=document.createElement("span");S.className=`${n}__flag`,S.textContent="\u{1F1FA}\u{1F1E6} ";let E=document.createElement("span");E.className=`${n}__prefix`,E.textContent=`${d.supportUkraine} `;let T=document.createElement("span");T.className=`${n}__info`;let b=document.createElement("span");b.className=`${n}__name`,b.textContent=m.name;let $=document.createElement("span");$.className=`${n}__colon`,$.textContent=": ";let y=document.createElement("span");y.className=`${n}__tagline`,y.textContent=m.tagline,T.append(b,$,y),s.append(S,E,T),i.append(s);let l=document.createElement("a");l.className=`${n}__more`,l.href="https://damian-buho.github.io/support-ukraine/",l.target="_blank",l.rel="noopener noreferrer",l.style.fontSize=r;let P=`${n}-more-new-tab`,x=document.createElement("span");x.id=P,x.className=Q,x.textContent=d.opensInNewTab,l.setAttribute("aria-describedby",P);let U=document.createElement("span");U.className=`${n}__more-text`,U.textContent=d.more;let A=document.createElement("span");A.className=`${n}__more-ellipsis`,A.textContent="\u2026",l.append(U,A),i.append(l),i.append(g,x);function V(a){s.href=a.url,b.textContent=a.name,y.textContent=a.tagline,k&&console.info("[support-ukraine] banner",`${a.name}: ${a.tagline}`,a.url)}function q(){let a=ee(f,p);re?(i.classList.add(`${n}--refreshing`),setTimeout(()=>{V(a),i.classList.remove(`${n}--refreshing`)},200)):V(a)}if(L){let a=document.createElement("button");a.className=`${n}__refresh`,a.type="button",a.textContent=ce,a.style.fontSize=r,a.setAttribute("aria-label",d.refresh),a.addEventListener("click",q),i.insertBefore(a,l)}B.append(i);let R=t.element??document.body;if(e==="replace"){let a=R.querySelector(`.${n}`);a?a.replaceWith(h):R.prepend(h)}else R.prepend(h);k&&console.info("[support-ukraine] banner",`${m.name}: ${m.tagline}`,m.url),h.dataset.supportUkraine="";let N;O>0&&(N=setInterval(q,O));let G=h;return G.destroy=()=>{N!==void 0&&clearInterval(N)},G}export{pe as DEFAULT_CHARITIES,F as RTL_LOCALES,I as charitiesSchema,se as charitySchema,M as detectLocale,le as formatBannerText,H as isRTL,w as loadLocale,j as mergeCharities,me as randomItem,u as resolveLocale,Ce as supportUkraineBlock};
|
|
1
|
+
var K=["military","humanitarian","animals"];function c(t,e){if(!t)throw new Error(e)}function _(t,e){c(typeof t=="string",`${e} must be a string`),c(t.length>0,`${e} must not be empty`)}function oe(t,e){_(t,e);try{new URL(t)}catch{throw new Error(`${e} must be a valid URL`)}}function ie(t){return c(K.includes(t),`Invalid tag: ${String(t)}. Must be one of: ${K.join(", ")}`),t}function Y(t){c(t!==null&&typeof t=="object","Charity must be an object");let e=t;return _(e.id,"id"),_(e.name,"name"),_(e.tagline,"tagline"),oe(e.url,"url"),c(Array.isArray(e.tags),"tags must be an array"),c(e.tags.length>0,"tags must not be empty"),{id:e.id,name:e.name,tagline:e.tagline,url:e.url,tags:e.tags.map(r=>ie(r))}}var se={parse:Y},I={parse(t){return c(Array.isArray(t),"Charities must be an array"),t.map(e=>Y(e))}};var J=[{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"]},{id:"dignitas",name:"Dignitas",tagline:"Technology and support for Ukrainian defenders and veterans",url:"https://dignitas.fund",tags:["military"]},{id:"leleka",name:"Leleka Foundation",tagline:"Tactical medical supplies for Ukraine's frontline medics",url:"https://leleka.care/en",tags:["humanitarian"]},{id:"superhumans",name:"Superhumans Center",tagline:"Prosthetics, surgery, and rehabilitation for war survivors",url:"https://superhumans.com/en/",tags:["humanitarian"]}];var W=":host{display:block;margin:0;padding:0;border:none;font-size:16px;width:100%;min-height:2.5em;line-height:1.4;box-sizing:border-box;z-index:2147483647}.support-ukraine-block__visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0}header.support-ukraine-block{margin:0;padding:0;border:none;border-radius:0;width:100%;min-height:2.5em;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--refreshing .support-ukraine-block__link{opacity: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:.5em 1em;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}@media(prefers-reduced-motion: no-preference){header.support-ukraine-block .support-ukraine-block__link{transition:opacity .2s ease-in-out}}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__link:hover{opacity:.9}header.support-ukraine-block .support-ukraine-block__link:focus-visible{outline:2px solid #fff;outline-offset:-2px}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:.5em 1em;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 rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__more:hover{opacity:1}header.support-ukraine-block .support-ukraine-block__more:focus-visible{outline:2px solid #fff;outline-offset:-2px}header.support-ukraine-block .support-ukraine-block__more-ellipsis{display:none}header.support-ukraine-block .support-ukraine-block__refresh{display:inline-flex;align-items:center;background:none;border:none;text-decoration:none;padding:.5em .5em .5em 1em;box-sizing:border-box;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4);white-space:nowrap;opacity:.8;cursor:pointer;font-size:inherit;line-height:1}@media(prefers-color-scheme: dark){header.support-ukraine-block .support-ukraine-block__refresh{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}}header.support-ukraine-block .support-ukraine-block__refresh:hover{opacity:1}header.support-ukraine-block .support-ukraine-block__refresh:focus-visible{outline:2px solid #fff;outline-offset:-2px}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,header.support-ukraine-block .support-ukraine-block__refresh{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}[dir=rtl] header.support-ukraine-block .support-ukraine-block__refresh{text-align:right}:host-context([data-theme=dark]) header.support-ukraine-block{background-color:gold}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__link{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__more{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=dark]) header.support-ukraine-block .support-ukraine-block__refresh{color:#000;text-shadow:0 1px 2px rgba(255,255,255,.4)}:host-context([data-theme=light]) header.support-ukraine-block{background-color:#0057b7}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__link{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__more{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}:host-context([data-theme=light]) header.support-ukraine-block .support-ukraine-block__refresh{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.4)}";var z={en:()=>import("./en-USDD4ZER.js"),es:()=>import("./es-AKIYXMKC.js"),fr:()=>import("./fr-7VL4S5JP.js"),de:()=>import("./de-SJGBM5DD.js"),pt:()=>import("./pt-JUS6AZJJ.js"),it:()=>import("./it-ZDMFUBOR.js"),pl:()=>import("./pl-N6U3K6J6.js"),nl:()=>import("./nl-BA3NAP2X.js"),sv:()=>import("./sv-AJXCXYD3.js"),uk:()=>import("./uk-UNLQFM5K.js"),ar:()=>import("./ar-HMIC6E5B.js"),zh:()=>import("./zh-F25PPVQF.js"),hi:()=>import("./hi-QEIYAT2C.js"),th:()=>import("./th-2W7FWPOF.js"),ja:()=>import("./ja-6734QCRR.js"),ko:()=>import("./ko-5UGWT3BY.js")},F=["ar"];function u(t){let e=(t.split("-",1)[0]??"").toLowerCase();return Object.hasOwn(z,e)?e:"en"}var X=new Map;function M(t){if(t)return u(t);if(typeof navigator<"u"&&navigator.languages)for(let e of navigator.languages){let r=u(e);if(r!=="en")return r}if(typeof navigator<"u"&&navigator.language){let e=u(navigator.language);if(e!=="en")return e}return"en"}async function w(t){let e=u(t),r=X.get(e);if(r)return r;try{let o=await z[e]();return X.set(e,o.default),o.default}catch{if(e!=="en")return w("en");throw new Error(`[support-ukraine] Failed to load locale "${e}"`)}}function j(t,e){return t.map(r=>{let o=e.charities[r.id];return o?.tagline?{...r,tagline:o.tagline}:r})}function H(t){let e=u(t);return F.includes(e)}function le(t,e){return`\u{1F1FA}\u{1F1E6} ${e.supportUkraine} ${t.name}: ${t.tagline}`}var pe=I.parse(J),n="support-ukraine-block",te="support-ukraine-seen",ce="\u27F3",Q=`${n}__visually-hidden`;function ue(){try{let t=localStorage.getItem(te);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function de(t){try{localStorage.setItem(te,JSON.stringify([...t]))}catch{}}function Z(t){let e=ue();t(e),de(e)}function me(t){if(t.length===0)throw new Error("randomItem: cannot pick from an empty array");return t[Math.floor(Math.random()*t.length)]}function ee(t,e){let r=t;e&&Z(p=>{let k=r.filter(L=>!p.has(L.url));k.length>0?r=k:p.clear()});let o=me(r);return e&&Z(p=>{p.add(o.url)}),o}function he(t){let e=`${n}-styles`;if(t.querySelector(`#${e}`))return;let r=t.ownerDocument.createElement("style");r.id=e,r.textContent=W,t.append(r)}async function Ce(t={}){let{mode:e="shift",fontSize:r="87.5%",tags:o,dontRepeat:p=!0,isInConsole:k=!0,showRefreshButton:L=!1,autoRefreshInterval:O=0,showRefreshAnimation:re=!1,locale:ae}=t,v=M(ae),d=await w(v),C=j(pe,d),f=o&&o.length>0?C.filter(a=>a.tags.some(ne=>o.includes(ne))):C;f.length===0&&(f=C);let m=ee(f,p),h=document.createElement("div"),B=h.attachShadow({mode:"open"});he(B);let i=document.createElement("header");i.className=`${n} ${n}--${e}`,i.lang=v,H(v)&&i.setAttribute("dir","rtl");let s=document.createElement("a");s.className=`${n}__link`,s.href=m.url,s.target="_blank",s.rel="noopener noreferrer",s.style.fontSize=r;let D=`${n}-link-new-tab`,g=document.createElement("span");g.id=D,g.className=Q,g.textContent=d.opensInNewTab,s.setAttribute("aria-describedby",D);let S=document.createElement("span");S.className=`${n}__flag`,S.textContent="\u{1F1FA}\u{1F1E6} ";let E=document.createElement("span");E.className=`${n}__prefix`,E.textContent=`${d.supportUkraine} `;let T=document.createElement("span");T.className=`${n}__info`;let b=document.createElement("span");b.className=`${n}__name`,b.textContent=m.name;let $=document.createElement("span");$.className=`${n}__colon`,$.textContent=": ";let y=document.createElement("span");y.className=`${n}__tagline`,y.textContent=m.tagline,T.append(b,$,y),s.append(S,E,T),i.append(s);let l=document.createElement("a");l.className=`${n}__more`,l.href="https://damian-buho.github.io/support-ukraine/",l.target="_blank",l.rel="noopener noreferrer",l.style.fontSize=r;let P=`${n}-more-new-tab`,x=document.createElement("span");x.id=P,x.className=Q,x.textContent=d.opensInNewTab,l.setAttribute("aria-describedby",P);let U=document.createElement("span");U.className=`${n}__more-text`,U.textContent=d.more;let A=document.createElement("span");A.className=`${n}__more-ellipsis`,A.textContent="\u2026",l.append(U,A),i.append(l),i.append(g,x);function V(a){s.href=a.url,b.textContent=a.name,y.textContent=a.tagline,k&&console.info("[support-ukraine] banner",`${a.name}: ${a.tagline}`,a.url)}function q(){let a=ee(f,p);re?(i.classList.add(`${n}--refreshing`),setTimeout(()=>{V(a),i.classList.remove(`${n}--refreshing`)},200)):V(a)}if(L){let a=document.createElement("button");a.className=`${n}__refresh`,a.type="button",a.textContent=ce,a.style.fontSize=r,a.setAttribute("aria-label",d.refresh),a.addEventListener("click",q),i.insertBefore(a,l)}B.append(i);let R=t.element??document.body;if(e==="replace"){let a=R.querySelector(`.${n}`);a?a.replaceWith(h):R.prepend(h)}else R.prepend(h);k&&console.info("[support-ukraine] banner",`${m.name}: ${m.tagline}`,m.url),h.dataset.supportUkraine="";let N;O>0&&(N=setInterval(q,O));let G=h;return G.destroy=()=>{N!==void 0&&clearInterval(N)},G}export{pe as DEFAULT_CHARITIES,F as RTL_LOCALES,I as charitiesSchema,se as charitySchema,M as detectLocale,le as formatBannerText,H as isRTL,w as loadLocale,j as mergeCharities,me as randomItem,u as resolveLocale,Ce as supportUkraineBlock};
|
package/dist/types.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface SupportUkraineBlockOptions {
|
|
|
61
61
|
*/
|
|
62
62
|
mode?: 'shift' | 'overlap' | 'replace';
|
|
63
63
|
/**
|
|
64
|
-
Font size (default '
|
|
64
|
+
Font size (default '87.5%'). Percentages resolve against the widget's fixed 16px host box, so document root scaling is ignored; rem would inherit it.
|
|
65
65
|
*/
|
|
66
66
|
fontSize?: string;
|
|
67
67
|
/**
|