-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: toggle features from map toolbar
- Loading branch information
1 parent
30fcd40
commit c0ee7a7
Showing
3 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script lang="ts" setup> | ||
import { ChevronDown } from "lucide-vue-next"; | ||
import { useGeojsonStore } from "@/stores/use-geojson-store.ts"; | ||
import type { GeojsonMapSchema } from "@/types/global.d"; | ||
interface Props { | ||
params: Zod.infer<typeof GeojsonMapSchema>["params"]; | ||
} | ||
const props = defineProps<Props>(); | ||
const { params } = toRefs(props); | ||
const GeojsonStore = useGeojsonStore(); | ||
const { tables } = storeToRefs(GeojsonStore); | ||
const table = computed(() => tables.value.get(params.value.url)); | ||
const categories = computed(() => { | ||
return table.value?.getAllColumns().filter((column) => column.getCanHide()); | ||
}); | ||
function titleCase(s: string) { | ||
return s | ||
.replace(/^[-_]*(.)/, (_, c) => c.toUpperCase()) // Initial char (after -/_) | ||
.replace(/[-_]+(.)/g, (_, c) => " " + c.toUpperCase()); // First char after each -/_ | ||
} | ||
const isCollapsibleOpen = ref(categories.value!.map(() => false)); | ||
</script> | ||
|
||
<template> | ||
<div class="grid items-center border-b border-border bg-surface px-8 py-3 text-on-surface"> | ||
<div class="flex flex-wrap items-center gap-x-4 gap-y-1 text-sm font-medium text-on-surface/75"> | ||
<div v-for="(group, idx) in categories" :key="group.id"> | ||
<DropdownMenu v-slot="{ open }" v-model:open="isCollapsibleOpen[idx]"> | ||
<DropdownMenuTrigger class="flex w-full items-center gap-1 p-2 text-sm"> | ||
<span>{{ titleCase(group.id) }}</span> | ||
<ChevronDown class="size-4" :class="open ? 'rotate-180' : ''"></ChevronDown> | ||
</DropdownMenuTrigger> | ||
|
||
<DropdownMenuContent class=""> | ||
<DropdownMenuCheckboxItem | ||
v-for="column in group.columns" | ||
:key="column.id" | ||
:checked="column.getIsVisible()" | ||
@select.prevent | ||
@update:checked=" | ||
(value) => { | ||
column.toggleVisibility(!!value); | ||
column.setFilterValue([]); | ||
} | ||
" | ||
> | ||
{{ column.columnDef.header }} | ||
</DropdownMenuCheckboxItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters