Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit b7a8982

Browse files
committed
Rollback of some lines
1 parent aae6260 commit b7a8982

File tree

10 files changed

+28
-48
lines changed

10 files changed

+28
-48
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ tsconfig.json
3535

3636
npm-debug.log
3737
webpack.config.js
38-
._config.yml
38+
_config.yml

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "4.1.1",
44
"description": "Custom Electron Titlebar is a library for electron that allows you to configure a fully customizable title bar.",
55
"exports": {
6-
".": "./index.js",
7-
"./main": "./main.js"
6+
".": "./dist/index.js",
7+
"./main": "./dist/main.js"
88
},
99
"types": "dist/index.d.ts",
1010
"scripts": {

src/menu.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Event, Emitter } from "vs/base/common/event";
2020
import { RunOnceScheduler } from "vs/base/common/async";
2121
import { MenubarOptions } from "./types/menubar-options";
2222
import icons from "static/icons.json";
23+
import { applyFill } from "utils/color";
2324

2425
export const MENU_MNEMONIC_REGEX = /\(&([^\s&])\)|(^|[^&])&([^\s&])/;
2526
export const MENU_ESCAPED_MNEMONIC_REGEX = /(&)?(&)([^\s&])/g;
@@ -503,11 +504,7 @@ class Submenu extends CETMenuItem {
503504
this.submenuIndicator = append(this.itemElement, $('span.cet-submenu-indicator'));
504505
this.submenuIndicator.innerHTML = icons.arrow;
505506

506-
let fillColor;
507-
508-
if (this.menubarOptions?.svgColor) fillColor = this.menubarOptions.svgColor?.toString();
509-
else if (this.menuStyle?.foregroundColor) fillColor = this.menuStyle?.foregroundColor?.toString();
510-
this.submenuIndicator.firstElementChild?.setAttribute('fill', fillColor as string);
507+
applyFill(this.submenuIndicator.firstElementChild, this.menubarOptions?.svgColor, this.menuStyle?.foregroundColor);
511508
this.submenuIndicator.setAttribute('aria-hidden', 'true');
512509

513510
if (this.container) {
@@ -644,22 +641,13 @@ class Submenu extends CETMenuItem {
644641
applyStyle(): void {
645642
super.applyStyle();
646643

647-
if (!this.menuStyle) {
648-
return;
649-
}
644+
if (!this.menuStyle) return;
650645

651646
const isSelected = this.container && hasClass(this.container, 'focused');
652647
const fgColor = isSelected && this.menuStyle.selectionForegroundColor ? this.menuStyle.selectionForegroundColor : this.menuStyle.foregroundColor;
648+
applyFill(this.submenuIndicator?.firstElementChild, this.menubarOptions?.svgColor, fgColor);
653649

654-
let fillColor = '';
655-
656-
if (this.menubarOptions?.svgColor) fillColor = this.menubarOptions.svgColor?.toString();
657-
else if (this.menuStyle?.foregroundColor) fillColor = this.menuStyle?.foregroundColor?.toString();
658-
if (this.submenuIndicator) this.submenuIndicator.firstElementChild?.setAttribute('fill', fgColor ? fgColor.toString() : fillColor);
659-
660-
if (this.parentData.submenu) {
661-
this.parentData.submenu.style(this.menuStyle);
662-
}
650+
if (this.parentData.submenu) this.parentData.submenu.style(this.menuStyle);
663651
}
664652

665653
dispose(): void {

src/menubar.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ export class Menubar {
153153
const menuIndex = this.menuItems.length;
154154
const cleanMenuLabel = cleanMnemonic(menubarMenu.label);
155155

156-
const buttonElement = $('div.cet-menubar-menu-button', { 'role': 'menuitem', 'tabindex': -1, 'aria-label': cleanMenuLabel, 'aria-haspopup': true });
156+
const buttonElement = $('div.cet-menubar-menu-button', { 'tabindex': -1, 'aria-label': cleanMenuLabel, 'aria-haspopup': true });
157157
if (!menubarMenu.enabled) {
158158
addClass(buttonElement, 'disabled');
159159
}
160-
const titleElement = $('div.cet-menubar-menu-title', { 'role': 'none', 'aria-hidden': true });
160+
const titleElement = $('div.cet-menubar-menu-title', { 'aria-hidden': true });
161161

162162
buttonElement.appendChild(titleElement);
163163
append(this.container, buttonElement);
@@ -597,7 +597,6 @@ export class Menubar {
597597
const menuHolder = $('ul.cet-menubar-menu-container');
598598

599599
addClass(btnElement, 'open');
600-
menuHolder.setAttribute('role', 'menu');
601600
menuHolder.tabIndex = 0;
602601
menuHolder.style.top = `${btnRect.bottom - 5}px`;
603602
menuHolder.style.left = `${btnRect.left}px`;

src/menuitem.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Disposable } from "vs/base/common/lifecycle";
1717
import { isMacintosh } from "vs/base/common/platform";
1818
import { MenubarOptions } from "./types/menubar-options";
1919
import defaultIcons from 'static/icons.json';
20+
import { applyFill } from 'utils/color';
2021

2122
export interface IMenuItem {
2223
render(element: HTMLElement): void;
@@ -120,7 +121,6 @@ export class CETMenuItem extends Disposable implements IMenuItem {
120121
});
121122

122123
this.itemElement = append(this.container, $('a.cet-action-menu-item'));
123-
this.itemElement.setAttribute('role', 'menuitem');
124124

125125
if (this.mnemonic) {
126126
this.itemElement.setAttribute('aria-keyshortcuts', `${this.mnemonic}`);
@@ -299,12 +299,7 @@ export class CETMenuItem extends Disposable implements IMenuItem {
299299
this.iconElement!.innerHTML = this.item.checked ? defaultIcons.radio.checked : defaultIcons.radio.unchecked;
300300
}
301301

302-
if (this.iconElement!.firstElementChild) {
303-
let fillColor;
304-
if (this.menubarOptions?.svgColor) fillColor = this.menubarOptions.svgColor?.toString();
305-
else if (this.menuStyle?.foregroundColor) fillColor = this.menuStyle?.foregroundColor?.toString();
306-
this.iconElement?.firstElementChild.setAttribute('fill', fillColor as string);
307-
}
302+
applyFill(this.iconElement?.firstElementChild, this.menubarOptions?.svgColor, this.menuStyle?.foregroundColor);
308303
}
309304

310305
updateTooltip(): void {
@@ -346,11 +341,9 @@ export class CETMenuItem extends Disposable implements IMenuItem {
346341
if (this.itemElement) {
347342
if (this.item.checked) {
348343
addClass(this.itemElement, 'checked');
349-
this.itemElement.setAttribute('role', `menuitemcheckbox${this.item.type}`);
350344
this.itemElement.setAttribute('aria-checked', 'true');
351345
} else {
352346
removeClass(this.itemElement, 'checked');
353-
this.itemElement.setAttribute('role', 'menuitem');
354347
this.itemElement.setAttribute('aria-checked', 'false');
355348
}
356349
}
@@ -430,13 +423,7 @@ export class CETMenuItem extends Disposable implements IMenuItem {
430423
this.itemElement.style.color = fgColor ? fgColor.toString() : '';
431424
this.itemElement.style.backgroundColor = bgColor ? bgColor.toString() : '';
432425

433-
if (this.iconElement) {
434-
let fillColor = '';
435-
436-
if (this.menubarOptions?.svgColor) fillColor = this.menubarOptions.svgColor?.toString();
437-
else if (this.menuStyle?.foregroundColor) fillColor = this.menuStyle?.foregroundColor?.toString();
438-
this.iconElement.firstElementChild?.setAttribute('fill', fgColor ? fgColor.toString() : fillColor);
439-
}
426+
if (this.iconElement) applyFill(this.iconElement.firstElementChild, this.menubarOptions?.svgColor, fgColor);
440427
}
441428
}
442429

src/static/menubar.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@
203203

204204
&.checkbox {
205205
visibility: hidden;
206-
207-
&.checked {
208-
visibility: visible;
209-
}
210206
}
211207
}
212208
}

src/titlebar.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export default class Titlebar {
149149

150150
// Create menubar
151151
this.menubarContainer = append(this.titlebar, $('div.cet-menubar'));
152-
this.menubarContainer.setAttribute('role', 'menubar');
153152

154153
// Create title
155154
this.title = append(this.titlebar, $('div.cet-window-title'));

src/utils/color.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Color } from "vs/base/common/color";
2+
3+
export const applyFill = (element: Element | undefined | null, svgColor: Color | undefined, fgColor: Color | undefined) => {
4+
let fillColor = '';
5+
6+
if (svgColor) fillColor = svgColor.toString();
7+
else if (fgColor) fillColor = fgColor.toString();
8+
9+
if (element && element !== null) element.setAttribute('fill', fillColor);
10+
}

webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require("path");
22
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
33

44
const srcPath = path.join(__dirname, "src");
5+
const distPath = path.join(__dirname, "dist");
56

67
const commonConfig = {
78
context: srcPath,
@@ -39,7 +40,7 @@ module.exports = [
3940
target: "electron-renderer",
4041
entry: { index: path.join(srcPath, 'index.ts') },
4142
output: {
42-
path: __dirname,
43+
path: distPath,
4344
filename: "index.js",
4445
libraryTarget: "umd",
4546
globalObject: "this",
@@ -52,7 +53,7 @@ module.exports = [
5253
target: "electron-main",
5354
entry: { main: path.join(srcPath, 'main', 'main.ts') },
5455
output: {
55-
path: __dirname,
56+
path: distPath,
5657
filename: "main.js",
5758
libraryTarget: "umd",
5859
globalObject: "this",

0 commit comments

Comments
 (0)