add more styles and use icons in theme

This commit is contained in:
Reorx 2023-02-05 23:23:45 +08:00
parent d3c4bf38d6
commit fd9a90c4f3
5 changed files with 127 additions and 13 deletions

View File

@ -4,7 +4,10 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
<title>CV</title>
</head>
<body>
<div class="cv-container"></div>

View File

@ -18,7 +18,7 @@ const getIconsData = function(prefix) {
throw new Error(`Icon set ${prefix} is not included.`);
}
export const getIconSVG = function(name, { dom }) {
export const getIconSVG = function(name, { dom } = {}) {
const iconName = stringToIcon(name)
const icon = getIconData(getIconsData(iconName.prefix), iconName.name)
if (!icon) {

View File

@ -1,9 +1,37 @@
<!-- Basics -->
<h1><%= cv.basics.name %></h1>
<p><%= cv.basics.summary %></p>
<div class="contact">
<%= cv.basics.email %> | <%= cv.basics.phone %>
</div>
<section class="basics-section">
<h1><%= cv.basics.name %></h1>
<% if (cv.basics.label) { %>
<div class="label"><%= cv.basics.label %></div>
<% } %>
<% if (cv.basics.url) { %>
<div class="url">
<a href="<%= cv.basics.url %>"><%= fn.urlNoSchema(cv.basics.url) %></a></div>
<% } %>
<% if (cv.basics.summary) { %>
<div class="summary"><%= cv.basics.summary %></div>
<% } %>
<div class="contact">
<% if (cv.basics.email) { %>
<div class="item">
<%- fn.getIconSVG('mdi:email') %>
<span><a href="mailto:<%= cv.basics.email %>"><%= cv.basics.email %></a></span>
</div>
<% } %>
<% if (cv.basics.phone) { %>
<div class="item">
<%- fn.getIconSVG('mdi:phone') %>
<span><%= cv.basics.phone %></span>
</div>
<% } %>
<% if (cv.basics.location) { %>
<div class="item">
<%- fn.getIconSVG('mdi:location') %>
<span><%= cv.basics.location.city %>, <%= cv.basics.location.countryCode %></span>
</div>
<% } %>
</div>
</section>
<%
function dateRange(item, preserveDay) {
@ -21,7 +49,10 @@ function dateRange(item, preserveDay) {
<!-- Educations -->
<% if (cv.education) { %>
<section>
<h2>Educations</h2>
<div class="section-title">
<h2>Educations</h2>
<div class="line"></div>
</div>
<% for (const item of cv.education) { %>
<div class="education">
<h3><%= item.institution %></h3>
@ -37,7 +68,10 @@ function dateRange(item, preserveDay) {
<!-- Work -->
<% if (cv.work) { %>
<section>
<h2>Work</h2>
<div class="section-title">
<h2>Work</h2>
<div class="line"></div>
</div>
<% for (const item of cv.work) { %>
<div class="work">
<h3><%= item.name %></h3>
@ -58,7 +92,10 @@ function dateRange(item, preserveDay) {
<!-- Projects -->
<% if (cv.projects) { %>
<section>
<h2>Projects</h2>
<div class="section-title">
<h2>Projects</h2>
<div class="line"></div>
</div>
<% for (const item of cv.projects) { %>
<div class="project">
<h3><%= item.name %></h3>
@ -83,7 +120,10 @@ function dateRange(item, preserveDay) {
<!-- Side-projects -->
<% if (cv.sideProjects) { %>
<section>
<h2>Side-projects</h2>
<div class="section-title">
<h2>Side-projects</h2>
<div class="line"></div>
</div>
<% for (const item of cv.sideProjects) { %>
<div class="sideproject">
<h3><%= item.name %></h3>
@ -103,7 +143,10 @@ function dateRange(item, preserveDay) {
<!-- Skills -->
<% if (cv.skills) { %>
<section>
<h2>Skills</h2>
<div class="section-title">
<h2>Skills</h2>
<div class="line"></div>
</div>
<% for (const item of cv.skills) { %>
<div class="skill">
<h3><%= item.name %></h3>
@ -121,7 +164,10 @@ function dateRange(item, preserveDay) {
<!-- Languages -->
<% if (cv.languages) { %>
<section>
<h2>Languages</h2>
<div class="section-title">
<h2>Languages</h2>
<div class="line"></div>
</div>
<% for (const item of cv.languages) { %>
<div class="language">
<h3><%= item.language %></h3>

View File

@ -1,5 +1,61 @@
$color-signature: #2A3FFB;
$color-text-dim: #777;
.cv-container {
font-size: 14px;
font-family: system-ui, sans-serif;
a, a:visited, a:hover, a:active {
color: $color-signature;
text-decoration: none;
}
}
.basics-section {
h1 {
font-size: 36px;
font-weight: 600;
margin: .8em 0 .2em 0;
}
.label {
margin: .4em 0;
}
.url {
margin: .4em 0;
}
.summary {
margin: .4em 0;
}
.contact {
margin: .4em 0;
color: $color-text-dim;
display: flex;
.item {
margin-right: 1em;
a {
color: $color-text-dim;
}
svg {
vertical-align: bottom;
}
}
}
}
.section-title {
margin-top: 3em;
display: flex;
h2 {
font-size: 22px;
font-weight: 600;
color: $color-signature;
margin: 0;
}
.line {
flex-grow: 1;
margin: 14px 0 0 1em;
height: 2px;
background-color: $color-signature;
}
}

View File

@ -1,6 +1,7 @@
import ejs from 'ejs';
import { reformatDate } from '../lib/date';
import { getIconSVG } from '../lib/icons';
const themes = {}
@ -35,6 +36,8 @@ export function renderTheme(template, data, options) {
cv: data,
fn: {
reformatDate,
getIconSVG,
urlNoSchema,
}
}, options)
}
@ -52,3 +55,9 @@ export function applyThemeTo(name, el, data) {
}
elStyle.innerHTML = theme.style
}
/* fn */
function urlNoSchema(url) {
return url.replace(/https?:\/\//, '')
}