Skip to content

Commit

Permalink
feat(ui): add filter to BuilderSidebarToolbar. WF-42
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Aug 13, 2024
1 parent 8a80db3 commit 15306e5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/ui/src/builder/BuilderSidebarToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<i class="material-symbols-outlined"> handyman </i>
<h3>Toolkit</h3>
</div>
<WdsTextInput
v-model="searchQuery"
placeholder="Search a component"
left-icon="search"
/>
<div class="categories">
<template
v-for="(categoryData, category) in categoriesData"
Expand Down Expand Up @@ -63,6 +68,7 @@ import { Ref, computed, inject, ref } from "vue";
import { useDragDropComponent } from "./useDragDropComponent";
import injectionKeys from "../injectionKeys";
import { Component, WriterComponentDefinition } from "../writerTypes";
import WdsTextInput from "../wds/WdsTextInput.vue";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand All @@ -74,6 +80,8 @@ type CategoryData = {
icon?: string;
};
const searchQuery = ref("");
const categoriesData: Ref<Record<string, CategoryData>> = ref({
Root: {
isVisible: false,
Expand Down Expand Up @@ -114,6 +122,15 @@ const definitionsByDisplayCategory = computed(() => {
types.map((type) => {
const definition = wf.getComponentDefinition(type);
const matchingSearch =
searchQuery.value === "" ||
definition.name
.toLocaleLowerCase()
.includes(searchQuery.value.toLocaleLowerCase());
if (!matchingSearch) return;
const isMatch = Object.keys(categoriesData.value).includes(
definition.category,
);
Expand Down

0 comments on commit 15306e5

Please sign in to comment.