@netless/telebox-insider 0.2.6 → 0.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/telebox-insider",
3
- "version": "0.2.6",
3
+ "version": "0.2.10",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "license": "MIT",
@@ -1,3 +1,9 @@
1
+ export enum TELE_BOX_COLOR_SCHEME {
2
+ Light = "light",
3
+ Dark = "dark",
4
+ Auto = "auto",
5
+ }
6
+
1
7
  export enum TELE_BOX_STATE {
2
8
  Normal = "normal",
3
9
  Minimized = "minimized",
@@ -5,6 +11,8 @@ export enum TELE_BOX_STATE {
5
11
  }
6
12
 
7
13
  export enum TELE_BOX_EVENT {
14
+ DarkMode = "dark_mode",
15
+ PrefersColorScheme = "prefers_color_scheme",
8
16
  Close = "close",
9
17
  Focus = "focus",
10
18
  Blur = "blur",
@@ -26,6 +26,7 @@ import {
26
26
  TELE_BOX_STATE,
27
27
  TELE_BOX_RESIZE_HANDLE,
28
28
  TELE_BOX_DELEGATE_EVENT,
29
+ TELE_BOX_COLOR_SCHEME,
29
30
  } from "./constants";
30
31
  import type {
31
32
  TeleBoxConfig,
@@ -36,12 +37,15 @@ import type {
36
37
  TeleBoxDelegateEvents,
37
38
  TeleBoxCoord,
38
39
  TeleBoxSize,
40
+ TeleBoxColorScheme,
39
41
  } from "./typings";
40
42
 
41
43
  export * from "./constants";
42
44
  export * from "./typings";
43
45
 
44
46
  type ValConfig = {
47
+ prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
48
+ darkMode: Val<boolean, boolean>;
45
49
  containerRect: Val<TeleBoxRect, boolean>;
46
50
  collectorRect: Val<TeleBoxRect | undefined, boolean>;
47
51
  /** Box title. Default empty. */
@@ -74,6 +78,8 @@ export class TeleBox {
74
78
  public constructor({
75
79
  id = genUniqueKey(),
76
80
  title = getBoxDefaultName(),
81
+ prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
82
+ darkMode,
77
83
  visible = true,
78
84
  width = 0.5,
79
85
  height = 0.5,
@@ -112,6 +118,62 @@ export class TeleBox {
112
118
  this.events = new EventEmitter();
113
119
  this._delegateEvents = new EventEmitter();
114
120
 
121
+ const prefersColorScheme$ = createVal<TeleBoxColorScheme, boolean>(
122
+ prefersColorScheme
123
+ );
124
+ prefersColorScheme$.reaction((prefersColorScheme, _, skipUpdate) => {
125
+ if (!skipUpdate) {
126
+ this.events.emit(
127
+ TELE_BOX_EVENT.PrefersColorScheme,
128
+ prefersColorScheme
129
+ );
130
+ }
131
+ });
132
+
133
+ const darkMode$ = createVal(Boolean(darkMode));
134
+
135
+ if (darkMode == null) {
136
+ prefersColorScheme$.subscribe(
137
+ (prefersColorScheme, _, skipUpdate) => {
138
+ this._sideEffect.add(() => {
139
+ if (prefersColorScheme === "auto") {
140
+ const prefersDark = window.matchMedia(
141
+ "(prefers-color-scheme: dark)"
142
+ );
143
+ if (prefersDark) {
144
+ darkMode$.setValue(
145
+ prefersDark.matches,
146
+ skipUpdate
147
+ );
148
+ const handler = (
149
+ evt: MediaQueryListEvent
150
+ ): void => {
151
+ darkMode$.setValue(evt.matches, skipUpdate);
152
+ };
153
+ prefersDark.addListener(handler);
154
+ return () =>
155
+ prefersDark.removeListener(handler);
156
+ } else {
157
+ return noop;
158
+ }
159
+ } else {
160
+ darkMode$.setValue(
161
+ prefersColorScheme === "dark",
162
+ skipUpdate
163
+ );
164
+ return noop;
165
+ }
166
+ }, "prefers-color-scheme");
167
+ }
168
+ );
169
+ }
170
+
171
+ darkMode$.reaction((darkMode, _, skipUpdate) => {
172
+ if (!skipUpdate) {
173
+ this.events.emit(TELE_BOX_EVENT.DarkMode, darkMode);
174
+ }
175
+ });
176
+
115
177
  const containerRect$ = createVal(containerRect, shallowequal);
116
178
  const collectorRect$ = createVal(collectorRect, shallowequal);
117
179
 
@@ -354,6 +416,8 @@ export class TeleBox {
354
416
  const $userStyles$ = createVal(styles);
355
417
 
356
418
  const valConfig: ValConfig = {
419
+ prefersColorScheme: prefersColorScheme$,
420
+ darkMode: darkMode$,
357
421
  containerRect: containerRect$,
358
422
  collectorRect: collectorRect$,
359
423
  title: title$,
@@ -417,6 +481,10 @@ export class TeleBox {
417
481
  public _coord$: Val<TeleBoxCoord, boolean>;
418
482
  public _intrinsicCoord$: Val<TeleBoxCoord, boolean>;
419
483
 
484
+ public get darkMode(): boolean {
485
+ return this._darkMode$.value;
486
+ }
487
+
420
488
  public _state$: Val<TeleBoxState, boolean>;
421
489
 
422
490
  public get state(): TeleBoxState {
@@ -735,6 +803,13 @@ export class TeleBox {
735
803
  bindClassName(this.$box, this._draggable$, "no-drag", isFalsy);
736
804
  bindClassName(this.$box, this._resizable$, "no-resize", isFalsy);
737
805
  bindClassName(this.$box, this._focus$, "blur", isFalsy);
806
+ bindClassName(this.$box, this._darkMode$, "color-scheme-dark");
807
+ bindClassName(
808
+ this.$box,
809
+ this._darkMode$,
810
+ "color-scheme-light",
811
+ isFalsy
812
+ );
738
813
 
739
814
  this._renderSideEffect.add(() => {
740
815
  const minimizedClassName = this.wrapClassName("minimized");
@@ -1184,6 +1259,10 @@ export class TeleBox {
1184
1259
  }
1185
1260
  }
1186
1261
 
1262
+ function noop(): void {
1263
+ return;
1264
+ }
1265
+
1187
1266
  type PropKeys<K = keyof TeleBox> = K extends keyof TeleBox
1188
1267
  ? TeleBox[K] extends Function
1189
1268
  ? never
@@ -202,3 +202,13 @@
202
202
  pointer-events: none !important;
203
203
  }
204
204
  }
205
+
206
+ .#{$namespace}-color-scheme-dark {
207
+ color-scheme: dark;
208
+
209
+ .#{$namespace}-box-main {
210
+ color: #e9e9e9;
211
+ background: #212126;
212
+ border-color: #43434d;
213
+ }
214
+ }
@@ -6,8 +6,11 @@ import type {
6
6
  TELE_BOX_DELEGATE_EVENT,
7
7
  TELE_BOX_RESIZE_HANDLE,
8
8
  TELE_BOX_STATE,
9
+ TELE_BOX_COLOR_SCHEME,
9
10
  } from "./constants";
10
11
 
12
+ export type TeleBoxColorScheme = `${TELE_BOX_COLOR_SCHEME}`;
13
+
11
14
  export type TeleBoxCoord = { x: number; y: number };
12
15
 
13
16
  export type TeleBoxSize = { width: number; height: number };
@@ -26,6 +29,10 @@ export interface TeleBoxConfig {
26
29
  readonly id?: string;
27
30
  /** Box title. Default empty. */
28
31
  readonly title?: string;
32
+ /** Prefers Box color scheme. Default light. */
33
+ readonly prefersColorScheme?: TeleBoxColorScheme;
34
+ /** Actual Box Dark Mode */
35
+ readonly darkMode?: boolean;
29
36
  /** Box visible. Default true. */
30
37
  readonly visible?: boolean;
31
38
  /** Box width relative to root element. 0~1. Default 0.5. */
@@ -79,6 +86,8 @@ export interface TeleBoxConfig {
79
86
  type CheckTeleBoxConfig<T extends Record<`${TELE_BOX_EVENT}`, any>> = T;
80
87
 
81
88
  export type TeleBoxEventConfig = CheckTeleBoxConfig<{
89
+ dark_mode: boolean;
90
+ prefers_color_scheme: TeleBoxColorScheme;
82
91
  close: void;
83
92
  focus: void;
84
93
  blur: void;
@@ -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 = Boolean(visible);
22
- this._readonly = Boolean(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
- const $icon = document.createElement("img");
124
- $icon.draggable = false;
125
- $icon.className = this.wrapClassName("collector-icon");
126
- $icon.src = collectorSVG;
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
- .#{$namespace}-collector-icon {
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
+ }
@@ -10,4 +10,6 @@ export enum TELE_BOX_MANAGER_EVENT {
10
10
  IntrinsicMove = "intrinsic_move",
11
11
  IntrinsicResize = "intrinsic_resize",
12
12
  VisualResize = "visual_resize",
13
+ PrefersColorScheme = "prefers_color_scheme",
14
+ DarkMode = "dark_mode",
13
15
  }
@@ -17,7 +17,11 @@ import type {
17
17
  TeleBoxManagerUpdateConfig,
18
18
  } from "./typings";
19
19
  import { MaxTitleBar } from "./MaxTitleBar";
20
- import { TELE_BOX_DELEGATE_EVENT } from "..";
20
+ import {
21
+ TeleBoxColorScheme,
22
+ TELE_BOX_COLOR_SCHEME,
23
+ TELE_BOX_DELEGATE_EVENT,
24
+ } from "..";
21
25
  import { SideEffectManager } from "side-effect-manager";
22
26
  import {
23
27
  createSideEffectBinder,
@@ -30,6 +34,7 @@ export * from "./typings";
30
34
  export * from "./constants";
31
35
 
32
36
  type ValConfig = {
37
+ prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
33
38
  containerRect: Val<TeleBoxRect, boolean>;
34
39
  collector: Val<TeleBoxCollector | null>;
35
40
  readonly: Val<boolean, boolean>;
@@ -42,6 +47,7 @@ export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
42
47
  export class TeleBoxManager {
43
48
  public constructor({
44
49
  root = document.body,
50
+ prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
45
51
  minimized = false,
46
52
  maximized = false,
47
53
  fence = true,
@@ -63,6 +69,47 @@ export class TeleBoxManager {
63
69
  this.namespace = namespace;
64
70
  this.zIndex = zIndex;
65
71
 
72
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
73
+ const prefersDark$ = createVal(false);
74
+
75
+ if (prefersDark) {
76
+ prefersDark$.setValue(prefersDark.matches);
77
+ this._sideEffect.add(() => {
78
+ const handler = (evt: MediaQueryListEvent): void => {
79
+ prefersDark$.setValue(evt.matches);
80
+ };
81
+ prefersDark.addListener(handler);
82
+ return () => prefersDark.removeListener(handler);
83
+ });
84
+ }
85
+
86
+ const prefersColorScheme$ = createVal(prefersColorScheme);
87
+ prefersColorScheme$.reaction((prefersColorScheme, _, skipUpdate) => {
88
+ this.boxes.forEach((box) =>
89
+ box.setPrefersColorScheme(prefersColorScheme, skipUpdate)
90
+ );
91
+ if (!skipUpdate) {
92
+ this.events.emit(
93
+ TELE_BOX_MANAGER_EVENT.PrefersColorScheme,
94
+ prefersColorScheme
95
+ );
96
+ }
97
+ });
98
+
99
+ this._darkMode$ = combine(
100
+ [prefersDark$, prefersColorScheme$],
101
+ ([prefersDark, prefersColorScheme]) =>
102
+ prefersColorScheme === "auto"
103
+ ? prefersDark
104
+ : prefersColorScheme === "dark"
105
+ );
106
+ this._darkMode$.reaction((darkMode, _, skipUpdate) => {
107
+ this.boxes.forEach((box) => box.setDarkMode(darkMode, skipUpdate));
108
+ if (!skipUpdate) {
109
+ this.events.emit(TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
110
+ }
111
+ });
112
+
66
113
  const readonly$ = createVal(readonly);
67
114
  readonly$.reaction((readonly, _, skipUpdate) => {
68
115
  this.boxes.forEach((box) => box.setReadonly(readonly, skipUpdate));
@@ -123,6 +170,7 @@ export class TeleBoxManager {
123
170
  if (collector) {
124
171
  collector.setVisible(minimized$.value);
125
172
  collector.setReadonly(readonly$.value);
173
+ collector.setDarkMode(this._darkMode$.value);
126
174
  this._sideEffect.add(() => {
127
175
  collector.onClick = () => {
128
176
  if (!readonly$.value) {
@@ -136,6 +184,9 @@ export class TeleBoxManager {
136
184
  readonly$.subscribe((readonly) =>
137
185
  collector$.value?.setReadonly(readonly)
138
186
  );
187
+ this._darkMode$.subscribe((darkMode) => {
188
+ collector$.value?.setDarkMode(darkMode);
189
+ });
139
190
 
140
191
  minimized$.subscribe((minimized, _, skipUpdate) => {
141
192
  collector$.value?.setVisible(minimized);
@@ -210,6 +261,7 @@ export class TeleBoxManager {
210
261
  );
211
262
 
212
263
  this.maxTitleBar = new MaxTitleBar({
264
+ darkMode: this.darkMode,
213
265
  readonly: readonly$.value,
214
266
  namespace: this.namespace,
215
267
  state: state$.value,
@@ -244,8 +296,12 @@ export class TeleBoxManager {
244
296
  readonly$.subscribe((readonly) =>
245
297
  this.maxTitleBar.setReadonly(readonly)
246
298
  );
299
+ this._darkMode$.subscribe((darkMode) => {
300
+ this.maxTitleBar.setDarkMode(darkMode);
301
+ });
247
302
 
248
303
  const valConfig: ValConfig = {
304
+ prefersColorScheme: prefersColorScheme$,
249
305
  containerRect: containerRect$,
250
306
  collector: collector$,
251
307
  readonly: readonly$,
@@ -271,6 +327,12 @@ export class TeleBoxManager {
271
327
 
272
328
  public zIndex: number;
273
329
 
330
+ public _darkMode$: Val<boolean, boolean>;
331
+
332
+ public get darkMode(): boolean {
333
+ return this._darkMode$.value;
334
+ }
335
+
274
336
  public _state$: Val<TeleBoxState, boolean>;
275
337
 
276
338
  public get state(): TeleBoxState {
@@ -385,11 +447,11 @@ export class TeleBoxManager {
385
447
  const box = boxes[0];
386
448
  this.focusBox({ focus: false, box });
387
449
  box.destroy();
388
- if (this.boxes.length <= 0) {
389
- this.setMaximized(false);
390
- this.setMinimized(false);
391
- }
392
450
  if (!skipUpdate) {
451
+ if (this.boxes.length <= 0) {
452
+ this.setMaximized(false);
453
+ this.setMinimized(false);
454
+ }
393
455
  this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, boxes);
394
456
  }
395
457
  return box;
@@ -412,11 +474,11 @@ export class TeleBoxManager {
412
474
  const boxes = this.boxes.splice(0, this.boxes.length);
413
475
  this.maxTitleBar.setBoxes(this.boxes);
414
476
  boxes.forEach((box) => box.destroy());
415
- if (this.boxes.length <= 0) {
416
- this.setMaximized(false);
417
- this.setMinimized(false);
418
- }
419
477
  if (!skipUpdate) {
478
+ if (this.boxes.length <= 0) {
479
+ this.setMaximized(false);
480
+ this.setMinimized(false);
481
+ }
420
482
  this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, boxes);
421
483
  }
422
484
  return boxes;
@@ -614,6 +676,8 @@ export class TeleBoxManager {
614
676
  y,
615
677
  width,
616
678
  height,
679
+ darkMode: this.darkMode,
680
+ prefersColorScheme: this.prefersColorScheme,
617
681
  maximized: this.maximized,
618
682
  minimized: this.minimized,
619
683
  fence: this.fence,
@@ -1,4 +1,5 @@
1
1
  import type EventEmitter from "eventemitter3";
2
+ import { TeleBoxColorScheme } from "..";
2
3
  import type { ReadonlyTeleBox, TeleBoxState } from "../TeleBox";
3
4
  import type { TeleBoxConfig } from "../TeleBox/typings";
4
5
  import type { TeleBoxCollector } from "../TeleBoxCollector";
@@ -7,6 +8,7 @@ import type { TELE_BOX_MANAGER_EVENT } from "./constants";
7
8
  export interface TeleBoxManagerConfig
8
9
  extends Pick<
9
10
  TeleBoxConfig,
11
+ | "prefersColorScheme"
10
12
  | "fence"
11
13
  | "containerRect"
12
14
  | "maximized"
@@ -67,6 +69,8 @@ export type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
67
69
  intrinsic_move: [ReadonlyTeleBox];
68
70
  intrinsic_resize: [ReadonlyTeleBox];
69
71
  visual_resize: [ReadonlyTeleBox];
72
+ prefers_color_scheme: [TeleBoxColorScheme];
73
+ dark_mode: [boolean];
70
74
  }>;
71
75
 
72
76
  export type TeleBoxManagerEvent = keyof TeleBoxManagerEventConfig;
@@ -16,6 +16,12 @@ export type TeleBoxReactProps = TeleBoxConfig & {
16
16
  export const TeleBoxReact: FC<TeleBoxReactProps> = (props) => {
17
17
  const [teleBox] = useState(() => new TeleBox(props));
18
18
 
19
+ useUpdateEffect(() => {
20
+ if (props.prefersColorScheme != null) {
21
+ teleBox.setPrefersColorScheme(props.prefersColorScheme);
22
+ }
23
+ }, [teleBox, props.prefersColorScheme]);
24
+
19
25
  useUpdateEffect(() => {
20
26
  if (props.minWidth != null) {
21
27
  teleBox.setMinWidth(props.minWidth);
@@ -52,6 +58,18 @@ export const TeleBoxReact: FC<TeleBoxReactProps> = (props) => {
52
58
  }
53
59
  }, [teleBox, props.visible]);
54
60
 
61
+ useUpdateEffect(() => {
62
+ if (props.minimized != null) {
63
+ teleBox.setMinimized(props.minimized, true);
64
+ }
65
+ }, [teleBox, props.minimized]);
66
+
67
+ useUpdateEffect(() => {
68
+ if (props.maximized != null) {
69
+ teleBox.setMaximized(props.maximized, true);
70
+ }
71
+ }, [teleBox, props.maximized]);
72
+
55
73
  useUpdateEffect(() => {
56
74
  if (props.state != null) {
57
75
  teleBox.setState(props.state, true);
@@ -71,3 +71,17 @@
71
71
  .#{$namespace}-titlebar-icon-close {
72
72
  background: center / cover no-repeat url("./icons/close.svg");
73
73
  }
74
+
75
+ .#{$namespace}-color-scheme-dark {
76
+ color-scheme: dark;
77
+
78
+ .#{$namespace}-title {
79
+ color: #e9e9e9;
80
+ }
81
+
82
+ .#{$namespace}-titlebar {
83
+ color: #e9e9e9;
84
+ background: #43434d;
85
+ border-bottom: none;
86
+ }
87
+ }