pico/docs/js/pico.docs.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

!function(){if(document.querySelector("aside nav").clientWidth<200)for(var e=document.querySelectorAll("aside details"),t=1;t<e.length;t++)e[t].removeAttribute("open")}(),function(){function a(e){if("light"==e)var t=f.button.on;else t=f.button.off;document.querySelector("html").setAttribute("data-theme",e);for(var r=document.querySelectorAll(f.selector),a=0;a<r.length;a++)r[a].innerHTML=t,r[a].setAttribute("aria-label",t.replace(/<[^>]*>?/gm,""));f.currentTheme=e}var f={button:{element:"BUTTON",class:"contrast switcher theme-switcher",on:"<i>Turn on dark mode</i>",off:"<i>Turn off dark mode</i>"},target:"body",selector:"button.theme-switcher",currentTheme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"};!function(){var e=document.createElement(f.button.element);e.className=f.button.class,document.querySelector(f.target).appendChild(e),a(f.currentTheme);for(var t=document.querySelectorAll(f.selector),r=0;r<t.length;r++)t[r].addEventListener("click",function(e){"light"==f.currentTheme?a("dark"):a("light")},!1)}()}(),function(){function r(e){event.preventDefault();var t,r,a=e.href.split("#");""!=a[1]&&(a=function(e){mobile=window.matchMedia("(max-width: 991.99px)"),mobile.matches||"docs"==e&&(e="start");return e}(a[1]),a=document.getElementById(a),r=a,t=Math.floor(r.getBoundingClientRect().top),window.scrollBy({top:t,left:0,behavior:"smooth"}))}!function(e){for(var t=0;t<e.length;t++)-1!=e[t].href.indexOf("#")&&e[t].addEventListener("click",function(e){r(e.target)},!1)}(document.querySelectorAll('a:not([href^="https://picocss.com"])'))}(),function(){function e(e){for(var t="",r="",a=0;a<e;a++)t+="<div>"+(a+1)+"</div>",r+=" &lt;<b>div</b>&gt;"+(a+1)+"&lt;/<b>div</b>&gt;\n";document.querySelector(f.targetGrid).innerHTML=t,document.querySelector(f.targetCode).innerHTML='&lt;<b>section</b> <i>class</i>=<u>"grid"</u>&gt;\n'+r+"&lt;/<b>section</b>&gt;"}var t,f={columnsCurrent:4,columnsMin:1,columnsMax:12,targetButtons:"#grids article",targetGrid:"#grids .grid",targetCode:"#grids pre code",selectorAdd:"#grids button.add",selectorRemove:"#grids button.remove"};(t=document.createElement("P")).innerHTML='<button class="secondary add"><svg xmlns="http://www.w3.org/2000/svg" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg> Add column</button><button class="secondary remove"><svg xmlns="http://www.w3.org/2000/svg" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg> Remove column</button>',document.querySelector(f.targetButtons).before(t),document.querySelector(f.selectorAdd).addEventListener("click",function(){f.columnsCurrent<f.columnsMax&&(f.columnsCurrent++,e(f.columnsCurrent))},!1),document.querySelector(f.selectorRemove).addEventListener("click",function(){f.columnsCurrent>f.columnsMin&&(f.columnsCurrent--,e(f.columnsCurrent))},!1)}(),function(){function c(e,t){!function(e,t){for(var r=document.querySelectorAll(s.selectorTheme+" .name"),a=0;a<r.length;++a)r[a].innerHTML=e.charAt(0).toUpperCase()+e.substring(1)+" ";for(var f=document.querySelectorAll(s.selectorTheme+" .c500"),a=0;a<f.length;++a)f[a].innerHTML=t[500];for(var o=document.querySelectorAll(s.selectorTheme+" .c600"),a=0;a<o.length;++a)o[a].innerHTML=t[600];for(var n=document.querySelectorAll(s.selectorTheme+" .c700"),a=0;a<n.length;++a)n[a].innerHTML=t[700];for(var c=document.querySelectorAll(s.selectorTheme+" .c600-outline-light"),a=0;a<c.length;++a)c[a].innerHTML=u(t[600],.125);for(var d=document.querySelectorAll(s.selectorTheme+" .c600-outline-dark"),a=0;a<d.length;++a)d[a].innerHTML=u(t[600],.25);for(var l=document.querySelectorAll(s.selectorTheme+" .inverse"),a=0;a<l.length;++a)l[a].innerHTML=t.inverse;var i='[data-theme="generated"] {--primary:'+t[600]+";--h4:"+t[700]+";--primary-hover:"+t[700]+";--primary-focus:"+u(t[600],.125)+";--pri