@netless/telebox-insider 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TeleBoxCollector/index.d.ts +5 -1
- package/dist/TeleBoxManager/MaxTitleBar/index.d.ts +3 -0
- package/dist/style.css +1 -1
- package/dist/telebox-insider.cjs.js +2 -2
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +2 -2
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/style.scss +2 -0
- package/src/TeleBoxCollector/index.ts +34 -8
- package/src/TeleBoxCollector/style.scss +11 -5
- package/src/TeleBoxManager/MaxTitleBar/index.ts +25 -0
- package/src/TeleBoxManager/MaxTitleBar/style.scss +18 -0
- package/src/TeleBoxManager/index.ts +8 -0
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +2 -0
package/package.json
CHANGED
package/src/TeleBox/style.scss
CHANGED
|
@@ -5,6 +5,7 @@ import { TeleStyles } from "../typings";
|
|
|
5
5
|
export interface TeleBoxCollectorConfig {
|
|
6
6
|
visible?: boolean;
|
|
7
7
|
readonly?: boolean;
|
|
8
|
+
darkMode?: boolean;
|
|
8
9
|
namespace?: string;
|
|
9
10
|
styles?: TeleStyles;
|
|
10
11
|
onClick?: () => void;
|
|
@@ -14,12 +15,14 @@ export class TeleBoxCollector {
|
|
|
14
15
|
public constructor({
|
|
15
16
|
visible = true,
|
|
16
17
|
readonly = false,
|
|
18
|
+
darkMode = false,
|
|
17
19
|
namespace = "telebox",
|
|
18
20
|
styles = {},
|
|
19
21
|
onClick,
|
|
20
22
|
}: TeleBoxCollectorConfig = {}) {
|
|
21
|
-
this._visible =
|
|
22
|
-
this._readonly =
|
|
23
|
+
this._visible = visible;
|
|
24
|
+
this._readonly = readonly;
|
|
25
|
+
this._darkMode = darkMode;
|
|
23
26
|
this.namespace = namespace;
|
|
24
27
|
this.styles = styles;
|
|
25
28
|
this.onClick = onClick;
|
|
@@ -37,6 +40,10 @@ export class TeleBoxCollector {
|
|
|
37
40
|
return this._readonly;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
public get darkMode(): boolean {
|
|
44
|
+
return this._darkMode;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
public onClick: (() => void) | undefined;
|
|
41
48
|
|
|
42
49
|
public $collector: HTMLElement | undefined;
|
|
@@ -85,6 +92,23 @@ export class TeleBoxCollector {
|
|
|
85
92
|
return this;
|
|
86
93
|
}
|
|
87
94
|
|
|
95
|
+
public setDarkMode(darkMode: boolean): this {
|
|
96
|
+
if (this._darkMode !== darkMode) {
|
|
97
|
+
this._darkMode = darkMode;
|
|
98
|
+
if (this.$collector) {
|
|
99
|
+
this.$collector.classList.toggle(
|
|
100
|
+
this.wrapClassName("color-scheme-dark"),
|
|
101
|
+
darkMode
|
|
102
|
+
);
|
|
103
|
+
this.$collector.classList.toggle(
|
|
104
|
+
this.wrapClassName("color-scheme-light"),
|
|
105
|
+
!darkMode
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
88
112
|
public setStyles(styles: TeleStyles): this {
|
|
89
113
|
Object.assign(this.styles, styles);
|
|
90
114
|
if (this.$collector) {
|
|
@@ -103,6 +127,7 @@ export class TeleBoxCollector {
|
|
|
103
127
|
if (!this.$collector) {
|
|
104
128
|
this.$collector = document.createElement("button");
|
|
105
129
|
this.$collector.className = this.wrapClassName("collector");
|
|
130
|
+
this.$collector.style.backgroundImage = `url('${collectorSVG}')`;
|
|
106
131
|
this.$collector.addEventListener(
|
|
107
132
|
"click",
|
|
108
133
|
this.handleCollectorClick
|
|
@@ -120,12 +145,11 @@ export class TeleBoxCollector {
|
|
|
120
145
|
);
|
|
121
146
|
}
|
|
122
147
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.$collector.appendChild($icon);
|
|
148
|
+
this.$collector.classList.add(
|
|
149
|
+
this.wrapClassName(
|
|
150
|
+
this._darkMode ? "color-scheme-dark" : "color-scheme-light"
|
|
151
|
+
)
|
|
152
|
+
);
|
|
129
153
|
|
|
130
154
|
this.setStyles(this.styles);
|
|
131
155
|
}
|
|
@@ -153,6 +177,8 @@ export class TeleBoxCollector {
|
|
|
153
177
|
|
|
154
178
|
protected _readonly: boolean;
|
|
155
179
|
|
|
180
|
+
protected _darkMode: boolean;
|
|
181
|
+
|
|
156
182
|
protected handleCollectorClick = (): void => {
|
|
157
183
|
if (!this._readonly && this.onClick) {
|
|
158
184
|
this.onClick();
|
|
@@ -18,11 +18,9 @@
|
|
|
18
18
|
cursor: pointer;
|
|
19
19
|
user-select: none;
|
|
20
20
|
pointer-events: none;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
width: 18px;
|
|
25
|
-
height: 16px;
|
|
21
|
+
background-repeat: no-repeat;
|
|
22
|
+
background-size: 18px 16px;
|
|
23
|
+
background-position: center;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
.#{$namespace}-collector-visible {
|
|
@@ -33,3 +31,11 @@
|
|
|
33
31
|
.#{$namespace}-collector-readonly {
|
|
34
32
|
cursor: not-allowed;
|
|
35
33
|
}
|
|
34
|
+
|
|
35
|
+
.#{$namespace}-color-scheme-dark {
|
|
36
|
+
color-scheme: dark;
|
|
37
|
+
|
|
38
|
+
&.#{$namespace}-collector {
|
|
39
|
+
background-color: #43434d;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -8,6 +8,7 @@ import { TeleBoxRect, TeleBoxState } from "../../TeleBox/typings";
|
|
|
8
8
|
export type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly">;
|
|
9
9
|
|
|
10
10
|
export interface MaxTitleBarConfig extends DefaultTitleBarConfig {
|
|
11
|
+
darkMode: boolean;
|
|
11
12
|
boxes: MaxTitleBarTeleBox[];
|
|
12
13
|
containerRect: TeleBoxRect;
|
|
13
14
|
focusedBox?: MaxTitleBarTeleBox;
|
|
@@ -20,6 +21,7 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
20
21
|
this.boxes = config.boxes;
|
|
21
22
|
this.focusedBox = config.focusedBox;
|
|
22
23
|
this.containerRect = config.containerRect;
|
|
24
|
+
this.darkMode = config.darkMode;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
public focusBox(box?: MaxTitleBarTeleBox): void {
|
|
@@ -89,6 +91,22 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
public setDarkMode(darkMode: boolean): void {
|
|
95
|
+
if (darkMode !== this.darkMode) {
|
|
96
|
+
this.darkMode = darkMode;
|
|
97
|
+
if (this.$titleBar) {
|
|
98
|
+
this.$titleBar.classList.toggle(
|
|
99
|
+
this.wrapClassName("color-scheme-dark"),
|
|
100
|
+
darkMode
|
|
101
|
+
);
|
|
102
|
+
this.$titleBar.classList.toggle(
|
|
103
|
+
this.wrapClassName("color-scheme-light"),
|
|
104
|
+
!darkMode
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
92
110
|
public render(): HTMLElement {
|
|
93
111
|
const $titleBar = super.render();
|
|
94
112
|
const { x, y, width } = this.containerRect;
|
|
@@ -104,6 +122,11 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
104
122
|
this.wrapClassName("readonly"),
|
|
105
123
|
this.readonly
|
|
106
124
|
);
|
|
125
|
+
$titleBar.classList.add(
|
|
126
|
+
this.wrapClassName(
|
|
127
|
+
this.darkMode ? "color-scheme-dark" : "color-scheme-light"
|
|
128
|
+
)
|
|
129
|
+
);
|
|
107
130
|
|
|
108
131
|
this.updateTitles();
|
|
109
132
|
|
|
@@ -171,6 +194,8 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
171
194
|
return this.$titles;
|
|
172
195
|
}
|
|
173
196
|
|
|
197
|
+
protected darkMode: boolean;
|
|
198
|
+
|
|
174
199
|
protected $titles: HTMLElement | undefined;
|
|
175
200
|
|
|
176
201
|
protected boxes: MaxTitleBarTeleBox[];
|
|
@@ -123,3 +123,21 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
123
123
|
cursor: not-allowed;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
|
|
127
|
+
.#{$namespace}-color-scheme-dark {
|
|
128
|
+
color-scheme: dark;
|
|
129
|
+
|
|
130
|
+
&.#{$namespace}-titlebar {
|
|
131
|
+
color: #e9e9e9;
|
|
132
|
+
background: #43434d;
|
|
133
|
+
border-bottom: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.#{$namespace}-titles-tab {
|
|
137
|
+
border-right-color: #7b88a0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.#{$namespace}-title {
|
|
141
|
+
color: #e9e9e9;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -166,6 +166,7 @@ export class TeleBoxManager {
|
|
|
166
166
|
if (collector) {
|
|
167
167
|
collector.setVisible(minimized$.value);
|
|
168
168
|
collector.setReadonly(readonly$.value);
|
|
169
|
+
collector.setDarkMode(this._darkMode$.value);
|
|
169
170
|
this._sideEffect.add(() => {
|
|
170
171
|
collector.onClick = () => {
|
|
171
172
|
if (!readonly$.value) {
|
|
@@ -179,6 +180,9 @@ export class TeleBoxManager {
|
|
|
179
180
|
readonly$.subscribe((readonly) =>
|
|
180
181
|
collector$.value?.setReadonly(readonly)
|
|
181
182
|
);
|
|
183
|
+
this._darkMode$.subscribe((darkMode) => {
|
|
184
|
+
collector$.value?.setDarkMode(darkMode);
|
|
185
|
+
});
|
|
182
186
|
|
|
183
187
|
minimized$.subscribe((minimized, _, skipUpdate) => {
|
|
184
188
|
collector$.value?.setVisible(minimized);
|
|
@@ -253,6 +257,7 @@ export class TeleBoxManager {
|
|
|
253
257
|
);
|
|
254
258
|
|
|
255
259
|
this.maxTitleBar = new MaxTitleBar({
|
|
260
|
+
darkMode: this.darkMode,
|
|
256
261
|
readonly: readonly$.value,
|
|
257
262
|
namespace: this.namespace,
|
|
258
263
|
state: state$.value,
|
|
@@ -287,6 +292,9 @@ export class TeleBoxManager {
|
|
|
287
292
|
readonly$.subscribe((readonly) =>
|
|
288
293
|
this.maxTitleBar.setReadonly(readonly)
|
|
289
294
|
);
|
|
295
|
+
this._darkMode$.subscribe((darkMode) => {
|
|
296
|
+
this.maxTitleBar.setDarkMode(darkMode);
|
|
297
|
+
});
|
|
290
298
|
|
|
291
299
|
const valConfig: ValConfig = {
|
|
292
300
|
prefersColorScheme: prefersColorScheme$,
|