-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add filter to
BuilderSidebarToolbar
. WF-42
I introduced a component named `BuilderSidebarTitleSearch` which extract the existing search logic of `BuilderSidebarTree` and use it for `BuilderSidebarToolbar`. I also took the opportunity to improve the accessibility since we use `<i>` elements as button, but they're not focusable and clickable with the keyboard. And finally, I introduced an E2E test which cover the new feature.
- Loading branch information
Showing
4 changed files
with
240 additions
and
92 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,99 @@ | ||
<template> | ||
<div v-if="isSearchActive" class="BuilderSidebarTitleSearch"> | ||
<input | ||
ref="searchInput" | ||
v-model="searchQuery" | ||
type="text" | ||
placeholder="Search..." | ||
/> | ||
<slot /> | ||
<i | ||
:class="{ disabled: disabled }" | ||
class="searchIcon material-symbols-outlined" | ||
title="Close" | ||
tabindex="0" | ||
@keydown.enter="toggleSearch" | ||
@click="toggleSearch" | ||
> | ||
close | ||
</i> | ||
</div> | ||
<div v-else class="BuilderSidebarTitleSearch"> | ||
<i class="material-symbols-outlined">{{ icon }}</i> | ||
<h3>{{ title }}</h3> | ||
<i | ||
title="Search" | ||
class="searchIcon material-symbols-outlined" | ||
tabindex="0" | ||
@keydown.enter="toggleSearch" | ||
@click="toggleSearch" | ||
> | ||
search | ||
</i> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { nextTick, ref, Ref } from "vue"; | ||
defineProps({ | ||
icon: { type: String, required: true }, | ||
title: { type: String, required: true }, | ||
disabled: { type: Boolean, required: false }, | ||
}); | ||
const searchQuery = defineModel({ type: String, default: "" }); | ||
defineEmits({}); | ||
const searchInput: Ref<HTMLInputElement> = ref(null); | ||
const isSearchActive: Ref<boolean> = ref(false); | ||
async function toggleSearch() { | ||
isSearchActive.value = !isSearchActive.value; | ||
if (isSearchActive.value) { | ||
await nextTick(); | ||
searchInput.value.focus(); | ||
} else { | ||
searchQuery.value = ""; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
@import "./sharedStyles.css"; | ||
.BuilderSidebarTitleSearch { | ||
display: flex; | ||
gap: 8px; | ||
align-items: center; | ||
font-size: 1rem; | ||
background: var(--builderBackgroundColor); | ||
padding: 16px; | ||
top: 0; | ||
position: sticky; | ||
font-size: 1rem; | ||
} | ||
.BuilderSidebarTitleSearch h3 { | ||
font-weight: 500; | ||
font-size: 0.875rem; | ||
flex-grow: 1; | ||
} | ||
.BuilderSidebarTitleSearch .searchIcon { | ||
cursor: pointer; | ||
} | ||
.BuilderSidebarTitleSearch .searchIcon.disabled { | ||
color: var(--builderDisabledColor); | ||
} | ||
.BuilderSidebarTitleSearch input { | ||
outline: 0; | ||
border: 0; | ||
flex-grow: 1; | ||
width: 50%; | ||
} | ||
</style> |
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
Oops, something went wrong.