@netless/fastboard-ui 0.3.0-canary.5 → 0.3.0

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/fastboard-ui",
3
- "version": "0.3.0-canary.5",
3
+ "version": "0.3.0",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -10,14 +10,14 @@
10
10
  ],
11
11
  "repository": "netless-io/fastboard",
12
12
  "peerDependencies": {
13
- "@netless/fastboard-core": "0.3.0-canary.5"
13
+ "@netless/fastboard-core": "0.3.0"
14
14
  },
15
15
  "dependencies": {
16
16
  "tippy.js": "^6.3.7"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@netless/esbuild-plugin-inline-sass": "0.1.0",
20
- "@netless/fastboard-core": "0.3.0-canary.5"
20
+ "@netless/fastboard-core": "0.3.0"
21
21
  },
22
22
  "scripts": {
23
23
  "cleanup": "rimraf dist",
@@ -64,6 +64,7 @@ export function tippy_hide_all() {
64
64
 
65
65
  export const tippy_menu: Partial<Props> = {
66
66
  delay: 0,
67
+ duration: [50, 300],
67
68
  placement: "right-start",
68
69
  interactive: true,
69
70
  trigger: "click",
@@ -26,8 +26,8 @@ class AppsInToolbar {
26
26
  this._listeners = this._listeners.filter(item => item !== fn);
27
27
  };
28
28
  }
29
- push(data: AppInToolbar) {
30
- this._data.push(data);
29
+ push(...data: AppInToolbar[]) {
30
+ this._data.push(...data);
31
31
  this._listeners.forEach(fn => fn(this._data));
32
32
  }
33
33
  insert(data: AppInToolbar, index: number) {
@@ -17,7 +17,16 @@
17
17
 
18
18
  let container: HTMLDivElement;
19
19
 
20
- $: if (app && container) app.bindContainer(container);
20
+ $: try {
21
+ if (app && container) app.bindContainer(container);
22
+ } catch (err) {
23
+ console.error("[fastboard] An error occurred while binding container");
24
+ console.error(err);
25
+ }
26
+
27
+ $: if (app && theme) {
28
+ app.manager.setPrefersColorScheme(theme);
29
+ }
21
30
 
22
31
  onMount(() => {
23
32
  if (containerRef) {
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { FastboardPlayer } from "@netless/fastboard-core";
3
3
  import type { Language, Theme } from "../../typings";
4
+ import { onMount } from "svelte";
4
5
  import { tippy_hide_all } from "../../actions/tippy";
5
6
  import PlayerControl from "../PlayerControl";
6
7
 
@@ -13,8 +14,25 @@
13
14
 
14
15
  let container: HTMLDivElement;
15
16
 
16
- $: if (player && container) player.bindContainer(container);
17
- $: if (containerRef) containerRef(container || null);
17
+ $: try {
18
+ if (player && container) player.bindContainer(container);
19
+ } catch (err) {
20
+ console.error("[fastboard] An error occurred while binding container");
21
+ console.error(err);
22
+ }
23
+
24
+ $: if (player && theme) {
25
+ player.manager.setPrefersColorScheme(theme);
26
+ }
27
+
28
+ onMount(() => {
29
+ if (containerRef) {
30
+ containerRef(container);
31
+ return () => {
32
+ if (containerRef) containerRef(null);
33
+ };
34
+ }
35
+ });
18
36
  </script>
19
37
 
20
38
  <div class="{name}-root" class:loading={!player}>
@@ -49,6 +49,7 @@
49
49
 
50
50
  function addPage() {
51
51
  app?.addPage({ after: true });
52
+ app?.nextPage();
52
53
  }
53
54
  </script>
54
55
 
@@ -132,7 +132,7 @@
132
132
  menu={speed_panel}
133
133
  menu_placement="top-end"
134
134
  >
135
- <span class="{name}-speed-text">{$speed}x</span>
135
+ <span class="{name}-speed-text">{$speed || 1}x</span>
136
136
  </Button>
137
137
  </div>
138
138
 
@@ -112,14 +112,15 @@ $name: "fastboard-toolbar";
112
112
 
113
113
  .#{$name}-panel.apps {
114
114
  display: grid;
115
- grid-template-columns: repeat(3, 1fr);
115
+ grid-template-columns: repeat(min(var(--n, 3), 3), minmax(max-content, 1fr));
116
116
  gap: 4px;
117
117
  }
118
118
 
119
119
  .#{$name}-app-btn {
120
120
  margin: 0;
121
121
  border: 0;
122
- padding: 4px;
122
+ border-radius: 2px;
123
+ padding: 4px 6px;
123
124
  background-color: transparent;
124
125
  display: inline-flex;
125
126
  flex-direction: column;
@@ -139,6 +140,7 @@ $name: "fastboard-toolbar";
139
140
 
140
141
  &-text {
141
142
  font-size: 14px;
143
+ line-height: 1;
142
144
  max-width: 100%;
143
145
  overflow: hidden;
144
146
  text-overflow: ellipsis;
@@ -172,8 +172,8 @@
172
172
  <div class="{name}-panel-divider" />
173
173
  <StrokeColor {app} {theme} {disabled} />
174
174
  </div>
175
- <div class="{name}-panel apps" bind:this={apps_panel}>
176
- {#each apps.data as netless_app (netless_app.kind)}
175
+ <div class="{name}-panel apps" style="--n:{$apps.length}" bind:this={apps_panel}>
176
+ {#each $apps as netless_app}
177
177
  {@const { icon, label, kind, onClick } = netless_app}
178
178
  {@const state = $status && $status[kind]}
179
179
  <button