From 4dcb37ef6df04f41813fb329847f6c90fbdb2ab1 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Thu, 3 Dec 2020 15:36:01 +0100 Subject: [PATCH] add pure Comment to options system --- src/gui/css/options.css | 2 +- src/gui/options/options.js | 45 ++++++++++++++++++++++++++++++++++++-- themes/light/options.css | 2 +- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/gui/css/options.css b/src/gui/css/options.css index fc2ad5bced6..baea93813c6 100644 --- a/src/gui/css/options.css +++ b/src/gui/css/options.css @@ -20,7 +20,7 @@ div.options-group div.button-group { margin: 6px 0; } -div.options-group span.comment { +div.options-group .comment { color: gray; font-style: italic; margin-left: 10px; diff --git a/src/gui/options/options.js b/src/gui/options/options.js index a70c53a33f3..16429633e06 100644 --- a/src/gui/options/options.js +++ b/src/gui/options/options.js @@ -303,6 +303,32 @@ App.UI.OptionsGroup = (function() { } } + class Comment extends Row { + + /** + * @param {string} comment can be SC markup + */ + constructor(comment) { + super(); + this.comment = comment; + this.long = false; + } + + /** + * @param {HTMLDivElement} container + */ + render(container) { + /* left */ + container.append(document.createElement("div")); + + /* right */ + const comment = document.createElement("div"); + comment.classList.add("comment"); + $(comment).wiki(this.comment); + container.append(comment); + } + } + return class { constructor() { /** @@ -319,6 +345,17 @@ App.UI.OptionsGroup = (function() { return this; } + /** + * @template {Row} T + * @param {T} row + * @returns {T} + * @private + */ + _addRow(row) { + this.rows.push(row); + return row; + } + /** * @param {string} name * @param {string} property @@ -327,8 +364,12 @@ App.UI.OptionsGroup = (function() { */ addOption(name, property, object = V) { const option = new Option(name, property, object); - this.rows.push(option); - return option; + return this._addRow(option); + } + + addComment(comment) { + const c = new Comment(comment); + return this._addRow(c); } render() { diff --git a/themes/light/options.css b/themes/light/options.css index 88e25e7e362..419ff6ed927 100644 --- a/themes/light/options.css +++ b/themes/light/options.css @@ -1,3 +1,3 @@ -div.options-group span.comment { +div.options-group .comment { color: #575757; } -- GitLab