Skip to content

Commit

Permalink
Merge pull request #26 from miyaoka/search-hashtag
Browse files Browse the repository at this point in the history
hashタグ右クリックで検索
  • Loading branch information
miyaoka authored Oct 2, 2024
2 parents 53aa6cd + 6ed86cf commit 47bf5cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/menu/keyword/KeywordListPopoverItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ defineProps<{
const searchStore = useSearchStore();
function setSearchTerm(term: string) {
function setSearchString(str: string) {
// 空白を含むならダブルクォーテーションで囲む
const formattedTerm = term.includes(" ") ? `"${term}"` : term;
const formattedStr = str.includes(" ") ? `"${str}"` : str;
// 同じものなら検索を解除
if (searchStore.searchString === formattedTerm) {
if (searchStore.searchString === formattedStr) {
searchStore.setSearchString("");
return;
}
searchStore.setSearchString(formattedTerm);
searchStore.setSearchString(formattedStr);
}
</script>

Expand All @@ -26,7 +26,7 @@ function setSearchTerm(term: string) {
v-for="item in itemList"
:key="item.value"
class="py-1 hover:bg-gray-100"
@click="setSearchTerm(item.value)"
@click="setSearchString(item.value)"
>
<div class="flex items-center gap-2 px-3 text-start">
<p class="line-clamp-2 flex-1 [overflow-wrap:anywhere]">
Expand Down
10 changes: 10 additions & 0 deletions src/components/streams/LiverEventCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ function onClickCard(evt: MouseEvent) {
if (!popover) return;
popover.showPopover();
}
function setSearchString(str: string) {
// 同じものなら検索を解除
if (searchStore.searchString === str) {
searchStore.setSearchString("");
return;
}
searchStore.setSearchString(str);
}
</script>
<template>
<div
Expand Down Expand Up @@ -235,6 +244,7 @@ function onClickCard(evt: MouseEvent) {
v-if="firstHash"
class="absolute bottom-0 right-0 flex max-w-[50%] flex-row gap-1 overflow-hidden rounded-tl-[10px] p-1 shadow-md"
:class="`${hasHoveredHash ? 'bg-amber-600 text-amber-100' : 'bg-blue-600 text-blue-100'}`"
@contextmenu.prevent="setSearchString(firstHash)"
>
<span class="whitespace-nowrap text-xs">#{{ firstHash }}</span>
</div>
Expand Down

0 comments on commit 47bf5cf

Please sign in to comment.