Skip to content

Commit

Permalink
feat(jsdoc): update docs with new theme/mode change strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Jul 28, 2021
1 parent 7603ae9 commit 5274605
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/core/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ export class UIPRoot extends ESLBaseElement {
public static is = 'uip-root';
private _model = new UIPStateModel();

/**
* Attribute for controlling UIP components' layout.
* Has two values: `vertical` and `horizontal`.
*/
@attr() public mode: string;
/**
* Attribute for controlling UIP components' theme.
* Has two values: `uip-light` and `uip-dark`.
*/
@attr() public theme: string;

static get observedAttributes() {
Expand Down
7 changes: 5 additions & 2 deletions src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface EditorConfig {
wrap?: number | boolean;
}

/** Interface to represent {@link UIPEditor's} theme. */
interface Theme {
[index: string]: string;
}
Expand All @@ -34,11 +35,11 @@ export class UIPEditor extends UIPPlugin {
/** Default [config]{@link EditorConfig} instance. */
public static defaultOptions: EditorConfig = {
theme: 'ace/theme/chrome',
mode: 'ace/mode/html',
printMarginColumn: -1,
wrap: true,
};

/** Object to map dark/light themes to [Ace]{@link https://ace.c9.io/} themes. */
static themesMapping: Theme = {
'uip-light': 'ace/theme/chrome',
'uip-dark': 'ace/theme/tomorrow_night'
Expand All @@ -47,7 +48,7 @@ export class UIPEditor extends UIPPlugin {
/** Editor's [config]{@link EditorConfig} passed through attribute. */
@jsonAttr()
public editorConfig: EditorConfig;
/** Wrapped ACE editor instance. */
/** Wrapped [Ace]{@link https://ace.c9.io/} editor instance. */
protected editor: Ace.Editor;

/** {@link editorConfig} merged with {@link defaultOptions}. */
Expand Down Expand Up @@ -82,6 +83,7 @@ export class UIPEditor extends UIPPlugin {

this.editor = edit(this.$inner);
this.editor.setOption('useWorker', false);
this.editor.setOption('mode', 'ace/mode/html');

this.initEditorOptions();
}
Expand Down Expand Up @@ -113,6 +115,7 @@ export class UIPEditor extends UIPPlugin {
this.initEditorOptions();
}

/** Callback to catch theme changes from {@link UIPRoot}. */
@bind
protected _onRootConfigChange(e: CustomEvent) {
if (e.detail.attribute !== 'theme') return false;
Expand Down
8 changes: 4 additions & 4 deletions src/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export class UIPOptions extends UIPPlugin {
static is = 'uip-options';

/**
* Attribute for controlling UIP components layout.
* Has two values: vertical and horizontal.
* Attribute for controlling UIP components' layout.
* Has two values: `vertical` and `horizontal`.
*/
@attr({defaultValue: 'vertical'}) public mode: string;
/**
* Attribute for controlling UIP components theme.
* Has two values: uip-light and uip-dark.
* Attribute for controlling UIP components' theme.
* Has two values: `uip-light` and `uip-dark`.
*/
@attr({defaultValue: 'uip-light'}) public theme: string;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/token-list/token-list-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class TokenListUtils {
return Array.from(arrays.reduce((intersect, arr) => {
arr.forEach(val => !intersect.has(val) && intersect.delete(val));
return intersect;
}, new Set(arrays[0]))) as T[];
}, new Set(arrays[0])));
}

/** Remove all element appearances from array. */
Expand Down

0 comments on commit 5274605

Please sign in to comment.