-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from bcc-code/feature/better-contributor-ux
add component for selecting contributors
- Loading branch information
Showing
4 changed files
with
107 additions
and
85 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 |
---|---|---|
|
@@ -31,3 +31,7 @@ html { | |
0px 1px 4px 0px #0000000d, | ||
0px 0px 0px 1px #ffffff14; | ||
} | ||
|
||
* { | ||
outline-color: currentColor; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script | ||
setup | ||
lang="ts" | ||
generic="TOption extends string | number | boolean | object" | ||
> | ||
import type { ContributorModel } from "@bcc-code/bmm-sdk-fetch"; | ||
import { ContributorApi } from "@bcc-code/bmm-sdk-fetch"; | ||
defineProps<{ | ||
label?: string; | ||
}>(); | ||
const modelValue = defineModel<ContributorModel[]>(); | ||
const searchTerm = ref<string>(""); | ||
const contributors = ref<ContributorModel[]>([]); | ||
watchDebounced( | ||
searchTerm, | ||
async (search) => { | ||
if (search === "" || !search) { | ||
contributors.value = []; | ||
return; | ||
} | ||
contributors.value = | ||
await new ContributorApi().contributorSearchUnpublishedTermGet({ | ||
term: search, | ||
}); | ||
}, | ||
{ debounce: 100, immediate: true }, | ||
); | ||
watch(modelValue, (newValue, oldValue) => { | ||
if (!newValue || !oldValue) return; | ||
if (newValue !== oldValue) { | ||
searchTerm.value = ""; | ||
contributors.value = []; | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<ComboSearchBox | ||
v-model:search="searchTerm" | ||
v-model="modelValue" | ||
:label="label" | ||
:options="contributors" | ||
:option-key="(c) => c.id" | ||
:display-value="(option) => option.name!" | ||
> | ||
<template #option="{ option, selected }"> | ||
<div class="flex grow items-baseline gap-2"> | ||
<span>{{ option.name }}</span> | ||
<div class="type-subtitle-3 flex items-baseline gap-0.5 text-label-3"> | ||
(<span>{{ option.interpretReferences }}</span | ||
>|<span>{{ option.otherReferences }}</span | ||
>) | ||
</div> | ||
<NuxtIcon | ||
:class="[ | ||
'ml-auto', | ||
{ 'opacity-100': selected, 'opacity-0': !selected }, | ||
]" | ||
name="icon.checkmark" | ||
/> | ||
</div> | ||
</template> | ||
</ComboSearchBox> | ||
</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