From 21d35801ac86d48b36d06a8f6f25a8cdeaf1dc61 Mon Sep 17 00:00:00 2001 From: Dandyandy <32077197+lastplace1990@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:25:37 -0600 Subject: [PATCH] fix: ASCII Text Drawer and menu - updated reference to figlet@1.8.0 - updated the fontPath URL Fix #40 feat(menu): default collapse state & add global toggle button for improved UX (#35) - Changed the default behavior so that if no collapse state is stored, menu categories auto-collapse on first load. - Updated the computed logic to default the collapsed state to true when undefined, ensuring a consistent initial UI. - Added new computed properties (areAllCollapsed) and a function (toggleAllCategories) to manage global collapse/expand behavior. - Introduced a top-level toggle button (using ) that allows users to expand or collapse all menu categories at once, aligning with the site's theme and improving overall UX/UI. --------- Co-authored-by: sharevb --- src/components/CollapsibleToolMenu.vue | 36 ++++++++++++++++++- .../ascii-text-drawer/ascii-text-drawer.vue | 4 +-- ...text-to-binary.e2e.spec.ts:Zone.Identifier | 0 ...t-to-binary.models.test.ts:Zone.Identifier | 0 .../text-to-binary.models.ts:Zone.Identifier | 0 .../text-to-binary.vue:Zone.Identifier | 0 ...ext-to-unicode.e2e.spec.ts:Zone.Identifier | 0 ...to-unicode.service.test.ts:Zone.Identifier | 0 ...text-to-unicode.service.ts:Zone.Identifier | 0 .../text-to-unicode.vue:Zone.Identifier | 0 10 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/tools/text-to-binary/text-to-binary.e2e.spec.ts:Zone.Identifier create mode 100644 src/tools/text-to-binary/text-to-binary.models.test.ts:Zone.Identifier create mode 100644 src/tools/text-to-binary/text-to-binary.models.ts:Zone.Identifier create mode 100644 src/tools/text-to-binary/text-to-binary.vue:Zone.Identifier create mode 100644 src/tools/text-to-unicode/text-to-unicode.e2e.spec.ts:Zone.Identifier create mode 100644 src/tools/text-to-unicode/text-to-unicode.service.test.ts:Zone.Identifier create mode 100644 src/tools/text-to-unicode/text-to-unicode.service.ts:Zone.Identifier create mode 100644 src/tools/text-to-unicode/text-to-unicode.vue:Zone.Identifier diff --git a/src/components/CollapsibleToolMenu.vue b/src/components/CollapsibleToolMenu.vue index 9a73ddd6..bd3045cf 100644 --- a/src/components/CollapsibleToolMenu.vue +++ b/src/components/CollapsibleToolMenu.vue @@ -29,10 +29,33 @@ function toggleCategoryCollapse({ name }: { name: string }) { collapsedCategories.value[name] = !collapsedCategories.value[name]; } +/** + * areAllCollapsed (new) + * -------------------------------------------------------------------------- + * A computed property that checks if all categories are collapsed. + * - If even one category is expanded (false), this becomes false. + * - If no categories are found or all are collapsed (true), it becomes true. + */ +const areAllCollapsed = computed(() => { + return toolsByCategory.value.every(({ name }) => collapsedCategories.value[name] !== false); +}); + +/** + * toggleAllCategories (new) + * -------------------------------------------------------------------------- + * If all categories are collapsed, expand them all; otherwise, collapse them all. + */ +function toggleAllCategories() { + const nextState = !areAllCollapsed.value; + toolsByCategory.value.forEach(({ name }) => { + collapsedCategories.value[name] = nextState; + }); +}; + const menuOptions = computed(() => toolsByCategory.value.map(({ name, components }) => ({ name, - isCollapsed: collapsedCategories.value[name], + isCollapsed: collapsedCategories.value[name] === undefined ? true : collapsedCategories.value[name], // default to collapsed if not set tools: components.map(tool => ({ label: makeLabel(tool), icon: makeIcon(tool), @@ -45,6 +68,17 @@ const themeVars = useThemeVars();