Skip to content

Commit

Permalink
fix: updating ui config raises error when toolbar is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Feb 5, 2024
1 parent d8117d6 commit acc4c28
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Fixed an error when UI config is updated to `{ toolbar: undefined }`.

## 0.3.11

- Added toolbar config `placement: "left" | "right"` and `items: ToolbarItem[]` to further control the style of toolbar; added 2 more tools `hand` and `laserPointer` to `ToolbarItem`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
class:hidden={!toolbar_has_items || !(layout === "visible" || layout === "toolbar-only")}
>
{#if config.toolbar?.enable !== false}
<Toolbar {app} {theme} {language} config={config.toolbar} />
<Toolbar {app} {theme} {language} config={config.toolbar || {}} />
{/if}
</div>
<div class="{name}-bottom-left" class:hidden={layout !== "visible"}>
Expand Down
3 changes: 2 additions & 1 deletion packages/fastboard-ui/src/components/Toolbar/Toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { height } from "../../actions/height";
import { clamp } from "../helpers";
import Contents from "./components/Contents.svelte";
import { default_items } from "./components/constants";
export let app: FastboardApp | null | undefined = null;
export let theme: Theme = "light";
Expand All @@ -25,7 +26,7 @@
$: scrollable = $scroll_height + extra_height > $container_height;
$: placement = config.placement || "left";
$: items = config.items;
$: items = config.items || default_items;
$: hide_apps = config.apps?.enable === false;
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { scrollTop } from "../../../actions/scroll";
import { tippy_hide_all } from "../../../actions/tippy";
import { clamp } from "../../helpers";
import { i18n } from "./constants";
import { default_items, i18n } from "./constants";
import { apps } from "../../../behaviors";
import { tooltip } from "./helper";
import Icons from "../../Icons";
Expand Down Expand Up @@ -36,7 +36,7 @@
export let computed_height = 0;
export let scrollable = false;
export let placement: "left" | "right" = "left";
export let items: ToolbarItem[] = ["clicker", "selector", "pencil", "text", "shapes", "eraser", "clear"];
export let items: ToolbarItem[] = default_items;
export let hide_apps = false;
const name = "fastboard-toolbar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import type { Appliance, Color } from "@netless/fastboard-core";
import type { I18nData, ToolbarItem } from "../../../typings";
import Icons from "../../Icons";

export const default_items: ToolbarItem[] = [
"clicker",
"selector",
"pencil",
"text",
"shapes",
"eraser",
"clear",
];

export const colors: Record<string, Color> = {
"#E02020": [224, 32, 32],
"#F7B500": [247, 181, 0],
Expand Down

0 comments on commit acc4c28

Please sign in to comment.