Skip to content

Commit

Permalink
style(braces): stroustrup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gh61 committed Nov 22, 2023
1 parent 7120c95 commit 5f986fb
Show file tree
Hide file tree
Showing 29 changed files with 222 additions and 107 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@typescript-eslint/lines-between-class-members": "off",
"@typescript-eslint/keyword-spacing": ["error", {"overrides": { "this": { "before": false }}}],
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/brace-style": ["error", "stroustrup"],

"react/jsx-filename-extension": "off",
"import/extensions": "off",
Expand Down
3 changes: 2 additions & 1 deletion src/controls/big-switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class HueBigSwitch extends LitElement {
this.checked = !this.reversed;
fireEvent(this, 'change');
});
} else {
}
else {
this._mc.on('swiperight', () => {
if (this.disabled) return;
this.checked = !this.reversed;
Expand Down
12 changes: 8 additions & 4 deletions src/controls/brightness-rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export class HueBrightnessRollup extends LitElement {
private onBarMouseDown(ev: MouseEvent | TouchEvent, isTouch: boolean) {
if (isTouch) {
this._clickPosition = new TouchPoint((<TouchEvent>ev).changedTouches[0]);
} else {
}
else {
this._clickPosition = new MousePoint((<MouseEvent>ev));
}

Expand All @@ -185,7 +186,8 @@ export class HueBrightnessRollup extends LitElement {
if (this._isMouseDown) {
if (!this._hasMouseMoved) {
this.toggleBar(!this._isOpened, false);
} else {
}
else {
this.toggleBar(false, true);
}
}
Expand All @@ -207,7 +209,8 @@ export class HueBrightnessRollup extends LitElement {
let currentPos: Point;
if (isTouch) {
currentPos = new TouchPoint((<TouchEvent>ev).changedTouches[0]);
} else {
}
else {
currentPos = new MousePoint(<MouseEvent>ev);
}

Expand Down Expand Up @@ -408,7 +411,8 @@ export class HueBrightnessRollup extends LitElement {
this.clearWheelTimeouts(false);
this.disconnectListeners();
this.toggleBar(false, true); // close bar
} else {
}
else {
// enable back
this.connectListeners();
}
Expand Down
3 changes: 2 additions & 1 deletion src/controls/color-temp-mode-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class HueColorTempModeSelector extends LitElement {
public selectPossibleMode() {
if (this.showColor) {
this.mode = 'color';
} else if (this.showTemp) {
}
else if (this.showTemp) {
this.mode = 'temp';
}
}
Expand Down
39 changes: 26 additions & 13 deletions src/controls/color-temp-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class HueColorWheelCache {
const dataUrl = canvas.toDataURL(); // we're using dataUrl, because in raw format, the image exceeds localStorage size limit
try {
localStorage.setItem(key, dataUrl);
} catch (e) {
}
catch (e) {
console.error(e);
}
}
Expand All @@ -40,7 +41,8 @@ class HueColorWheelCache {
dataUrl
};
}
} catch (e) {
}
catch (e) {
console.error(e);
}

Expand Down Expand Up @@ -82,7 +84,8 @@ export class HueColorTempPicker extends LitElement {
// if browser (or test engine) not support ResizeObserver
if (typeof ResizeObserver == 'undefined') {
this._ro = null;
} else {
}
else {
this._ro = new ResizeObserver(() => this.onResize());
}
}
Expand Down Expand Up @@ -182,7 +185,8 @@ export class HueColorTempPicker extends LitElement {
};
img.src = cacheItem.dataUrl!;

} else {
}
else {
const image = ctx.createImageData(2 * radius, 2 * radius);
const data = image.data;

Expand Down Expand Up @@ -232,7 +236,8 @@ export class HueColorTempPicker extends LitElement {
let point;
if ('changedTouches' in ev) {
point = new TouchPoint(ev.changedTouches[0]);
} else {
}
else {
point = new MousePoint(ev);
}

Expand All @@ -256,7 +261,8 @@ export class HueColorTempPicker extends LitElement {
public getColorAndValue(x: number, y: number, radius: number) {
if (this.mode == 'color') {
return this.getColorAndHSV(x, y, radius);
} else if (this.mode == 'temp') {
}
else if (this.mode == 'temp') {
return this.getTempAndKelvin(x, y, radius);
}

Expand Down Expand Up @@ -405,9 +411,11 @@ export class HueColorTempPicker extends LitElement {
const coef = (max / min) / 65;
if (t <= 0.1) {
addon = this.linearScale(t * 10, 0, coef);
} else if (t <= 0.97) {
}
else if (t <= 0.97) {
addon = coef - this.linearScale((t - 0.1) / 0.9, 0, 2 * coef);
} else {
}
else {
addon = -coef + this.linearScale((t - 0.97) / 0.03, 0, coef);
}

Expand All @@ -431,7 +439,8 @@ export class HueColorTempPicker extends LitElement {

if (midValue < targetValue) {
low = t;
} else {
}
else {
high = t;
}

Expand Down Expand Up @@ -523,7 +532,8 @@ export class HueColorTempPicker extends LitElement {
offset = maxOffset - offset;
if (lower) {
value -= offset / 360;
} else {
}
else {
value += offset / 360;
}
}
Expand Down Expand Up @@ -699,7 +709,8 @@ export class HueColorTempPickerMarker {
if ('hsv' in colorAndValue) {
const [hue, saturation, value] = colorAndValue.hsv;
this._color = new Color(hue, saturation, value, 1, 'hsv');
} else {
}
else {
const [red, green, blue] = colorAndValue.color;
this._color = new Color(red, green, blue);
}
Expand Down Expand Up @@ -745,7 +756,8 @@ export class HueColorTempPickerMarker {
public refresh() {
if (this.mode == 'temp') {
this.temp = this.temp;
} else {
}
else {
this.color = this.color;
}
}
Expand Down Expand Up @@ -861,7 +873,8 @@ export class HueColorTempPickerMarker {
if (this._isOff) {
this._markerG.style.color = 'rgb(0,0,0)';
this._iconPath.style.fill = Consts.LightColor.toString();
} else {
}
else {
this._markerG.style.color = this._color.toString();

// for temp view I want only one change of foreground in the middle of the wheel
Expand Down
3 changes: 2 additions & 1 deletion src/controls/dialog-light-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export class HueDialogLightTile extends HueDialogTile {
bfg.foreground.toString()
);
}
} else {
}
else {
this.style.removeProperty(
'--hue-light-background'
);
Expand Down
8 changes: 6 additions & 2 deletions src/controls/dialog-scene-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ export class HueDialogSceneTile extends HueDialogTile {
const animationMs = (HueDialogSceneTile.animationSeconds * 1000);
this._effectQueue.addEffect(0, () => sceneElement.classList.add('clicked'));
this._effectQueue.addEffect(3000, () => sceneElement.classList.add('unclicked'));
this._effectQueue.addEffect(animationMs, () => { sceneElement.classList.add('stop-color-animate'); sceneElement.classList.remove('clicked'); });
this._effectQueue.addEffect(50, () => { sceneElement.classList.remove('stop-color-animate', 'unclicked'); });
this._effectQueue.addEffect(animationMs, () => {
sceneElement.classList.add('stop-color-animate'); sceneElement.classList.remove('clicked');
});
this._effectQueue.addEffect(50, () => {
sceneElement.classList.remove('stop-color-animate', 'unclicked');
});
this._effectQueue.start();
}

Expand Down
27 changes: 18 additions & 9 deletions src/controls/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export class HueDialog extends IdLitElement {
this._lightDetailHistoryStep = new HueHistoryStep(show, hide, HueLightDetail.ElementName);
HueHistoryStateManager.instance.addStep(this._lightDetailHistoryStep);

} else if (this._selectedLight == ev.detail.lightContainer) {
}
else if (this._selectedLight == ev.detail.lightContainer) {
this.hideLightDetail();
}
}
Expand All @@ -118,7 +119,8 @@ export class HueDialog extends IdLitElement {
if (show) {
contentDiv.style.overflowY = 'hidden';
contentDiv.scrollBy({ top: contentDiv.scrollHeight, behavior: 'smooth' });
} else {
}
else {
contentDiv.style.overflowY = '';
}
}
Expand Down Expand Up @@ -160,7 +162,8 @@ export class HueDialog extends IdLitElement {

if (isBefore) {
tileScroller.scrollBy({ left: elStart - tileScrollerStart, behavior: 'smooth' });
} else {
}
else {
tileScroller.scrollBy({ left: elEnd - tileScrollerEnd, behavior: 'smooth' });
}
}
Expand Down Expand Up @@ -201,7 +204,8 @@ export class HueDialog extends IdLitElement {
const haRoot = haDom.length ? haDom[0].shadowRoot : null;
if (haRoot) {
haRoot.appendChild(this);
} else {
}
else {
document.body.appendChild(this);
}

Expand All @@ -218,7 +222,8 @@ export class HueDialog extends IdLitElement {
if (haDialog) {
// if dialog closed - will call onDialogClose event
haDialog.close();
} else {
}
else {
// no haDialog found - use legacy way
this.onDialogClose();
}
Expand Down Expand Up @@ -517,7 +522,8 @@ export class HueDialog extends IdLitElement {

this._lightDetailElement = detailElement;
}
} else if (throwError) {
}
else if (throwError) {
throw new Error('Cannot create backdrop and lightDetail. Surface not found.');
}
}
Expand Down Expand Up @@ -563,10 +569,12 @@ export class HueDialog extends IdLitElement {
const offColor = this._config.getOffColor();
if (!offColor.isThemeColor()) {
offBackground = new Background([offColor.getBaseColor()]);
} else {
}
else {
offBackground = null;
}
} else {
}
else {
offBackground = new Background([new Color(Consts.DialogOffColor)]);
}

Expand Down Expand Up @@ -594,7 +602,8 @@ export class HueDialog extends IdLitElement {
'--hue-text-color',
bfg.foreground.toString()
);
} else {
}
else {
this.style.removeProperty('--hue-text-color');
}
}
Expand Down
21 changes: 14 additions & 7 deletions src/controls/history-state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,17 @@ class HistoryStack {
this._pointer = i;
found = true;
break;
} else {
}
else {
// not found, but is on the path - should be exited
toExit.push(item);
}
}
if (!found) {
// clear items
toExit.length = 0;
} else {
}
else {
this.logState('Moved to ' + id);
return {
found,
Expand All @@ -243,7 +245,8 @@ class HistoryStack {
// clear items
toEnter.length = 0;
logMessage('NOT moved to ' + id);
} else {
}
else {
this.logState('Moved to ' + id);
}

Expand Down Expand Up @@ -305,16 +308,19 @@ export class HueHistoryStateManager {

// move to the current state
moveResult = this._states.moveTo(state.hueId);
} else if (state != null) {
}
else if (state != null) {
moveResult = this._states.moveToExternal(state);
if (!moveResult.found) {
// our stack is ruined, reset everything
moveResult = this._states.resetBeforeStart();
} else {
}
else {
// don't fire any functions
moveResult.found = false;
}
} else {
}
else {
// we're at the very beginning
moveResult = this._states.resetBeforeStart();
}
Expand Down Expand Up @@ -377,7 +383,8 @@ export class HueHistoryStateManager {

// save oldItem's position into newItem
newStep.position = replaceResult.oldItem?.position;
} else { // replace not possible, classic push
}
else { // replace not possible, classic push

// push it to stack
this._states.push(newStep);
Expand Down
Loading

0 comments on commit 5f986fb

Please sign in to comment.