Skip to content

Commit

Permalink
chore(docs): document css and optCss
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Nov 23, 2024
1 parent e0d9cda commit 8b8929d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/public/app/widgets/basic_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b8929d

Please sign in to comment.