UNPKG

jsonresume-theme-crewshin

Version:

A flat JSON Resume theme, compatible with the latest resume schema

308 lines (297 loc) 15.8 kB
"use strict";var y=Object.freeze,w=Object.defineProperty;var b=(t,i)=>y(w(t,"raw",{value:y(i||t.slice())}));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@rbardini/html"),D=require("micromark"),L=require("striptags"),k=require("feather-icons"),z=`const pluralize = (num, str) => \`\${num} \${num === 1 ? str : str.concat('s')}\` class TimeDuration extends HTMLElement { connectedCallback() { const [from, to] = this.querySelectorAll('time') if (!from) return const startDate = new Date(from.dateTime || from.textContent) const endDate = new Date(to ? to.dateTime || to.textContent : Date.now()) const diffDate = new Date(endDate - startDate) const years = diffDate.getFullYear() - 1970 const months = diffDate.getMonth() const days = diffDate.getDate() - 1 const segments = [ years && pluralize(years, 'yr'), months && pluralize(months, 'mo'), days && !years && !months && pluralize(days, 'day'), ].filter(Boolean) if (!segments.length) return const duration = document.createElement('time') duration.classList.add('duration') duration.textContent = '· '.concat(segments.join(' ')) this.append(' ', duration) } } customElements.define('time-duration', TimeDuration) `,C=':root{color-scheme:light dark;--color-background-light: #ffffff;--color-dimmed-light: #f3f4f5;--color-primary-light: #191e23;--color-secondary-light: #6c7781;--color-accent-light: #0073aa;--color-background-dark: #191e23;--color-dimmed-dark: #23282d;--color-primary-dark: #fbfbfc;--color-secondary-dark: #ccd0d4;--color-accent-dark: #00a0d2;--color-background: var(--color-background-light);--color-dimmed: var(--color-dimmed-light);--color-primary: var(--color-primary-light);--color-secondary: var(--color-secondary-light);--color-accent: var(--color-accent-light);--scale-ratio: 1.25;--scale0: 1rem;--scale1: calc(var(--scale0) * var(--scale-ratio));--scale2: calc(var(--scale1) * var(--scale-ratio));--scale3: calc(var(--scale2) * var(--scale-ratio));--scale4: calc(var(--scale3) * var(--scale-ratio));--scale5: calc(var(--scale4) * var(--scale-ratio))}@media (prefers-color-scheme: dark){:root{--color-background: var(--color-background-dark);--color-dimmed: var(--color-dimmed-dark);--color-primary: var(--color-primary-dark);--color-secondary: var(--color-secondary-dark);--color-accent: var(--color-accent-dark)}}*{box-sizing:border-box;margin:0;padding:0}html{font-size:14px}body{background:var(--color-background);color:var(--color-primary);display:grid;font:1em/1.5 Lato,sans-serif;gap:2em;grid-template-columns:[full-start] 1fr [main-start side-start] minmax(min-content,12em) [side-end content-start] minmax(min-content,36em) [main-end content-end] 1fr [full-end];grid-template-rows:auto [content] 0;margin-bottom:4em}body:before{content:"";grid-column:full;grid-row:content}ol,ul{padding-left:1em}:not(.icon-list,.tag-list)>li+li{margin-top:.4em}li::marker,.network{color:var(--color-secondary)}a{color:var(--color-accent);text-decoration:none}a:focus,a:hover{text-decoration:underline}h1,h2,h3,h5{font-weight:400}h1,h2,h3{line-height:1.2}h1{font-size:var(--scale5)}h2{color:var(--color-secondary);font-size:var(--scale4)}h3{color:var(--color-secondary);font-size:var(--scale3);grid-column:side;margin-bottom:1rem}h4{font-size:var(--scale2)}h5{font-size:var(--scale1)}h6{font-size:var(--scale0)}blockquote{border-left:.2em solid var(--color-dimmed);padding-left:1em}cite{color:var(--color-secondary);font-style:inherit}cite:before{content:"— "}svg{margin-right:.2em;vertical-align:text-bottom}.masthead{background:var(--color-dimmed);display:inherit;gap:inherit;grid-column:full;grid-template-columns:inherit;padding:4em 0;text-align:center}.masthead>*,section{grid-column:main}.masthead>img{border:4px solid;border-radius:50%;margin:0 auto;max-width:12em}article>*+*,blockquote>*+*,.timeline>div>*+*{margin-top:.6em}.meta{color:var(--color-secondary)}.stack{display:grid;gap:1.5em}.icon-list{display:flex;flex-wrap:wrap;gap:.4em 1em;justify-content:center;list-style:none;padding:0}.grid-list{display:grid;gap:1em}.tag-list{display:flex;flex-wrap:wrap;gap:.4em;list-style:none;padding:0}.tag-list>li{background:var(--color-dimmed);border-radius:.2em;padding:.2em .6em}.timeline>div{position:relative}.timeline>div:not(:last-child){padding-bottom:1rem}.timeline>div:not(:last-child):before{content:"";position:absolute;top:1rem;left:-15px;width:2px;height:100%;background:var(--color-secondary)}.timeline>div:not(:only-child):after{content:"";position:absolute;top:.6rem;left:-20px;width:8px;height:8px;background:var(--color-secondary);border:2px solid var(--color-background);border-radius:50%}@media print,(min-width: 48em){h3{text-align:right;margin-bottom:inherit}.masthead{text-align:inherit}.masthead>*,section{grid-column:content}.masthead img{grid-column:side;grid-row:span 2;max-width:100%}section{display:contents}.icon-list{flex-direction:column}.grid-list{grid-template-columns:repeat(auto-fit,minmax(calc((100% - 1em)/2),1fr))}}@media print{.duration{display:none}}';function j(t={}){const i=t.themeOptions?.colors;return i&&Object.entries(i).map(([n,[o,l=o]])=>`--color-${n}-light:${o}; --color-${n}-dark:${l};`).join(" ")}function s(t,i=!1){const n=D(t);return i?L(n):n}const q=t=>new Date(t).toLocaleDateString("en",{month:"short",year:"numeric",timeZone:"UTC"});function u(t){return e.html`<time datetime="${t}">${q(t)}</time>`}function I(t=[]){return t.length>0&&e.html` <section id="awards"> <h3>Awards</h3> <div class="stack"> ${t.map(({awarder:i,date:n,summary:o,title:l})=>e.html` <article> <header> <h4>${l}</h4> <div class="meta"> ${i&&e.html`<div>Awarded by <strong>${i}</strong></div>`} ${n&&u(n)} </div> </header> ${o&&s(o)} </article> `)} </div> </section> `}const T=t=>t.replace(/^(https?:|)\/\//,"").replace(/\/$/,"");function g(t,i){return i?t?e.html`<a href="${t}">${i}</a>`:i:t&&e.html`<a href="${t}">${T(t)}</a>`}function P(t=[]){return t.length>0&&e.html` <section id="certificates"> <h3>Certificates</h3> <div class="stack"> ${t.map(({date:i,issuer:n,name:o,url:l})=>e.html` <article> <header> <h4>${g(l,o)}</h4> <div class="meta"> ${n&&e.html`<div>Issued by <strong>${n}</strong></div>`} ${i&&u(i)} </div> </header> </article> `)} </div> </section> `}function p(t,i){return i===t?u(i):e.html`<time-duration>${u(t)}${i?u(i):"Present"}</time-duration>`}function R(t=[]){return t.length>0&&e.html` <section id="education"> <h3>Education</h3> <div class="stack"> ${t.map(({area:i,courses:n=[],institution:o,startDate:l,endDate:c,studyType:a,url:r})=>e.html` <article> <header> <h4>${g(r,o)}</h4> <div class="meta"> ${i&&e.html`<strong>${i}</strong>`} ${l&&e.html`<div>${p(l,c)}</div>`} </div> </header> ${a&&s(a)} ${n.length>0&&e.html` <h5>Courses</h5> <ul> ${n.map(d=>e.html`<li>${s(d)}</li>`)} </ul> `} </article> `)} </div> </section> `}function v(t,i){return(k.icons[t.toLowerCase()]||i&&k.icons[i.toLowerCase()])?.toSvg({width:16,height:16})}const S=t=>Intl.DisplayNames?new Intl.DisplayNames(["en"],{type:"region"}).of(t):t;function E(t={}){const{email:i,image:n,label:o,location:l,name:c,phone:a,profiles:r=[],summary:d,url:m}=t;return e.html` <header class="masthead"> ${n&&e.html`<img src="${n}" alt="" />`} <div>${c&&e.html`<h1>${c}</h1>`} ${o&&e.html`<h2>${o}</h2>`}</div> ${d&&e.html`<article>${s(d)}</article>`} <ul class="icon-list"> ${l?.city&&e.html` <li> ${v("map-pin")} ${l.city}${l.countryCode&&e.html`, ${S(l.countryCode)}`} </li> `} ${i&&e.html` <li> ${v("mail")} <a href="mailto:${i}">${i}</a> </li> `} ${a&&e.html` <li> ${v("phone")} <a href="tel:${a.replace(/\s/g,"")}">${a}</a> </li> `} ${m&&e.html`<li>${v("link")} ${g(m)}</li>`} ${r.map(({network:h,url:$,username:f})=>e.html` <li> ${h&&v(h,"user")} ${g($,f)} ${h&&e.html`<span class="network">(${h})</span>`} </li> `)} </ul> </header> `}function O(t=[]){return t.length>0&&e.html` <section id="interests"> <h3>Interests</h3> <div class="grid-list"> ${t.map(({keywords:i=[],name:n})=>e.html` <div> ${n&&e.html`<h4>${n}</h4>`} ${i.length>0&&e.html` <ul class="tag-list"> ${i.map(o=>e.html`<li>${o}</li>`)} </ul> `} </div> `)} </div> </section> `}function A(t=[]){return t.length>0&&e.html` <section id="languages"> <h3>Languages</h3> <div class="grid-list"> ${t.map(({fluency:i,language:n})=>e.html`<div>${n&&e.html`<h4>${n}</h4>`} ${i}</div>`)} </div> </section> `}function M(t={}){const{name:i,summary:n}=t;return e.html` ${i&&e.html`<title>${i}</title>`} ${n&&e.html`<meta name="description" content="${s(n,!0)}" />`} `}const F=t=>Intl.ListFormat?new Intl.ListFormat("en").format(t):t.join(", ");function W(t=[]){return t.length>0&&e.html` <section id="projects"> <h3>Projects</h3> <div class="stack"> ${t.map(({description:i,entity:n,highlights:o=[],keywords:l=[],name:c,startDate:a,endDate:r,roles:d=[],type:m,url:h})=>e.html` <article> <header> <h4>${g(h,c)}</h4> <div class="meta"> <div> ${d.length>0&&e.html`<strong>${F(d)}</strong>`} ${n&&e.html`at <strong>${n}</strong>`} </div> ${a&&e.html`<div>${p(a,r)}</div>`} ${m&&e.html`<div>${m}</div>`} </div> </header> ${i&&s(i)} ${o.length>0&&e.html` <ul> ${o.map($=>e.html`<li>${s($)}</li>`)} </ul> `} ${l.length>0&&e.html` <ul class="tag-list"> ${l.map($=>e.html`<li>${$}</li>`)} </ul> `} </article> `)} </div> </section> `}function B(t=[]){return t.length>0&&e.html` <section id="publications"> <h3>Publications</h3> <div class="stack"> ${t.map(({name:i,publisher:n,releaseDate:o,summary:l,url:c})=>e.html` <article> <header> <h4>${g(c,i)}</h4> <div class="meta"> ${n&&e.html`<div>Published by <strong>${n}</strong></div>`} ${o&&u(o)} </div> </header> ${l&&s(l)} </article> `)} </div> </section> `}function H(t=[]){return t.length>0&&e.html` <section id="references"> <h3>References</h3> <div class="stack"> ${t.map(({name:i,reference:n})=>e.html` <blockquote> ${n&&s(n)} ${i&&e.html` <p> <cite>${i}</cite> </p> `} </blockquote> `)} </div> </section> `}function N(t=[]){return t.length>0&&e.html` <section id="skills"> <h3>Skills</h3> <div class="grid-list"> ${t.map(({keywords:i=[],name:n})=>e.html` <div> ${n&&e.html`<h4>${n}</h4>`} ${i.length>0&&e.html` <ul class="tag-list"> ${i.map(o=>e.html`<li>${o}</li>`)} </ul> `} </div> `)} </div> </section> `}function U(t=[]){return t.length>0&&e.html` <section id="volunteer"> <h3>Volunteer</h3> <div class="stack"> ${t.map(({highlights:i=[],organization:n,position:o,startDate:l,endDate:c,summary:a,url:r})=>e.html` <article> <header> <h4>${g(r,n)}</h4> <div class="meta"> <strong>${o}</strong> ${l&&e.html`<div>${p(l,c)}</div>`} </div> </header> ${a&&s(a)} ${i.length>0&&e.html` <ul> ${i.map(d=>e.html`<li>${s(d)}</li>`)} </ul> `} </article> `)} </div> </section> `}function V(t=[]){const i=t.reduce((n,{description:o,name:l,url:c,...a})=>{const r=n[n.length-1];return r&&r.name===l&&r.description===o&&r.url===c?r.items.push(a):n.push({description:o,name:l,url:c,items:[a]}),n},[]);return t.length>0&&e.html` <section id="work"> <h3>Work</h3> <div class="stack"> ${i.map(({description:n,name:o,url:l,items:c=[]})=>e.html` <article> <header> <h4>${g(l,o)}</h4> <div class="meta">${n&&e.html`<div>${n}</div>`}</div> </header> <div class="timeline"> ${c.map(({highlights:a=[],location:r,position:d,startDate:m,endDate:h,summary:$})=>e.html` <div> <div> <h5>${d}</h5> <div class="meta"> ${m&&e.html`<div>${p(m,h)}</div>`} ${r&&e.html`<div>${r}</div>`} </div> </div> ${$&&s($)} ${a.length>0&&e.html` <ul> ${a.map(f=>e.html`<li>${s(f)}</li>`)} </ul> `} </div> `)} </div> </article> `)} </div> </section> `}var x;function Y(t,{css:i,js:n}={}){return e.html`<!doctype html> <html lang="en" style="${j(t.meta)}"> <head> <meta charset="utf-8" /> ${M(t.basics)} <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700&display=swap" /> ${i&&e.html`<style> ${i} </style>`} ${n&&e.html(x||(x=b([`<script type="module"> `,` <\/script>`])),n)} </head> <body> ${E(t.basics)} ${V(t.work)} ${U(t.volunteer)} ${R(t.education)} ${W(t.projects)} ${I(t.awards)} ${P(t.certificates)} ${B(t.publications)} ${N(t.skills)} ${A(t.languages)} ${O(t.interests)} ${H(t.references)} </body> </html>`}const Z={mediaType:"print",printBackground:!0},G=t=>Y(t,{css:C,js:z});exports.pdfRenderOptions=Z;exports.render=G;