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 <c-button>) 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 <sharevb@gmail.com>
This commit is contained in:
Dandyandyandsharevb authored and ShareVB committed 2025-03-23 22:40:15 +01:00
1 parent a06daf29fd
commit 21d35801ac
10 files changed
+37 -3

No files matched your search

+35 -1
View File
@@ -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();
</script>
<template>
<!--
A button at the top to expand or collapse all categories at once.
- Uses areAllCollapsed to determine the label ("Expand All" vs. "Collapse All").
- Calls toggleAllCategories() on click.
-->
<div class="top-controls" ml-6px>
<c-button @click="toggleAllCategories">
{{ areAllCollapsed ? 'Expand All Tools' : 'Collapse All Tools' }}
</c-button>
</div>
<div v-for="{ name, tools, isCollapsed } of menuOptions" :key="name">
<div ml-6px mt-12px flex cursor-pointer items-center op-60 @click="toggleCategoryCollapse({ name })">
<span :class="{ 'rotate-0': isCollapsed, 'rotate-90': !isCollapsed }" text-16px lh-1 op-50 transition-transform>
@@ -11,11 +11,11 @@ const output = ref('');
const errored = ref(false);
const processing = ref(false);
figlet.defaults({ fontPath: '//unpkg.com/figlet@1.6.0/fonts/' });
figlet.defaults({ fontPath: '//unpkg.com/figlet@1.8.0/fonts' });
const languagesOptions = languages.map(lang => ({ value: lang.id, label: lang.name }));
figlet.defaults({ fontPath: '//unpkg.com/figlet@1.6.0/fonts/' });
figlet.defaults({ fontPath: '//unpkg.com/figlet@1.8.0/fonts' });
watchEffect(async () => {
const inputValue = input.value;
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.