@netless/fastboard-ui 1.0.0-canary.6 → 1.0.0-canary.7

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": "1.0.0-canary.6",
3
+ "version": "1.0.0-canary.7",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -13,14 +13,14 @@
13
13
  ],
14
14
  "repository": "netless-io/fastboard",
15
15
  "peerDependencies": {
16
- "@netless/fastboard-core": "1.0.0-canary.6"
16
+ "@netless/fastboard-core": "1.0.0-canary.7"
17
17
  },
18
18
  "dependencies": {
19
19
  "tippy.js": "^6.3.7"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@netless/esbuild-plugin-inline-sass": "0.1.0",
23
- "@netless/fastboard-core": "1.0.0-canary.6"
23
+ "@netless/fastboard-core": "1.0.0-canary.7"
24
24
  },
25
25
  "scripts": {
26
26
  "cleanup": "rimraf dist",
@@ -7,6 +7,7 @@
7
7
  export { className as class };
8
8
  export let name = "fastboard-ui";
9
9
  export let theme: Theme = "light";
10
+ export let active = false;
10
11
  export let disabled = false;
11
12
  export let content: Content = "";
12
13
  export let placement: Placement = "top";
@@ -19,6 +20,7 @@
19
20
  <span class="{name}-btn-interactive {theme}" use:tippy={{ content, placement, className }}>
20
21
  <button
21
22
  class="{name}-btn {className} {theme}"
23
+ class:is-active={active}
22
24
  {disabled}
23
25
  on:click
24
26
  use:tippy={{
@@ -37,6 +39,7 @@
37
39
  {:else}
38
40
  <button
39
41
  class="{name}-btn {className} {theme}"
42
+ class:is-active={active}
40
43
  {disabled}
41
44
  on:click
42
45
  use:tippy={{ content, placement, className }}
@@ -45,7 +48,7 @@
45
48
  </button>
46
49
  {/if}
47
50
  {:else}
48
- <button class="{name}-btn {className} {theme}" {disabled} on:click>
51
+ <button class="{name}-btn {className} {theme}" class:is-active={active} {disabled} on:click>
49
52
  <slot />
50
53
  </button>
51
54
  {/if}
@@ -6,6 +6,7 @@ export declare interface ButtonProps {
6
6
  class?: string;
7
7
  name?: string;
8
8
  theme?: Theme;
9
+ active?: boolean;
9
10
  disabled?: boolean;
10
11
  content?: Content;
11
12
  placement?: Placement;
@@ -17,14 +17,14 @@
17
17
  display: flex;
18
18
  align-items: center;
19
19
  position: absolute;
20
- bottom: 62px;
20
+ bottom: 50px;
21
21
  top: 8px;
22
22
  left: 0;
23
23
  z-index: 200;
24
24
  pointer-events: none;
25
25
 
26
26
  .fastboard-toolbar {
27
- padding-left: 16px;
27
+ padding-left: 8px;
28
28
  }
29
29
  }
30
30
 
@@ -34,7 +34,6 @@
34
34
  position: absolute;
35
35
  bottom: 8px;
36
36
  left: 8px;
37
- padding: 8px;
38
37
  z-index: 200;
39
38
  pointer-events: none;
40
39
  }
@@ -7,12 +7,12 @@ $name: "fastboard-toolbar";
7
7
  display: flex;
8
8
  align-items: center;
9
9
  position: relative;
10
- transform: translateX(0);
11
- transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
10
+ left: 0px;
11
+ transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
12
12
  pointer-events: none;
13
13
 
14
14
  &.collapsed {
15
- transform: translateX(-100%);
15
+ left: -100%;
16
16
  }
17
17
  }
18
18
 
@@ -71,7 +71,7 @@ $name: "fastboard-toolbar";
71
71
  }
72
72
 
73
73
  .#{$name}-btn {
74
- @include btn(32px, 4px);
74
+ @include btn(32px, 4px, 8px);
75
75
  }
76
76
 
77
77
  @import "./components/Slider.scss";
@@ -45,20 +45,29 @@
45
45
  </div>
46
46
  <label class="{name}-handler {theme}">
47
47
  <input type="checkbox" bind:checked={collapsed} />
48
- <svg fill="none" stroke-width="2" viewBox="0 0 32 120">
48
+ <svg width="17" height="42" viewBox="0 0 17 42" fill="none">
49
49
  <path
50
+ d="M0 41H12C14.2091 41 16 39.2091 16 37V5C16 2.79086 14.2091 1 12 1H0"
51
+ stroke="#000"
50
52
  fill="#fff"
51
- stroke="none"
52
- d="m0 0 24 16q6 4 6 14v60q0 10-6 14L0 120"
53
- class="{name}-handler-bg-color"
53
+ class="{name}-handler-border-color {name}-handler-bg-color"
54
54
  />
55
- <path stroke="#000" d="m0 0 24 16q6 4 6 14v60q0 10-6 14L0 120" class="{name}-handler-border-color" />
56
55
  {#if collapsed}
57
- <path stroke="#000" d="M10 52v16" class="{name}-handler-image-stroke-color" />
58
- <path fill="#000" stroke="none" d="M14 52v16l8-8z" class="{name}-handler-image-fill-color" />
56
+ <path
57
+ fill-rule="evenodd"
58
+ clip-rule="evenodd"
59
+ d="M8 19L6 17V25L8 23L10 21L8 19ZM4 17H5V25H4V17Z"
60
+ fill="#fff"
61
+ class="{name}-handler-image-fill-color"
62
+ />
59
63
  {:else}
60
- <path stroke="#000" d="M20 52v16" class="{name}-handler-image-stroke-color" />
61
- <path fill="#000" stroke="none" d="M16 52v16l-8-8z" class="{name}-handler-image-fill-color" />
64
+ <path
65
+ fill-rule="evenodd"
66
+ clip-rule="evenodd"
67
+ d="M6 19L8 17V25L6 23L4 21L6 19ZM10 17H9V25H10V17Z"
68
+ fill="#fff"
69
+ class="{name}-handler-image-fill-color"
70
+ />
62
71
  {/if}
63
72
  </svg>
64
73
  </label>
@@ -20,8 +20,8 @@ $name: "fastboard-toolbar";
20
20
  .#{$name}-triangle {
21
21
  width: 0px;
22
22
  height: 0px;
23
- border-bottom: 4px solid;
24
- border-left: 4px solid transparent;
23
+ border-bottom: 3px solid;
24
+ border-left: 3px solid transparent;
25
25
  position: absolute;
26
26
  bottom: 0;
27
27
  right: 0;
@@ -36,7 +36,7 @@ $name: "fastboard-toolbar";
36
36
  overflow: hidden;
37
37
  display: flex;
38
38
  flex-direction: column;
39
- gap: 4px;
39
+ gap: 0;
40
40
  }
41
41
 
42
42
  .#{$name}-tooltip {
@@ -121,35 +121,68 @@
121
121
  </Button>
122
122
  {/if}
123
123
  <div class="{name}-scrollable" class:scrollable use:scrollHeight={scroll_height} use:scrollTop={top}>
124
- <Button class="clicker" {...btn_props} on:click={clicker} content={c.clicker}>
124
+ <Button
125
+ class="clicker"
126
+ active={appliance === "clicker"}
127
+ {...btn_props}
128
+ on:click={clicker}
129
+ content={c.clicker}
130
+ >
125
131
  {#if appliance === "clicker"}
126
132
  <Icons.ClickFilled {theme} active />
127
133
  {:else}
128
134
  <Icons.Click {theme} />
129
135
  {/if}
130
136
  </Button>
131
- <Button class="selector" {...btn_props} on:click={selector} content={c.selector}>
137
+ <Button
138
+ class="selector"
139
+ active={appliance === "selector"}
140
+ {...btn_props}
141
+ on:click={selector}
142
+ content={c.selector}
143
+ >
132
144
  {#if appliance === "selector"}
133
145
  <Icons.SelectorFilled {theme} active />
134
146
  {:else}
135
147
  <Icons.Selector {theme} />
136
148
  {/if}
137
149
  </Button>
138
- <Button class="pencil" {...btn_props} on:click={pencil} content={c.pencil} menu={pencil_panel}>
150
+ <Button
151
+ class="pencil"
152
+ active={appliance === "pencil"}
153
+ {...btn_props}
154
+ on:click={pencil}
155
+ content={c.pencil}
156
+ menu={pencil_panel}
157
+ >
139
158
  {#if appliance === "pencil"}
140
159
  <Icons.PencilFilled {theme} active />
141
160
  {:else}
142
161
  <Icons.Pencil {theme} />
143
162
  {/if}
144
163
  </Button>
145
- <Button class="text" {...btn_props} on:click={text} content={c.text} menu={text_panel}>
164
+ <Button
165
+ class="text"
166
+ active={appliance === "text"}
167
+ {...btn_props}
168
+ on:click={text}
169
+ content={c.text}
170
+ menu={text_panel}
171
+ >
146
172
  {#if appliance === "text"}
147
173
  <Icons.TextFilled {theme} active />
148
174
  {:else}
149
175
  <Icons.Text {theme} />
150
176
  {/if}
151
177
  </Button>
152
- <Button class="shapes" {...btn_props} on:click={select_last_shape} content={t.shapes} menu={shapes_panel}>
178
+ <Button
179
+ class="shapes"
180
+ active={appliance === last_shape || (appliance === "shape" && shape === last_shape)}
181
+ {...btn_props}
182
+ on:click={select_last_shape}
183
+ content={t.shapes}
184
+ menu={shapes_panel}
185
+ >
153
186
  {#if appliance === last_shape || (appliance === "shape" && shape === last_shape)}
154
187
  <svelte:component this={shapesIconActive[last_shape]} {theme} active />
155
188
  {:else}
@@ -157,7 +190,13 @@
157
190
  {/if}
158
191
  </Button>
159
192
  {#if eraser_type === "delete"}
160
- <Button class="eraser" {...btn_props} on:click={select_eraser} content={c.eraser}>
193
+ <Button
194
+ class="eraser"
195
+ active={appliance === "eraser"}
196
+ {...btn_props}
197
+ on:click={select_eraser}
198
+ content={c.eraser}
199
+ >
161
200
  {#if appliance === "eraser"}
162
201
  <Icons.EraserFilled {theme} active />
163
202
  {:else}
@@ -167,6 +206,7 @@
167
206
  {:else if eraser_type === "pencil"}
168
207
  <Button
169
208
  class="eraser"
209
+ active={appliance === "pencilEraser"}
170
210
  {...btn_props}
171
211
  on:click={select_pencil_eraser}
172
212
  content={c.pencilEraser}
@@ -181,6 +221,7 @@
181
221
  {:else}
182
222
  <Button
183
223
  class="eraser"
224
+ active={appliance === last_eraser}
184
225
  {...btn_props}
185
226
  on:click={select_last_eraser}
186
227
  content={t[last_eraser]}
@@ -229,6 +270,7 @@
229
270
  <div class="{name}-panel-btns">
230
271
  <Button
231
272
  class="eraser"
273
+ active={appliance === "pencilEraser"}
232
274
  {...btn_props}
233
275
  on:click={select_pencil_eraser}
234
276
  placement="top"
@@ -242,6 +284,7 @@
242
284
  </Button>
243
285
  <Button
244
286
  class="eraser"
287
+ active={appliance === "eraser"}
245
288
  {...btn_props}
246
289
  on:click={select_eraser}
247
290
  placement="top"
@@ -7,6 +7,7 @@ $themes: (
7
7
  active-color: $blue-6,
8
8
  bg-color: color.change(white, $alpha: 0.9),
9
9
  hover-bg-color: $blue-1,
10
+ active-bg-color: $blue-1,
10
11
  border-color: $grey-1,
11
12
  ),
12
13
  dark: (
@@ -14,6 +15,7 @@ $themes: (
14
15
  active-color: $blue-7,
15
16
  bg-color: color.change($grey-10, $alpha: 0.9),
16
17
  hover-bg-color: $grey-8,
18
+ active-bg-color: $grey-8,
17
19
  border-color: $grey-8,
18
20
  ),
19
21
  );
@@ -58,7 +60,7 @@ $themes: (
58
60
  }
59
61
  }
60
62
 
61
- @mixin btn($size: 24px, $padding: 0) {
63
+ @mixin btn($size: 24px, $padding: 0, $radius: 4px) {
62
64
  appearance: none;
63
65
  cursor: pointer;
64
66
  margin: 0;
@@ -67,7 +69,7 @@ $themes: (
67
69
  width: $size;
68
70
  height: $size;
69
71
  background-color: transparent;
70
- border-radius: 4px;
72
+ border-radius: $radius;
71
73
  font-size: 0;
72
74
  line-height: 1;
73
75
  flex-shrink: 0;
@@ -85,8 +87,13 @@ $themes: (
85
87
  }
86
88
 
87
89
  @each $name, $theme in $themes {
88
- &.#{$name}:not(:disabled):hover {
89
- background-color: read($theme, "hover-bg-color");
90
+ &.#{$name}:not(:disabled) {
91
+ &:hover {
92
+ background-color: read($theme, "hover-bg-color");
93
+ }
94
+ &.is-active {
95
+ background-color: read($theme, "active-bg-color");
96
+ }
90
97
  }
91
98
  }
92
99
  }