Lettersail: online English school for kids on MODX 3 (templates, chunks, snippets, plugins, scripts)

This commit is contained in:
jimagie committed 2026-11-01 18:30:36 +05:00
commit 3799cf8de5
96 files changed
+4423

No files matched your search

+76
View File
@@ -0,0 +1,76 @@
(()=>{
const rng=seed=>()=>{seed=(seed*1664525+1013904223)>>>0;return seed/4294967296};
const sandRidge=(y,i,w)=>{
const silhouettes=[
'M-350 35C-120 42 90 72 230 4C352 -56 359 -126 507 -139C680 -154 827 -71 979 -62C1122 -53 1114 -212 1242 -227C1367 -244 1464 -150 1582 -175C1735 -207 1765 -320 1930 -311C2091 -302 2229 -220 2398 -248C2531 -270 2650 -343 2950 -318L2950 -154C2670 -176 2544 -102 2385 -89C2180 -70 2075 -142 1914 -146C1737 -150 1692 -39 1558 -26C1400 -11 1339 -94 1228 -63C1119 -33 1159 94 992 104C819 114 670 28 510 51C360 72 340 150 212 179C43 216 -133 175 -350 190Z',
'M-350 40C-131 14 63 112 238 43C380 -14 409 -91 539 -102C674 -114 772 -18 899 -47C1000 -70 1002 -186 1113 -206C1241 -229 1365 -151 1499 -164C1652 -179 1681 -285 1829 -304C1998 -325 2121 -220 2292 -255C2445 -285 2571 -366 2950 -325L2950 -165C2601 -202 2485 -113 2308 -97C2134 -82 1981 -168 1833 -122C1692 -77 1673 7 1511 16C1341 24 1233 -56 1139 -9C1063 29 1070 121 927 137C780 155 675 60 534 83C407 104 364 183 223 211C39 248 -138 178 -350 205Z'
];
const crest=[
'M-350 35C-120 42 90 72 230 4C352 -56 359 -126 507 -139C680 -154 827 -71 979 -62C1122 -53 1114 -212 1242 -227C1367 -244 1464 -150 1582 -175C1735 -207 1765 -320 1930 -311C2091 -302 2229 -220 2398 -248C2531 -270 2650 -343 2950 -318L2950 -296C2650 -321 2537 -245 2401 -225C2220 -198 2089 -279 1927 -286C1776 -293 1738 -183 1588 -150C1462 -123 1360 -219 1244 -202C1125 -184 1137 -25 982 -35C819 -27 675 -127 510 -112C372 -99 361 -27 241 31C93 101 -121 70 -350 61Z',
'M-350 40C-131 14 63 112 238 43C380 -14 409 -91 539 -102C674 -114 772 -18 899 -47C1000 -70 1002 -186 1113 -206C1241 -229 1365 -151 1499 -164C1652 -179 1681 -285 1829 -304C1998 -325 2121 -220 2292 -255C2445 -285 2571 -366 2950 -325L2950 -304C2574 -342 2455 -260 2295 -231C2110 -196 1997 -301 1833 -276C1696 -257 1655 -152 1501 -139C1358 -124 1241 -200 1118 -180C1014 -163 1016 -41 904 -20C764 7 673 -88 541 -75C421 -63 393 10 246 69C63 140 -132 40 -350 65Z'
];
return `<g transform="translate(0 ${y}) scale(${w/2600} 1)"><path d="${silhouettes[i%2]}" fill="#F7E4BD" opacity=".82"/><path d="${crest[i%2]}" fill="#F0D6A3" opacity=".66"/></g>`;
};
const sandGrains=(count,w,h,start,r)=>{let s='';for(let i=0;i<count;i++){const x=r()*w,y=start+r()*(h-start),rx=1.8+r()*3.9,ry=rx*(.65+r()*.6),angle=r()*180;s+=`<ellipse cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" rx="${rx.toFixed(1)}" ry="${ry.toFixed(1)}" transform="rotate(${angle.toFixed(0)} ${x.toFixed(1)} ${y.toFixed(1)})" fill="${i%3?'#E4C582':'#EED5A5'}" opacity="${(.45+r()*.3).toFixed(2)}"/>`;}return s;};
document.querySelectorAll(".learn__bg").forEach(svg=>{
const W=2600,H=2400,r=rng(5);
const step=o=>`M-300 ${120+o}C400 ${60+o} 800 ${110+o} 1150 ${330+o}S1800 ${640+o} 2900 ${600+o}L2900 ${H}L-300 ${H}Z`;
let stripes='';
for(let y=980,i=0;y<H+450;y+=490,i++)stripes+=sandRidge(y,i,W);
const grains=sandGrains(320,W,H,700,r);
svg.setAttribute("viewBox",`0 0 ${W} ${H}`);
svg.innerHTML=`<g transform="rotate(3 ${W/2} ${H/2})"><path d="${step(-120)}" fill="#F8B994"/><path d="${step(0)}" fill="#FCEACA"/>${stripes}${grains}</g>`;
});
const jit=rng(29);
const jitter=()=>`translate(0 ${((jit()-.5)*9).toFixed(1)}) rotate(${((jit()-.5)*7).toFixed(1)} 20 100) scale(1 ${(.94+jit()*.1).toFixed(3)})`;
const BRUSH=window.brushTable({"П":{w:76,d:"M14 92V10H62V92"},"А":{w:80,d:"M10 92L40 8L70 92M22 62H58"},"Й":{w:76,d:"M14 12L14 92L62 12L62 92M24 -26Q38 -12 52 -26"},"С":{w:70,d:"M60 18C28 -6 10 20 10 52C10 83 32 109 61 84"},"Ё":{w:62,d:"M50 10L14 10L14 92L52 92M14 50L44 50M22 -8L22 -7M42 -8L42 -7"}});
document.querySelectorAll(".learn__brush").forEach((svg,n)=>{
const word=svg.dataset.word;let cx=0,h="";
[...word].forEach(ch=>{const g=BRUSH[ch],t=`translate(${cx} 0) ${jitter()}`;h+=`<path class="learn__shadow" d="${g.d}" transform="translate(-8 8) ${t}"/><path class="learn__ink" d="${g.d}" transform="${t}"/>`;cx+=g.w+16});
svg.setAttribute("viewBox",`-24 -48 ${cx-16+48} 160`);svg.setAttribute("role","img");svg.setAttribute("aria-label",word.charAt(0)+word.slice(1).toLowerCase());
svg.innerHTML=`<defs><filter id="learn-brush-${n}" x="-5%" y="-50%" width="110%" height="200%"><feTurbulence type="fractalNoise" baseFrequency=".09" numOctaves="2" seed="3"/><feDisplacementMap in="SourceGraphic" scale="6"/></filter></defs><g filter="url(#learn-brush-${n})">${h}</g>`;
});
const W="#FFFFFF",P="#F69971",T="#84CAC8",D="#3E5F5C";
const ICONS={
speak:`<path d="M14 18C14 12 18 8 24 8H76C82 8 86 12 86 18V54C86 60 82 64 76 64H42L24 80V64C18 64 14 60 14 54Z" fill="${W}"/><circle cx="34" cy="36" r="5" fill="${P}"/><circle cx="50" cy="36" r="5" fill="${P}"/><circle cx="66" cy="36" r="5" fill="${P}"/>`,
listen:`<path d="M22 56V46C22 28 34 16 50 16S78 28 78 46V56" fill="none" stroke="${W}" stroke-width="7" stroke-linecap="round"/><rect x="14" y="50" width="18" height="30" rx="8" fill="${W}"/><rect x="68" y="50" width="18" height="30" rx="8" fill="${W}"/>`,
read:`<path d="M50 24C40 16 26 14 12 16V76C26 74 40 76 50 84C60 76 74 74 88 76V16C74 14 60 16 50 24Z" fill="${W}"/><path d="M50 24V84" stroke="${P}" stroke-width="4"/><path d="M22 34H40M22 46H40M60 34H78M60 46H78M60 58H74" stroke="${T}" stroke-width="4" stroke-linecap="round"/>`,
write:`<rect x="14" y="14" width="56" height="70" rx="8" fill="${W}"/><path d="M26 32H58M26 46H58M26 60H46" stroke="${T}" stroke-width="5" stroke-linecap="round"/><path d="M84 30L52 72L46 82L56 76L88 34Z" fill="${D}"/>`
};
document.querySelectorAll(".learn [data-icon]").forEach(el=>{el.outerHTML=`<svg viewBox="0 0 100 92" aria-hidden="true">${ICONS[el.dataset.icon]}</svg>`});
const PD="#F19C77",C="#FFFFFF",S="#F19C77";
const THINGS={
book:`<path d="M18 47Q61 27 100 49Q140 27 183 47L181 151Q139 136 100 164Q60 136 20 151Z" fill="#F69971"/><path d="M26 49Q62 32 99 55L99 153Q63 132 28 144Z" fill="#FFFFFF"/><path d="M102 55Q139 32 175 49L173 144Q137 132 102 153Z" fill="#FFFFFF"/><path d="M30 141Q66 132 98 153M103 153Q138 132 172 141" fill="none" stroke="#FCEACA" stroke-width="4" stroke-linecap="round"/><path d="M100 55Q96 100 100 153" fill="none" stroke="#F19C77" stroke-width="3" stroke-linecap="round"/><path d="M42 70Q62 65 82 76M43 89Q63 84 82 95M44 109Q63 104 77 113M119 76Q140 65 159 70M119 95Q140 84 159 89M119 114Q138 103 155 108" fill="none" stroke="#52B8B1" stroke-width="5" stroke-linecap="round"/>`,
hello:`<path d="M20 30C20 20 28 14 38 14H162C172 14 180 20 180 30V104C180 114 172 120 162 120H84L50 150V120H38C28 120 20 114 20 104Z" fill="#52B8B1"/><text x="100" y="82" text-anchor="middle" font-family="Neucha, sans-serif" font-size="46" fill="${W}">Hello!</text>`,
pencil:`<g transform="rotate(37 100 95)">
<path fill="#52B8B1" d="M86 22Q98 18 111 22Q116 24 116 31L115 50L82 50L81 31Q80 25 86 22Z"/>
<path fill="#F69971" d="M82 46Q98 48 115 46L113 131Q104 139 98 137Q90 138 83 131Z"/>
<path fill="#FFF8EC" d="M87 49L93 49L94 132L87 130Z"/>
<path fill="#FFF8EC" d="M83 131L91 134L98 131L105 135L113 131Q107 148 98 167Q89 149 83 131Z"/>
<path fill="#F69971" d="M92 155Q98 157 104 154L99 168Q97 172 96 168Z"/>
<path fill="#FFF8EC" d="M82 43Q98 45 115 43L115 49Q98 51 82 49Z"/>
</g>`,
phones:`
<path fill="#52B8B1" d="M36 112C30 90 32 66 44 47C56 27 76 18 99 20C122 20 142 31 153 49C165 68 168 91 161 114L149 110C154 89 151 70 141 55C131 40 117 33 98 33C80 31 65 38 55 53C45 69 44 90 49 108Z"/>
<path fill="#F69971" d="M30 100C35 95 43 95 50 97C57 99 60 105 61 114L64 144C65 154 61 160 52 163L40 165C31 164 26 159 25 151L21 119C20 110 23 104 30 100Z"/>
<path fill="#FFF8EC" d="M37 108C41 105 47 107 48 113L52 146C52 151 49 153 45 152C41 152 39 149 39 145L35 116C34 112 35 110 37 108Z"/>
<path fill="#F69971" d="M148 96C155 94 163 97 167 102C172 107 174 113 172 121L169 149C168 159 163 163 154 162L143 160C135 158 132 153 133 144L136 114C137 103 141 98 148 96Z"/>
<path fill="#FFF8EC" d="M149 108C153 105 159 108 159 113L156 144C155 149 153 151 149 150C145 150 144 147 145 142L147 115C147 112 147 110 149 108Z"/>`
};
document.querySelectorAll("[data-thing]").forEach(el=>{el.setAttribute("aria-hidden","true");el.innerHTML=`<svg viewBox="0 0 200 190"><defs><filter id="thing-shadow-${el.dataset.thing}" x="-20%" y="-20%" width="140%" height="150%"><feDropShadow dx="-6" dy="9" stdDeviation="0" flood-color="#B98A45" flood-opacity=".28"/></filter></defs><g filter="url(#thing-shadow-${el.dataset.thing})">${THINGS[el.dataset.thing]}</g></svg>`});
const wob=rng(41);
const wrap=node=>[...node.childNodes].forEach(n=>{
if(n.nodeType===3){const f=document.createDocumentFragment();[...n.textContent].forEach(ch=>{if(ch===" "){f.append(" ");return}const s=document.createElement("span");s.className="learn__char";s.style.cssText=`--y:${((wob()-.5)*.09).toFixed(3)}em;--a:${((wob()-.5)*7).toFixed(1)}deg;--s:${(.94+wob()*.1).toFixed(3)}`;s.textContent=ch;f.append(s)});n.replaceWith(f)}
else if(n.nodeType===1)wrap(n);
});
document.querySelectorAll("[data-wobble]").forEach(wrap);
const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add("learn--play");io.unobserve(e.target)}}),{threshold:.4});
document.querySelectorAll("[data-learn]").forEach(s=>io.observe(s));
})();