Skip to content

Commit

Permalink
Refactor UI: Combine 'Collapse All' and 'Show All' buttons into a sin…
Browse files Browse the repository at this point in the history
…gle toggle button for improved usability
  • Loading branch information
tarunsinghofficial committed Jan 21, 2025
1 parent 93c4ed9 commit 434470a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/routes/stops/[stopID]/schedule/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
let stopDirection = $state('');
let loading = $state(true);
let accordionComponent = $state();
let allRoutesExpanded = $state(false);
let schedulesMap = new Map();
let routeReference = new Map();
Expand Down Expand Up @@ -105,6 +106,15 @@
return grouped;
}
function toggleAllRoutes() {
if (allRoutesExpanded) {
accordionComponent.closeAll();
} else {
accordionComponent.openAll();
}
allRoutesExpanded = !allRoutesExpanded;
}
onMount(async () => {
const formattedDate = currentDate.toISOString().split('T')[0];
await fetchScheduleForStop(stopId, formattedDate);
Expand Down Expand Up @@ -148,11 +158,10 @@
</div>
<div class="flex-1 text-right">
<button class="button" onclick={() => accordionComponent.openAll()}>
{$t('schedule_for_stop.show_all_routes')}
</button>
<button class="button" onclick={() => accordionComponent.closeAll()}>
{$t('schedule_for_stop.collapse_all_routes')}
<button class="button" onclick={toggleAllRoutes}>
{allRoutesExpanded
? $t('schedule_for_stop.collapse_all_routes')
: $t('schedule_for_stop.show_all_routes')}
</button>
</div>
</div>
Expand Down

0 comments on commit 434470a

Please sign in to comment.