aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/main.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/assets/main.js b/assets/main.js
index bc5d65c..c83e4fc 100644
--- a/assets/main.js
+++ b/assets/main.js
@@ -272,3 +272,23 @@ function prettyPrintMonth(isoDate) {
function capitalize(str) {
return str.replace(/^\w/, function (c) { return c.toUpperCase() })
}
+
+/******************/
+/* Web components */
+/******************/
+
+/* Apply color given from attribute.
+ *
+ * This permits not to use the style attribute in HTML to respect a strict CSP policy.
+ */
+customElements.define(
+ 'colored-category',
+ class extends HTMLSpanElement {
+ constructor() {
+ super()
+ const span = this
+ span.style = `color: ${span.getAttribute('data-color')}`
+ }
+ },
+ { extends: 'span' }
+)