Skip to content

Commit 1a0f81a

Browse files
arashsheydaantfu
andauthored
feat: add search functionality to components graph (#696)
Co-authored-by: Anthony Fu <[email protected]>
1 parent 19ac073 commit 1a0f81a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/devtools/client/components/ComponentsGraph.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const {
3535
3636
const selectedFilter = ref<ComponentRelationship>()
3737
38+
const search = ref('')
39+
const searchDebounced = useDebounce(search, 300)
40+
3841
const entries = computed(() => {
3942
const relations = (props.relationships || [])
4043
if (selectedFilter.value) {
@@ -89,16 +92,18 @@ const data = computed<Data>(() => {
8992
? 'square'
9093
: 'dot'
9194
95+
const isGrayedOut = searchDebounced.value && !rel.id.toLowerCase().includes(searchDebounced.value.toLowerCase())
96+
9297
return {
9398
id: rel.id,
9499
label: path.split('/').splice(-1)[0].replace(/\.\w+$/, ''),
95100
group,
96101
shape,
97102
size: 15 + Math.min(rel.deps.length / 2, 8),
98103
font: {
99-
color: colorMode.value === 'dark' ? 'white' : 'black',
104+
color: isGrayedOut ? '#8885' : (colorMode.value === 'dark' ? 'white' : 'black'),
100105
},
101-
color: selectedFilter.value?.id === rel.id ? '#82c742' : undefined,
106+
color: isGrayedOut ? '#8885' : selectedFilter.value?.id === rel.id ? '#82c742' : undefined,
102107
// @ts-expect-error additional data
103108
extra: {
104109
id: rel.id,
@@ -200,8 +205,8 @@ function setFilter() {
200205
</script>
201206

202207
<template>
203-
<NNavbar ref="navbar" absolute left-0 right-0 top-0>
204-
<template #search>
208+
<NNavbar ref="navbar" v-model:search="search" absolute left-0 right-0 top-0>
209+
<template #actions>
205210
<div flex="~ gap-4 wrap" w-full>
206211
<NCheckbox v-model="showPages" n="primary sm">
207212
<span op75>Show pages</span>

0 commit comments

Comments
 (0)