Skip to content

Commit b7b99de

Browse files
ert78gbmondalaci
andauthored
feat: change position of module config icon (#2209)
* feat: change position of module config icon * Adjust the positions of module configuration circle buttons. --------- Co-authored-by: László Monda <[email protected]>
1 parent c6abe45 commit b7b99de

File tree

20 files changed

+60
-53
lines changed

20 files changed

+60
-53
lines changed

packages/uhk-common/src/config-serializer/config-items/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export * from './module-configuration.js';
2121
export * from './mouse-speed-configuration.js';
2222
export * from './rgb-color.js';
2323
export * from './svg-keyboard-cover-colors.js';
24+
export * from './uhk-theme-colors.js';
2425
export * from './user-configuration.js';

packages/uhk-common/src/config-serializer/config-items/layer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { assertEnum } from '../assert.js';
44
import { Macro } from './macro.js';
55
import { Module } from './module.js';
66
import { SerialisationInfo } from './serialisation-info.js';
7-
import { SvgKeyboardCoverColors } from './svg-keyboard-cover-colors.js';
7+
import { UhkThemeColors } from './uhk-theme-colors.js';
88
import { UserConfiguration } from './user-configuration.js';
99
import { LayerName } from './layer-name.js';
1010

@@ -14,15 +14,15 @@ export class Layer {
1414

1515
modules: Module[];
1616

17-
svgKeyboardCoverColors: SvgKeyboardCoverColors;
17+
uhkThemeColors: UhkThemeColors;
1818

1919
constructor(layers?: Layer) {
2020
if (!layers) {
2121
return;
2222
}
2323
this.id = layers.id;
2424
this.modules = layers.modules.map(module => new Module(module));
25-
this.svgKeyboardCoverColors = layers.svgKeyboardCoverColors;
25+
this.uhkThemeColors = layers.uhkThemeColors;
2626
}
2727

2828
fromJsonObject(jsonObject: any, macros: Macro[], serialisationInfo: SerialisationInfo): Layer {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { SvgKeyboardCoverColors } from './svg-keyboard-cover-colors.js';
2+
3+
export interface UhkThemeColors {
4+
backgroundColor: string;
5+
svgKeyboardCoverColors: SvgKeyboardCoverColors;
6+
}

packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[keyboardLayout]="keyboardLayout"
1111
[description]="description"
1212
[showDescription]="true"
13-
[svgKeyboardCoverColors]="aLayer.svgKeyboardCoverColors"
13+
[uhkThemeColors]="aLayer.uhkThemeColors"
1414
[lastEditedKey]="lastEditedKey"
1515
oncontextmenu="return false;"
1616
(keyClick)="keyClick.emit($event)"
@@ -34,7 +34,7 @@
3434
[keyboardLayout]="keyboardLayout"
3535
[description]="description"
3636
[showDescription]="true"
37-
[svgKeyboardCoverColors]="bLayer.svgKeyboardCoverColors"
37+
[uhkThemeColors]="bLayer.uhkThemeColors"
3838
[lastEditedKey]="lastEditedKey"
3939
oncontextmenu="return false;"
4040
(keyClick)="keyClick.emit($event)"

packages/uhk-web/src/app/components/popover/popover.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
[defaultKeyAction]="defaultKeyAction"
5050
[keymaps]="keymaps$ | async"
5151
[keymapOptions]="keymapOptions$ | async"
52-
[svgKeyboardCoverColors]="svgKeyboardCoverColors$ | async"
52+
[uhkThemeColors]="uhkThemeColors$ | async"
5353
(validAction)="setKeyActionValidState($event)"
5454
></keymap-tab>
5555
<none-tab #tab *ngSwitchCase="tabName.None" class="popover-content"

packages/uhk-web/src/app/components/popover/popover.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
MouseAction,
2525
PlayMacroAction,
2626
SecondaryRoleAction,
27-
SvgKeyboardCoverColors,
27+
UhkThemeColors,
2828
SwitchKeymapAction,
2929
SwitchLayerAction
3030
} from 'uhk-common';
@@ -37,7 +37,7 @@ import {
3737
getKeymapOptions,
3838
getKeymaps,
3939
getLayerOptions,
40-
getSvgKeyboardCoverColorsOfTheme,
40+
getUhkThemeColors,
4141
macroPlaybackSupported
4242
} from '../../store';
4343
import { KeyActionRemap } from '../../models/key-action-remap';
@@ -87,7 +87,7 @@ export class PopoverComponent implements OnChanges {
8787
tabName = TabName;
8888
keyActionValid: boolean;
8989
activeTab: TabName;
90-
svgKeyboardCoverColors$: Observable<SvgKeyboardCoverColors>;
90+
uhkThemeColors$: Observable<UhkThemeColors>;
9191
keymaps$: Observable<Keymap[]>;
9292
keymapOptions$: Observable<SelectOptionData[]>;
9393
shadowKeyAction: KeyAction;
@@ -130,7 +130,7 @@ export class PopoverComponent implements OnChanges {
130130

131131
constructor(private store: Store<AppState>,
132132
private cdRef: ChangeDetectorRef) {
133-
this.svgKeyboardCoverColors$ = store.select(getSvgKeyboardCoverColorsOfTheme);
133+
this.uhkThemeColors$ = store.select(getUhkThemeColors);
134134
this.keymaps$ = store.select(getKeymaps);
135135
this.keymapOptions$ = store.select(getKeymapOptions);
136136
this.macroPlaybackSupported$ = store.select(macroPlaybackSupported);

packages/uhk-web/src/app/components/popover/tab/keymap/keymap-tab.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<svg-keyboard *ngIf="selectedKeymap?.abbreviation"
3535
[moduleConfig]="selectedKeymap.layers[0].modules"
3636
[embedded]="true"
37-
[svgKeyboardCoverColors]="svgKeyboardCoverColors"
37+
[uhkThemeColors]="uhkThemeColors"
3838
>
3939
</svg-keyboard>
4040
</div>

packages/uhk-web/src/app/components/popover/tab/keymap/keymap-tab.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
2-
import { copyRgbColor, Keymap, KeyAction, SvgKeyboardCoverColors, SwitchKeymapAction } from 'uhk-common';
2+
import { copyRgbColor, Keymap, KeyAction, UhkThemeColors, SwitchKeymapAction } from 'uhk-common';
33

44
import { Tab } from '../tab';
55
import { SelectOptionData } from '../../../../models/select-option-data';
@@ -14,7 +14,7 @@ export class KeymapTabComponent extends Tab implements OnChanges {
1414
@Input() defaultKeyAction: KeyAction;
1515
@Input() keymaps: Keymap[];
1616
@Input() keymapOptions: SelectOptionData[];
17-
@Input() svgKeyboardCoverColors: SvgKeyboardCoverColors;
17+
@Input() uhkThemeColors: UhkThemeColors;
1818

1919
selectedKeymap: Keymap;
2020

packages/uhk-web/src/app/components/svg/keyboard/svg-keyboard.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[selectedKey]="selectedKey"
2020
[@fadeKeyboard]="{value:'', params: { animationTime: modulesState[module.id].animationTime } }"
2121
[selected]="selectedKey?.moduleId === module.id"
22-
[svgKeyboardCoverColors]="svgKeyboardCoverColors"
22+
[uhkThemeColors]="uhkThemeColors"
2323
[lastEdited]="lastEditedKey?.moduleId === module.id"
2424
[lastEditedKeyId]="lastEditedKey?.key"
2525
(keyClick)="onKeyClick(module.id, $event)"

packages/uhk-web/src/app/components/svg/keyboard/svg-keyboard.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
LeftSlotModules,
2121
Module,
2222
RightSlotModules,
23-
SvgKeyboardCoverColors
23+
UhkThemeColors,
2424
} from 'uhk-common';
2525

2626
import { SvgModule } from '../module';
@@ -99,7 +99,7 @@ export class SvgKeyboardComponent implements AfterViewInit, OnInit, OnChanges {
9999
@Input() keyboardLayout = KeyboardLayout.ANSI;
100100
@Input() description: string;
101101
@Input() showDescription = false;
102-
@Input() svgKeyboardCoverColors: SvgKeyboardCoverColors;
102+
@Input() uhkThemeColors: UhkThemeColors;
103103
@Input() lastEditedKey: LastEditedKey;
104104
@Input() embedded = false;
105105
@Output() keyClick = new EventEmitter<SvgKeyboardKeyClickEvent>();

packages/uhk-web/src/app/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { KeyModifierModel } from '../../../../models/key-modifier-model';
4747
import { StartKeypressCapturingAction, StopKeypressCapturingAction } from '../../../../store/actions/app';
4848
import { KeyActionDragAndDropService } from '../../../../services/key-action-drag-and-drop.service';
4949
import { getColorsOf } from '../../../../util/get-colors-of';
50-
import { uhkThemeColors } from '../../../../util/uhk-theme-colors';
50+
import { defaultUhkThemeColors } from '../../../../util/default-uhk-theme-colors';
5151
import { keyboardGreyRgbColor } from '../../../../util/rgb-color-contants';
5252
import { SvgKeyboardKey } from './svg-keyboard-key.model';
5353

@@ -484,7 +484,7 @@ export class SvgKeyboardKeyComponent implements OnChanges, OnDestroy {
484484
: colors.backgroundColorAsHex;
485485
this.textColor = colors.fontColorAsHex;
486486

487-
const themeColors = uhkThemeColors();
487+
const themeColors = defaultUhkThemeColors();
488488

489489
this.strokeColor = isPerKeyBacklighting && colord(themeColors.backgroundColor).delta(this.keyAction) < 0.01
490490
? 'lightgray'

packages/uhk-web/src/app/components/svg/module/svg-module.component.html

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<svg:path *ngFor="let path of coverages"
22
[attr.d]="path.d"
3-
[attr.fill]="svgKeyboardCoverColors?.fillColor"
4-
[attr.stroke]="svgKeyboardCoverColors?.strokeColor"/>
3+
[attr.fill]="uhkThemeColors?.svgKeyboardCoverColors.fillColor"
4+
[attr.stroke]="uhkThemeColors?.svgKeyboardCoverColors.strokeColor"/>
55
<svg:circle *ngFor="let circle of circles"
66
[attr.cx]="circle.cx"
77
[attr.cy]="circle.cy"
88
[attr.r]="circle.r"
9-
[attr.fill]="svgKeyboardCoverColors?.fillColor"
10-
[attr.stroke]="svgKeyboardCoverColors?.strokeColor"/>
9+
[attr.fill]="uhkThemeColors?.svgKeyboardCoverColors.fillColor"
10+
[attr.stroke]="uhkThemeColors?.svgKeyboardCoverColors.strokeColor"/>
1111

1212
<svg:g class="module-nav" *ngIf="moduleNavPath && moduleNavCircle" (click)="navigateToModuleSettings.emit()">
1313
<svg:circle [attr.cx]="moduleNavCircle.cx"
1414
[attr.cy]="moduleNavCircle.cy"
1515
[attr.r]="moduleNavCircle.r"
16-
[attr.fill]="svgKeyboardCoverColors?.fillColor"
17-
[attr.stroke]="svgKeyboardCoverColors?.strokeColor"
16+
[attr.fill]="uhkThemeColors?.svgKeyboardCoverColors.fillColor"
17+
[attr.stroke]="uhkThemeColors.backgroundColor"
18+
[attr.stroke-width]="moduleNavCircle['stroke-width']"
1819
/>
1920
<svg:path [attr.d]="moduleNavPath.d" />
2021
</svg:g>

packages/uhk-web/src/app/components/svg/module/svg-module.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ChangeDetectionStrategy
88
} from '@angular/core';
99
import { Store } from '@ngrx/store';
10-
import { BacklightingMode, KeyAction, Macro, SvgKeyboardCoverColors } from 'uhk-common';
10+
import { BacklightingMode, KeyAction, Macro, UhkThemeColors } from 'uhk-common';
1111
import { Subscription } from 'rxjs';
1212

1313
import { SvgKeyboardKey } from '../keys';
@@ -33,7 +33,7 @@ export class SvgModuleComponent implements OnDestroy {
3333
@Input() keyActions: KeyAction[];
3434
@Input() selectedKey: { layerId: number, moduleId: number, keyId: number };
3535
@Input() selected: boolean;
36-
@Input() svgKeyboardCoverColors: SvgKeyboardCoverColors;
36+
@Input() uhkThemeColors: UhkThemeColors;
3737
@Input() capturingEnabled: boolean;
3838
@Input() lastEdited: boolean;
3939
@Input() lastEditedKeyId: string;

packages/uhk-web/src/app/store/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
LeftSlotModules,
2626
PlayMacroAction,
2727
RightSlotModules,
28-
SvgKeyboardCoverColors,
28+
UhkThemeColors,
2929
UHK_60_DEVICE,
3030
UhkBuffer,
3131
UserConfiguration,
@@ -48,7 +48,7 @@ import {
4848
} from '../models';
4949
import { PrivilagePageSate } from '../models/privilage-page-sate';
5050
import { SelectOptionData } from '../models/select-option-data';
51-
import { uhkThemeColors } from '../util/uhk-theme-colors';
51+
import { defaultUhkThemeColors } from '../util/default-uhk-theme-colors';
5252
import { addMissingModuleConfigs } from './reducers/add-missing-module-configs';
5353

5454
import * as fromAdvancedSettings from './reducers/advanced-settings.reducer';
@@ -181,8 +181,8 @@ export const getEverAttemptedSavingToKeyboard = createSelector(appState, fromApp
181181
export const getUdevFileContent = createSelector(appState, fromApp.getUdevFileContent);
182182
export const getAnimationEnabled = createSelector(appState, fromApp.getAnimationEnabled);
183183
export const getAppTheme = createSelector(appState, fromApp.getAppTheme);
184-
export const getSvgKeyboardCoverColorsOfTheme = createSelector(getAppTheme, (theme): SvgKeyboardCoverColors => {
185-
return uhkThemeColors(theme).svgKeyboardCoverColors;
184+
export const getUhkThemeColors = createSelector(getAppTheme, (theme): UhkThemeColors => {
185+
return defaultUhkThemeColors(theme);
186186
});
187187
export const getPlatform = createSelector(appState, fromApp.getPlatform);
188188

packages/uhk-web/src/app/util/uhk-theme-colors.ts renamed to packages/uhk-web/src/app/util/default-uhk-theme-colors.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { SvgKeyboardCoverColors } from 'uhk-common';
1+
import { UhkThemeColors } from 'uhk-common';
22

3-
export interface UhkThemeColors {
4-
backgroundColor: string;
5-
svgKeyboardCoverColors: SvgKeyboardCoverColors;
6-
}
7-
export function uhkThemeColors(theme = (window as any).getUhkTheme()): UhkThemeColors {
3+
export function defaultUhkThemeColors(theme = (window as any).getUhkTheme()): UhkThemeColors {
84
if (theme === 'dark') {
95
return {
10-
backgroundColor: '#000',
6+
backgroundColor: '#111',
117
svgKeyboardCoverColors: {
128
fillColor: '#333',
139
strokeColor: ''

packages/uhk-web/src/app/util/set-svg-keyboard-cover-colors-of-layer.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@ import { colord, extend } from 'colord';
22
import labPlugin from 'colord/plugins/lab';
33
import { BacklightingMode, Layer } from 'uhk-common';
44

5-
import { uhkThemeColors } from './uhk-theme-colors';
5+
import { defaultUhkThemeColors } from './default-uhk-theme-colors';
66

77
extend([labPlugin]);
88

99
export function setSvgKeyboardCoverColorsOfLayer(backligtingMode: BacklightingMode, layer: Layer, theme: string): void {
10-
const themeColors = uhkThemeColors(theme);
10+
const themeColors = defaultUhkThemeColors(theme);
1111

1212
if (backligtingMode === BacklightingMode.PerKeyBacklighting) {
1313
const fillColord = colord('#cccccc');
1414

15-
layer.svgKeyboardCoverColors = {
16-
fillColor: fillColord.toHex(),
17-
strokeColor: colord(themeColors.backgroundColor).delta(fillColord) < 0.01
18-
? 'lightgray'
19-
: ''
15+
layer.uhkThemeColors = {
16+
...themeColors,
17+
svgKeyboardCoverColors: {
18+
fillColor: fillColord.toHex(),
19+
strokeColor: colord(themeColors.backgroundColor).delta(fillColord) < 0.01
20+
? 'lightgray'
21+
: ''
22+
}
2023
};
2124
} else {
22-
layer.svgKeyboardCoverColors = themeColors.svgKeyboardCoverColors;
25+
layer.uhkThemeColors = themeColors;
2326
}
2427
}

packages/uhk-web/src/modules/keyclusterleft/module.svg

+2-2
Loading

0 commit comments

Comments
 (0)