-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcc.min.js
More file actions
1 lines (1 loc) · 1.41 KB
/
cc.min.js
File metadata and controls
1 lines (1 loc) · 1.41 KB
1
const loadStyle=e=>{const t=document.createElement("link");t.rel="stylesheet",t.type=type="text/css",t.href=e,document.head.appendChild(t)},addTitle=e=>{const t=document.createElement("div");t.setAttribute("class","container"),document.body.appendChild(t);const n=document.createElement("img");n.src="dark"===e.theme?"/svg/logo/monogram-white.svg":"/svg/logo/monogram-black.svg",n.alt="Creative Coding logo",t.appendChild(n);const d=document.createElement("div");d.setAttribute("class","title"),d.innerHTML=e.title,t.appendChild(d);const i=document.createElement("div");i.setAttribute("class","description");const c=document.createTextNode(e.description);i.appendChild(c),t.appendChild(i)},addLink=(e,t,n,d)=>{const i=document.createElement("a");i.setAttribute("class","link"),i.setAttribute("target","_blank"),i.href=t;const c=document.createTextNode(e);i.appendChild(c),d.appendChild(i);const o=document.createElement("img");o.src="dark"===n?"/svg/link/link-white.svg":"/svg/link/link-black.svg",o.alt="Creative Coding logo",i.appendChild(o)},addInfo=e=>{const t=document.createElement("div");t.setAttribute("class","info"),document.body.appendChild(t),addLink("Article",e.article,e.theme,t),addLink("Source",e.source,e.theme,t)},init=e=>{loadStyle("//fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;700&display=swap"),loadStyle("/cc.min.css"),document.body.classList.add(e.theme),addTitle(e),addInfo(e)};window.cc={init:init};