From 8b8929dde0583a4772985170ee9557564edc6c37 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 23 Nov 2024 10:01:49 +0200 Subject: [PATCH] chore(docs): document css and optCss --- src/public/app/widgets/basic_widget.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/public/app/widgets/basic_widget.js b/src/public/app/widgets/basic_widget.js index 87bde16c7..33ade4cb4 100644 --- a/src/public/app/widgets/basic_widget.js +++ b/src/public/app/widgets/basic_widget.js @@ -65,11 +65,26 @@ class BasicWidget extends Component { return this; } + /** + * Sets the CSS attribute of the given name to the given value. + * + * @param {string} name the name of the CSS attribute to set (e.g. `padding-left`). + * @param {string} value the value of the CSS attribute to set (e.g. `12px`). + * @returns self for chaining. + */ css(name, value) { this.attrs.style += `${name}: ${value};`; return this; } + /** + * Sets the CSS attribute of the given name to the given value, but only if the condition provided is truthy. + * + * @param {boolean} condition `true` in order to apply the CSS, `false` to ignore it. + * @param {string} name the name of the CSS attribute to set (e.g. `padding-left`). + * @param {string} value the value of the CSS attribute to set (e.g. `12px`). + * @returns self for chaining. + */ optCss(condition, name, value) { if (condition) { return this.css(name, value);