From 7949fcdc683d07689bad5da5d20bfa3eeb5a6a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Sep 2023 01:25:00 +0200 Subject: Move frontend code to subdirectories, to simplify command line flags. --- static/ts/components/changelog.ts | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 static/ts/components/changelog.ts (limited to 'static/ts/components/changelog.ts') diff --git a/static/ts/components/changelog.ts b/static/ts/components/changelog.ts new file mode 100644 index 00000000..d08f7cb3 --- /dev/null +++ b/static/ts/components/changelog.ts @@ -0,0 +1,49 @@ +import { makeElement } from '../lib' +import { ComponentVEvent } from './vevent' +import { VEvent } from '../vevent' + +export { VEventChangelog } + +class VEventChangelog extends ComponentVEvent { + + readonly ul: HTMLElement + + constructor(uid?: string) { + super(uid); + + this.ul = makeElement('ul'); + } + + connectedCallback() { + this.replaceChildren(this.ul); + } + + redraw(data: VEvent) { + /* TODO only redraw what is needed */ + let children = [] + for (let [_, el] of data.changelog) { + let msg = ''; + switch (el.type) { + case 'property': + msg += `change ${el.name}: ` + msg += `from "${el.from}" to "${el.to}"` + break; + case 'calendar': + if (el.from === null && el.to === null) { + msg += '???' + } else if (el.from === null) { + msg += `set calendar to "${atob(el.to!)}"` + } else if (el.to === null) { + msg += `Remove calendar "${atob(el.from)}"` + } else { + msg += `Change calendar from "${atob(el.from)}" to "${atob(el.to)}"` + } + break; + } + + children.push(makeElement('li', { textContent: msg })); + } + + this.ul.replaceChildren(...children) + } +} -- cgit v1.2.3 From f653a01328be3b8be6af35c0c96867623765ca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Sep 2023 11:41:46 +0200 Subject: Move JS documentation into the JS-code. Texinfo was a bad match for how TypeScript is structured. This also allows generation of jsdoc pages, which can be nice. Another large win is that this opens up for the texinfo pages to replace the Guile heading with different subheadings, including - external library - internal library - C library - ... --- static/ts/components/changelog.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'static/ts/components/changelog.ts') diff --git a/static/ts/components/changelog.ts b/static/ts/components/changelog.ts index d08f7cb3..720d1656 100644 --- a/static/ts/components/changelog.ts +++ b/static/ts/components/changelog.ts @@ -1,3 +1,14 @@ +/** + * `` + * + * Display of a VEvents changelog. @ref{ChangeLogEntry} + * + * @privateRemarks @anchor{VEventChangelog} + * + * @category Web Components + * @mergeTarget components + * @module + */ import { makeElement } from '../lib' import { ComponentVEvent } from './vevent' import { VEvent } from '../vevent' -- cgit v1.2.3 From e753d721519f72014241b3d2fc804a919f655769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 7 Sep 2023 02:58:41 +0200 Subject: Document remaining javascript items. --- static/ts/components/changelog.ts | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'static/ts/components/changelog.ts') diff --git a/static/ts/components/changelog.ts b/static/ts/components/changelog.ts index 720d1656..8f8adc1c 100644 --- a/static/ts/components/changelog.ts +++ b/static/ts/components/changelog.ts @@ -1,32 +1,43 @@ /** - * `` - * - * Display of a VEvents changelog. @ref{ChangeLogEntry} - * - * @privateRemarks @anchor{VEventChangelog} - * - * @category Web Components - * @mergeTarget components - * @module - */ + `` + + Display of a VEvents changelog. @ref{ChangeLogEntry} + + TODO rename this file! + + + @privateRemarks @anchor{VEventChangelog} + + @category Web Components + @mergeTarget components + @module +*/ import { makeElement } from '../lib' import { ComponentVEvent } from './vevent' import { VEvent } from '../vevent' export { VEventChangelog } +/** + Component displaying veevents changelog. + + This component is dumb, and (almost) doesn't keep any internal state. Instead + other parts of the program should call it with a `VEvent`, which contains the + actual changelog. +*/ class VEventChangelog extends ComponentVEvent { - readonly ul: HTMLElement + /** The list holding the changelog */ + readonly #ul: HTMLElement constructor(uid?: string) { super(uid); - this.ul = makeElement('ul'); + this.#ul = makeElement('ul'); } connectedCallback() { - this.replaceChildren(this.ul); + this.replaceChildren(this.#ul); } redraw(data: VEvent) { @@ -55,6 +66,6 @@ class VEventChangelog extends ComponentVEvent { children.push(makeElement('li', { textContent: msg })); } - this.ul.replaceChildren(...children) + this.#ul.replaceChildren(...children) } } -- cgit v1.2.3