@netless/telebox-insider 1.0.0-alpha.25 → 1.0.0-alpha.28

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.
@@ -7,6 +7,8 @@ import type { TELE_BOX_MANAGER_EVENT } from "./constants";
7
7
  export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
8
8
  /** Element to mount boxes. */
9
9
  readonly root?: HTMLElement | null;
10
+ /** Fullscreen mode. Default false. */
11
+ readonly fullscreen?: TeleBoxFullscreen;
10
12
  /** Stage area height/with ratio. No ratio if <= 0. Default -1. */
11
13
  readonly stageRatio?: number;
12
14
  /** Where the minimized boxes go. */
@@ -29,6 +31,8 @@ export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
29
31
  readonly defaultBoxBodyStyle?: string | null;
30
32
  /** Custom `style` attribute value for stage area of all boxes. Can be overwritten by box. */
31
33
  readonly defaultBoxStageStyle?: string | null;
34
+ /** Theme variable */
35
+ readonly theme?: TeleBoxManagerThemeConfig;
32
36
  }
33
37
 
34
38
  type TeleBoxManagerBoxConfigBaseProps =
@@ -101,3 +105,44 @@ export type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
101
105
  }>;
102
106
 
103
107
  export type TeleBoxManagerEvent = keyof TeleBoxManagerEventConfig;
108
+
109
+ /**
110
+ * Fullscreen mode.
111
+ * - `true`: fullscreen mode. hide titlebar for single tab.
112
+ * - `false`: normal mode.
113
+ * - `"no-titlebar"`: always hide titlebar
114
+ * - `"always-titlebar"`: always show titlebar
115
+ */
116
+ export type TeleBoxFullscreen = boolean | "no-titlebar" | "always-titlebar";
117
+
118
+ export type TeleBoxManagerThemeConfig = {
119
+ managerContainerBackground?: string | null;
120
+ managerStageBackground?: string | null;
121
+ managerStageShadow?: string | null;
122
+
123
+ boxContainerBackground?: string | null;
124
+ boxStageBackground?: string | null;
125
+ boxStageShadow?: string | null;
126
+
127
+ boxColor?: string | null;
128
+ boxBorder?: string | null;
129
+ boxShadow?: string | null;
130
+ boxFooterColor?: string | null;
131
+ boxFooterBackground?: string | null;
132
+
133
+ titlebarColor?: string | null;
134
+ titlebarBackground?: string | null;
135
+ titlebarBorderBottom?: string | null;
136
+ titlebarTabColor?: string | null;
137
+ titlebarTabFocusColor?: string | null;
138
+ titlebarTabBackground?: string | null;
139
+ titlebarTabDividerColor?: string | null;
140
+
141
+ collectorBackground?: string | null;
142
+ collectorShadow?: string | null;
143
+
144
+ titlebarIconMinimize?: string | null;
145
+ titlebarIconMaximize?: string | null;
146
+ titlebarIconMaximizeActive?: string | null;
147
+ titlebarIconClose?: string | null;
148
+ };
@@ -122,9 +122,9 @@ export class DefaultTitleBar implements TeleTitleBar {
122
122
 
123
123
  this.sideEffect.addEventListener(
124
124
  $buttonsContainer,
125
- "pointerup",
125
+ "click",
126
126
  (ev) => {
127
- if (!ev.isPrimary || this.readonly$.value) {
127
+ if (this.readonly$.value) {
128
128
  return;
129
129
  }
130
130
  const target = ev.target as HTMLElement;
@@ -11,9 +11,9 @@
11
11
  user-select: none;
12
12
  touch-action: manipulation;
13
13
 
14
- @include v(color, titlebar-color, $titlebar-color);
15
- @include v(background-color, titlebar-background, $titlebar-background);
16
- @include v(border-bottom, titlebar-border-bottom, $titlebar-border-bottom);
14
+ @include clr(color, titlebarColor);
15
+ @include clr(background-color, titlebarBackground);
16
+ @include clr(border-bottom, titlebarBorderBottom);
17
17
  }
18
18
 
19
19
  .#{$namespace}-title-area {
@@ -28,7 +28,7 @@
28
28
 
29
29
  .#{$namespace}-title {
30
30
  @include no-user-select;
31
- @include v(color, titlebar-color, $titlebar-color);
31
+ @include clr(color, titlebarColor);
32
32
 
33
33
  overflow: hidden;
34
34
  margin: 0;
@@ -49,6 +49,8 @@
49
49
  bottom: 0;
50
50
  margin: auto;
51
51
  z-index: 10;
52
+ // enable pointermove event on touch devices
53
+ touch-action: none;
52
54
  }
53
55
 
54
56
  .#{$namespace}-titlebar-btns {
@@ -88,25 +90,25 @@
88
90
 
89
91
  .#{$namespace}-titlebar-icon-minimize {
90
92
  background: center / cover no-repeat;
91
- @include v(
92
- background-image,
93
- titlebar-icon-minimize,
93
+ background-image: url("./icons/minimize.svg");
94
+ background-image: var(
95
+ --tele-titlebarIconMinimize,
94
96
  url("./icons/minimize.svg")
95
97
  );
96
98
  }
97
99
 
98
100
  .#{$namespace}-titlebar-icon-maximize {
99
101
  background: center / cover no-repeat;
100
- @include v(
101
- background-image,
102
- titlebar-icon-maximize,
102
+ background-image: url("./icons/maximize.svg");
103
+ background-image: var(
104
+ --tele-titlebarIconMaximize,
103
105
  url("./icons/maximize.svg")
104
106
  );
105
107
 
106
108
  &.is-active {
107
- @include v(
108
- background-image,
109
- titlebar-icon-maximize-active,
109
+ background-image: url("./icons/maximize-active.svg");
110
+ background-image: var(
111
+ --tele-titlebarIconMaximizeActive,
110
112
  url("./icons/maximize-active.svg")
111
113
  );
112
114
  }
@@ -114,59 +116,20 @@
114
116
 
115
117
  .#{$namespace}-titlebar-icon-close {
116
118
  background: center / cover no-repeat;
117
- @include v(background-image, titlebar-icon-close, url("./icons/close.svg"));
119
+ background-image: url("./icons/close.svg");
120
+ background-image: var(--tele-titlebarIconClose, url("./icons/close.svg"));
118
121
  }
119
122
 
120
123
  .#{$namespace}-color-scheme-dark {
121
124
  color-scheme: dark;
122
125
 
123
126
  .#{$namespace}-title {
124
- @include v(color, titlebar-color-dark, $titlebar-color-dark);
127
+ @include clr-dark(color, titlebarColor);
125
128
  }
126
129
 
127
130
  .#{$namespace}-titlebar {
128
- @include v(color, titlebar-color-dark, $titlebar-color-dark);
129
- @include v(
130
- background-color,
131
- titlebar-background-dark,
132
- $titlebar-background-dark
133
- );
134
- @include v(
135
- border-bottom,
136
- titlebar-border-bottom-dark,
137
- $titlebar-border-bottom-dark
138
- );
139
- }
140
-
141
- .#{$namespace}-titlebar-icon-minimize {
142
- @include v(
143
- background-image,
144
- titlebar-icon-minimize-dark,
145
- url("./icons/minimize.svg")
146
- );
147
- }
148
-
149
- .#{$namespace}-titlebar-icon-maximize {
150
- @include v(
151
- background-image,
152
- titlebar-icon-maximize-dark,
153
- url("./icons/maximize.svg")
154
- );
155
-
156
- &.is-active {
157
- @include v(
158
- background-image,
159
- titlebar-icon-maximize-active-dark,
160
- url("./icons/maximize-active.svg")
161
- );
162
- }
163
- }
164
-
165
- .#{$namespace}-titlebar-icon-close {
166
- @include v(
167
- background-image,
168
- titlebar-icon-close-dark,
169
- url("./icons/close.svg")
170
- );
131
+ @include clr-dark(color, titlebarColor);
132
+ @include clr-dark(background-color, titlebarBackground);
133
+ @include clr-dark(border-bottom, titlebarBorderBottom);
171
134
  }
172
135
  }
package/src/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- import "./scss/fancy-scrollbar.scss";
2
-
3
1
  export * from "./TeleBox";
4
2
  export * from "./TeleTitleBar";
5
3
  export * from "./TeleBoxManager";
@@ -5,8 +5,3 @@
5
5
  // iOS Safari
6
6
  -webkit-user-select: none;
7
7
  }
8
-
9
- @mixin v($property, $varName, $val) {
10
- #{$property}: $val;
11
- #{$property}: var(--tele-#{$varName}, $val);
12
- }
@@ -5,44 +5,70 @@ $max-titlebar-z-index: $base-z-index + 5000;
5
5
  $stage-z-index: $max-titlebar-z-index + 10;
6
6
  $collector-z-index: $stage-z-index + 10;
7
7
 
8
- $manager-container-background: #f9f9f9;
9
- $manager-container-background-dark: #25282e;
10
- $manager-stage-background: #fff;
11
- $manager-stage-background-dark: #272a30;
12
- $manager-stage-shadow: 0px 0px 16px rgba(0, 0, 0, 0.08);
13
- $manager-stage-shadow-dark: 0px 0px 16px rgba(0, 0, 0, 0.24);
8
+ $tele-colors: (
9
+ managerContainerBackground: #f9f9f9,
10
+ managerStageBackground: #fff,
11
+ managerStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.08),
12
+ boxContainerBackground: #f9f9f9,
13
+ boxStageBackground: #fff,
14
+ boxStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.08),
15
+ boxColor: #191919,
16
+ boxBorder: 1px solid #e3e3ec,
17
+ boxShadow: 0px 4px 10px 0px rgba(47, 65, 146, 0.15),
18
+ boxFooterColor: #191919,
19
+ boxFooterBackground: #fff,
20
+ titlebarColor: #191919,
21
+ titlebarBackground: #fff,
22
+ titlebarBorderBottom: 1px solid #eeeef7,
23
+ titlebarTabColor: #7b88a0,
24
+ titlebarTabFocusColor: #357bf6,
25
+ titlebarTabBackground: transparent,
26
+ titlebarTabDividerColor: #e5e5f0,
27
+ collectorBackground: #fff,
28
+ collectorShadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15),
29
+ );
14
30
 
15
- $box-container-background: $manager-container-background;
16
- $box-container-background-dark: $manager-container-background-dark;
17
- $box-stage-background: $manager-stage-background;
18
- $box-stage-background-dark: $manager-stage-background-dark;
19
- $box-stage-shadow: $manager-stage-shadow;
20
- $box-stage-shadow-dark: $manager-stage-shadow-dark;
31
+ $tele-colors-dark: (
32
+ managerContainerBackground: #25282e,
33
+ managerStageBackground: #272a30,
34
+ managerStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.24),
35
+ boxContainerBackground: #25282e,
36
+ boxStageBackground: #272a30,
37
+ boxStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.24),
38
+ boxColor: #e9e9e9,
39
+ boxBorder: 1px solid #383b42,
40
+ boxShadow: 0px 4px 10px 0px rgba(56, 59, 66, 0.15),
41
+ boxFooterColor: #e9e9e9,
42
+ boxFooterBackground: #383b42,
43
+ titlebarColor: #e9e9e9,
44
+ titlebarBackground: #383b42,
45
+ titlebarBorderBottom: none,
46
+ titlebarTabColor: #e9e9e9,
47
+ titlebarTabFocusColor: #357bf6,
48
+ titlebarTabBackground: transparent,
49
+ titlebarTabDividerColor: #7b88a0,
50
+ collectorBackground: #383b42,
51
+ collectorShadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15),
52
+ );
21
53
 
22
- $box-color: #191919;
23
- $box-color-dark: #e9e9e9;
24
- $box-border: 1px solid #e3e3ec;
25
- $box-border-dark: 1px solid #383b42;
26
- $box-shadow: 0px 4px 10px 0px rgba(47, 65, 146, 0.15);
27
- $box-shadow-dark: 0px 4px 10px 0px rgba(56, 59, 66, 0.15);
54
+ @mixin clr($property, $key) {
55
+ #{$property}: map-get($tele-colors, $key);
56
+ #{$property}: var(--tele-#{$key}, map-get($tele-colors, $key));
57
+ }
28
58
 
29
- $titlebar-color: #191919;
30
- $titlebar-color-dark: #e9e9e9;
31
- $titlebar-background: #fff;
32
- $titlebar-background-dark: #383b42;
33
- $titlebar-border-bottom: 1px solid #eeeef7;
34
- $titlebar-border-bottom-dark: none;
59
+ @mixin clr-dark($property, $key) {
60
+ #{$property}: map-get($tele-colors-dark, $key);
61
+ #{$property}: var(--tele-#{$key}, map-get($tele-colors-dark, $key));
62
+ }
35
63
 
36
- $titlebar-tab-color: #7b88a0;
37
- $titlebar-tab-color-dark: #e9e9e9;
38
- $titlebar-tab-focus-color: #357bf6;
39
- $titlebar-tab-focus-color-dark: #357bf6;
40
- $titlebar-tab-background: transparent;
41
- $titlebar-tab-background-dark: transparent;
42
- $titlebar-tab-divider-color: #e5e5f0;
43
- $titlebar-tab-divider-color-dark: #7b88a0;
64
+ @mixin clr-root() {
65
+ @each $key, $value in $tele-colors {
66
+ --tele-#{$key}: #{$value};
67
+ }
68
+ }
44
69
 
45
- $collector-background: #fff;
46
- $collector-background-dark: #383b42;
47
- $collector-shadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15);
48
- $collector-shadow-dark: $collector-shadow;
70
+ @mixin clr-root-dark() {
71
+ @each $key, $value in $tele-colors-dark {
72
+ --tele-#{$key}: #{$value};
73
+ }
74
+ }