diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 4cef06b..caa08e3 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -6,7 +6,7 @@ diff --git a/index.html b/index.html index 450f0fa..62b0470 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,15 @@ WIP: Obsiview - + @@ -27,8 +35,25 @@ + + - + \ No newline at end of file diff --git a/src/hashtag.mjs b/src/hashtag.mjs new file mode 100644 index 0000000..8deb453 --- /dev/null +++ b/src/hashtag.mjs @@ -0,0 +1,9 @@ +export class HashtagElement extends HTMLElement { + connectedCallback() { + const templateElement = document.getElementById("template-hashtag") + const instanceElement = templateElement.content.cloneNode(true) + + const shadow = this.attachShadow({ mode: "open" }) + shadow.appendChild(instanceElement) + } +} diff --git a/src/index.mjs b/src/index.mjs index e6d3f42..b9f124d 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -1,3 +1,7 @@ import {CardElement} from "./card.mjs" +import {WikilinkElement} from "./wikilink.mjs"; +import {HashtagElement} from "./hashtag.mjs"; customElements.define("x-card", CardElement) +customElements.define("x-wikilink", WikilinkElement) +customElements.define("x-hashtag", HashtagElement) diff --git a/src/page.mjs b/src/page.mjs index 2155b4d..7f95b7b 100644 --- a/src/page.mjs +++ b/src/page.mjs @@ -19,13 +19,13 @@ const marked = new Marked({ return { type: "wikilink", raw: match[0], - target: match[1], - display: match[2], + wref: match[1], + text: match[2], } } }, renderer(token) { - return `${token.display ?? token.target}` + return `${token.text ?? token.wref}` }, }, { @@ -45,7 +45,7 @@ const marked = new Marked({ } }, renderer(token) { - return `#${token.tag}` + return `#${token.tag}` } } ] diff --git a/src/wikilink.mjs b/src/wikilink.mjs new file mode 100644 index 0000000..3f9a86f --- /dev/null +++ b/src/wikilink.mjs @@ -0,0 +1,29 @@ +export class WikilinkElement extends HTMLElement { + /** + * Get the card this Wikilink points to via the `wref` attribute. + * + * @returns {String} The card target. + */ + getWikilinkWref() { + return this.getAttribute("wref") + } + + /** + * The clickable anchor resolving the Wikilink. + */ + anchorElement + + connectedCallback() { + const templateElement = document.getElementById("template-wikilink") + const instanceElement = templateElement.content.cloneNode(true) + + this.anchorElement = this.querySelector(".wikilink") + + this.title = this.getWikilinkWref() + + + + const shadow = this.attachShadow({ mode: "open" }) + shadow.appendChild(instanceElement) + } +} \ No newline at end of file diff --git a/style/dark.css b/style/dark.css index dbae388..e3a4542 100644 --- a/style/dark.css +++ b/style/dark.css @@ -1,6 +1,7 @@ @media (prefers-color-scheme: dark) { :root { - --color-background: #1E1E1E; - --color-foreground: #FFFFFF; + --color-background: #1e1e1e; + --color-foreground: #ffffff; + --color-accent: #ff7f00; } } diff --git a/style/index.css b/style/index.css index 8780628..8b13789 100644 --- a/style/index.css +++ b/style/index.css @@ -1,7 +1 @@ -@import "./light.css"; -@import "./dark.css"; -body { - background-color: var(--color-background); - color: var(--color-foreground); -} diff --git a/style/light.css b/style/light.css index cf304d0..3c0806e 100644 --- a/style/light.css +++ b/style/light.css @@ -1,6 +1,7 @@ @media (prefers-color-scheme: light) { :root { - --color-background: #FFFFFF; - --color-foreground: #1E1E1E; + --color-background: #ffffff; + --color-foreground: #1e1e1e; + --color-accent: #ff7f00; } }