mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 22:13:56 +08:00
update 2026-10-21 10:58:41
This commit is contained in:
1 parent
f144cc6010
commit
4570f1512e
495 files changed
+129503
-31
No files matched your search
@@ -0,0 +1 @@
|
||||
"use strict";"require baseclass";const HEX_RE=/^#[0-9a-fA-F]{3,8}$/,safeHex=(e,t)=>HEX_RE.test(e||"")?e:t,mixHex=(e,t)=>"color-mix(in srgb, "+e+" "+t+"%, transparent)",logoImage=(e,t,i)=>{if(!e)return t;const o=E("img",{src:e,alt:"",style:i});return o.addEventListener("error",()=>{o.parentNode&&o.parentNode.replaceChild(t,o)}),o},buildMini=(e,t)=>{const i=t&&t.nav||"top",o=safeHex(e&&e.bg,"#f7fafc"),s=safeHex(e&&e.surface,"#ffffff"),r=safeHex(e&&e.text,"#121a22"),n=safeHex(e&&e.brand,"#0086bf"),l=(e,t,i)=>{const o=E("span",{style:"height:22%;border-radius:99px;width:"+e+";"+(i||"")});return o.style.background=mixHex(r,t),o},d=e=>{const t=E("div",{style:"height:5px;border-radius:99px;margin-bottom:4%;width:"+e+";"});return t.style.background=mixHex(r,24),t},a=e=>{const t=E("div",{style:"border-radius:8px;padding:4%;margin-bottom:5%;"},e);return t.style.background=s,t.style.border="1px solid "+mixHex(r,10),t},g="width:7%;aspect-ratio:1;border-radius:25%;flex:none;",b=E("span",{style:g});b.style.background=n;const x=logoImage(t&&t.logo||"",b,g+"object-fit:contain;"),u=E("div",{style:"height:8px;max-height:14%;border-radius:99px;width:45%;margin-bottom:6%;"});u.style.background=mixHex(r,72);const h=E("span",{style:"display:inline-block;width:26%;height:12px;border-radius:99px;"});h.style.background=n;const p=[a([u,d("90%"),d("70%"),h]),a([d("85%"),d("60%")])];let c,m;if("sidebar"===i){const e=E("div",{style:"position:absolute;left:0;top:0;bottom:0;width:22%;display:flex;flex-direction:column;gap:8%;padding:6% 4%;box-sizing:border-box;"},[x,l("80%",28,"height:7%;"),l("90%",28,"height:7%;"),l("70%",28,"height:7%;")]);e.children[2].style.background=n,e.style.background=s,e.style.borderRight="1px solid "+mixHex(r,12),c=[e],m=E("div",{style:"position:absolute;left:27%;top:7%;right:5%;bottom:0;"},p)}else{const e=E("div",{style:"position:absolute;left:0;right:0;top:0;height:16%;display:flex;align-items:center;gap:4%;padding:0 4%;box-sizing:border-box;"},[x,l("18%",55),l("12%",34),l("12%",34)]);if(e.style.background=s,e.style.borderBottom="1px solid "+mixHex(r,12),c=[e],"mega-menu"===i){const e=E("div",{style:"position:absolute;left:0;right:0;top:16%;height:13%;display:flex;align-items:center;gap:3%;padding:0 4%;box-sizing:border-box;"},[l("10%",30,"height:26%;"),l("14%",30,"height:26%;"),l("9%",30,"height:26%;"),l("12%",30,"height:26%;")]);e.style.background=s,e.style.borderBottom="1px solid "+mixHex(r,12),c.push(e)}m=E("div",{style:"position:absolute;left:5%;top:"+("mega-menu"===i?"37%":"24%")+";right:5%;bottom:0;"},p)}const y=E("div",{style:"position:absolute;inset:0;overflow:hidden;"},c.concat([m]));return y.style.background=o,y},buildDuo=(e,t)=>{const i=buildMini(e&&e.dark||{},t);return i.style.clipPath="polygon(58% 0, 100% 0, 100% 100%, 42% 100%)",E("div",{style:"position:relative;width:100%;height:100%;"},[buildMini(e&&e.light||{},t),i])};return baseclass.extend({safeHex:safeHex,mixHex:mixHex,logoImage:logoImage,buildMini:buildMini,buildDuo:buildDuo});
|
||||
Reference in new issue
Block a user