Initial Commit

This commit is contained in:
2018-09-13 21:15:47 +02:00
commit 09f406cba7
84 changed files with 6920 additions and 0 deletions
@@ -0,0 +1,52 @@
const moment = require("moment")
module.exports = class {
onCreate({kind, weak, value, updated}) {
this.state = {text: null, color: "color-menu", href: null, tooltip: null}
if (value == null || value == "") {
return
}
switch (kind) {
case "date": {
const m = moment(value)
if (m.year() < 2) {
break
}
if (!weak) {
this.state.tooltip = `See all stories set during ${m.format("MMMM YYYY")}`
this.state.href = `/story/by-month/${m.format("YYYY-MM")}/`
}
const dateStr = m.format("MMM D, YYYY")
this.state.text = dateStr
if (updated != null && Date.parse(updated) > Date.parse(value)) {
const m2 = moment(updated)
this.state.tooltip = "Originally posted: " + dateStr
this.state.text = m2.format("MMM D, YYYY") + " *"
}
break
}
case "author": {
this.state.text = value
this.state.tooltip = "See all stories by " + value
this.state.href = `/story/by-author/${value}/`
break
}
default: {
this.state.color = "color-menu"
this.state.text = value
break
}
}
}
}
@@ -0,0 +1,6 @@
<if(state.text != null && state.text != "")>
<div class=["chapter-meta", input.kind, state.color, input.weak ? "weak" : null] title=state.tooltip>
<a if(state.href != null) href=state.href>${state.text}</a>
<span else>${state.text}</span>
</div>
</if>
@@ -0,0 +1,20 @@
div.chapter-meta {
display: inline-block;
padding: 0;
padding-right: 1em;
margin: 0;
user-select: none;
a {
color: inherit;
border-bottom: 0.25px dotted;
}
a:hover {
border-bottom: 0.5px solid;
}
}
div.chapter-meta.weak {
opacity: 0.5;
}