From d3958f80fa068909fdb58e958930a6283bdae003 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 31 Jul 2021 18:20:51 -0700 Subject: [PATCH] Add checkbox to MenuBarInput widget --- client/web/src/components/panels/Document.vue | 4 +-- .../widgets/floating-menus/MenuList.vue | 32 +++++++++++++++---- .../widgets/inputs/CheckboxInput.vue | 30 ++++++++++++++++- .../widgets/inputs/MenuBarInput.vue | 2 +- 4 files changed, 57 insertions(+), 11 deletions(-) diff --git a/client/web/src/components/panels/Document.vue b/client/web/src/components/panels/Document.vue index e2ddfe89c..46cdf9dda 100644 --- a/client/web/src/components/panels/Document.vue +++ b/client/web/src/components/panels/Document.vue @@ -308,8 +308,8 @@ export default defineComponent({ const { reset_colors } = await wasm; reset_colors(); }, - download(filename: string, svgData: string) { - const svgBlob = new Blob([svgData], { type: "image/svg+xml;charset=utf-8" }); + download(filename: string, fileData: string) { + const svgBlob = new Blob([fileData], { type: "image/svg+xml;charset=utf-8" }); const svgUrl = URL.createObjectURL(svgBlob); const element = document.createElement("a"); diff --git a/client/web/src/components/widgets/floating-menus/MenuList.vue b/client/web/src/components/widgets/floating-menus/MenuList.vue index 9fa40245a..cb1e5857e 100644 --- a/client/web/src/components/widgets/floating-menus/MenuList.vue +++ b/client/web/src/components/widgets/floating-menus/MenuList.vue @@ -12,13 +12,18 @@ @mouseleave="handleEntryMouseLeave(entry)" :data-hover-menu-spawner-extend="entry.children && []" > - -
+ + +
+ - + + +
+ ; @@ -134,14 +149,14 @@ interface MenuListEntryData { value?: string; label?: string; icon?: string; - // TODO: Add `checkbox` (which overrides any `icon`) + checkbox?: boolean; shortcut?: Array; shortcutRequiresLock?: boolean; action?: Function; children?: SectionsOfMenuListEntries; } -export type MenuListEntry = MenuListEntryData & { ref?: typeof FloatingMenu | typeof MenuList }; +export type MenuListEntry = MenuListEntryData & { ref?: typeof FloatingMenu | typeof MenuList; checked?: boolean }; const KEYBOARD_LOCK_USE_FULLSCREEN = "This hotkey is reserved by the browser, but becomes available in fullscreen mode"; const KEYBOARD_LOCK_SWITCH_BROWSER = "This hotkey is reserved by the browser, but becomes available in Chrome, Edge, and Opera which support the Keyboard.lock() API"; @@ -164,6 +179,8 @@ const MenuList = defineComponent({ handleEntryClick(menuEntry: MenuListEntry) { (this.$refs.floatingMenu as typeof FloatingMenu).setClosed(); + if (menuEntry.checkbox) menuEntry.checked = !menuEntry.checked; + if (menuEntry.action) menuEntry.action(); else if (this.defaultAction) this.defaultAction(); else this.$emit("update:activeEntry", menuEntry); @@ -259,6 +276,7 @@ const MenuList = defineComponent({ FloatingMenu, Separator, IconLabel, + CheckboxInput, UserInputLabel, }, }); diff --git a/client/web/src/components/widgets/inputs/CheckboxInput.vue b/client/web/src/components/widgets/inputs/CheckboxInput.vue index b5224f9d4..2fb9871fb 100644 --- a/client/web/src/components/widgets/inputs/CheckboxInput.vue +++ b/client/web/src/components/widgets/inputs/CheckboxInput.vue @@ -1,5 +1,5 @@