-
-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: show tag hover card when hovering cursor on hashtag links #2621
Merged
Merged
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
385fa0f
feat: show tag hover card when hovering cursor on hashtag links
shuuji3 0d3ec43
text: update snapshot as `TagHoverWrapper` adds one `<span>` wrapper
shuuji3 381d166
fix: avoid aggressive tag fetch call by moving `fetchTag()` to `TagCa…
shuuji3 32b1151
fix: adjust tag hovercard layout
shuuji3 de8e26a
test: update vitest snapshot
shuuji3 f7c376a
chore: avoid fetching card until visible
userquin 9b3184d
Revert "test: update vitest snapshot"
shuuji3 1019773
fix: remove unnecessary async
shuuji3 c1bce74
feat: improve tag card layout
shuuji3 acd15de
test: set `test.pool` = `forks` to fix pending test issue
shuuji3 3ed696f
fix: store a resolved promise when resolving cache result
userquin 3219d65
fix(cache): cache fetch promises until resolved
userquin 4bb6bdb
fix(cache): cache fetch promises until resolved also for account by id
userquin 23bc2e9
chore: don't store promise, return the promise when requested
userquin 9b8056f
chore: .
userquin 89f0a47
chore: rever account hover changes
userquin 0056238
chore: revert fetch promises
userquin b84c7f0
chore: remove pool forks
userquin 2215703
chore: don't fetch when running tests
userquin da7dddd
chore: return resolved promise when cached instead the cached
userquin 35cc206
chore: include `hide_account_and_tag_hover_card` translation for es-ES
userquin 0f05142
chore: cleanup tag hover wrapper
userquin d19770d
feat: split `hideAccountHoverCard` and `hideTagHoverCard` settings
shuuji3 f6b2471
feat: fetch tag cache just once after hovering
shuuji3 db070ee
test: update vitest snapshot
shuuji3 8364abc
fix: check hovered value in watch and fetch tag cache each mouse hove…
shuuji3 d327c60
feat: show TagCardSkeleton during loading tag data
shuuji3 f67be19
refactor: use `useElementHover` for hover state detection
shuuji3 95fdea6
fix: revert show delay to initial 500ms included by mistake
shuuji3 9b9d74b
chore: update spanish entries
userquin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,68 @@ | ||
<script setup lang="ts"> | ||
import type { mastodon } from 'masto' | ||
import { fetchTag } from '~/composables/cache' | ||
|
||
type WatcherType = [tag?: mastodon.v1.Tag, tagName?: string, v?: boolean] | ||
|
||
defineOptions({ | ||
inheritAttrs: false, | ||
}) | ||
|
||
const props = defineProps<{ | ||
tag?: mastodon.v1.Tag | ||
tagName?: string | ||
disabled?: boolean | ||
}>() | ||
|
||
const hoverCard = ref() | ||
const targetIsVisible = ref(false) | ||
const tag = ref<mastodon.v1.Tag | null | undefined>(props.tag) | ||
|
||
useIntersectionObserver( | ||
hoverCard, | ||
([{ intersectionRatio }]) => { | ||
targetIsVisible.value = intersectionRatio > 0.1 | ||
}, | ||
) | ||
|
||
watch( | ||
() => [props.tag, props.tagName, targetIsVisible.value] satisfies WatcherType, | ||
([newTag, newTagName, newVisible], oldProps) => { | ||
if (newTag) { | ||
tag.value = newTag | ||
return | ||
} | ||
|
||
if (!newVisible || process.test) | ||
return | ||
|
||
if (newTagName) { | ||
const [_oldTag, oldTagName, _oldVisible] = oldProps ?? [undefined, undefined, false] | ||
if (!oldTagName || newTagName !== oldTagName || !tag.value) { | ||
fetchTag(newTagName).then((t) => { | ||
if (newTagName === props.tagName) | ||
tag.value = t | ||
}) | ||
} | ||
|
||
return | ||
} | ||
|
||
tag.value = undefined | ||
}, { immediate: true, flush: 'post' }, | ||
) | ||
|
||
const userSettings = useUserSettings() | ||
</script> | ||
|
||
<template> | ||
<span ref="hoverCard"> | ||
<VMenu v-if="!disabled && tag && !getPreferences(userSettings, 'hideAccountAndTagHoverCard')" placement="bottom-start" :delay="{ show: 500, hide: 100 }" v-bind="$attrs" :close-on-content-click="false"> | ||
<slot /> | ||
<template #popper> | ||
<TagCard v-if="tag" :tag="tag" /> | ||
</template> | ||
</VMenu> | ||
<slot v-else /> | ||
</span> | ||
</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
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
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
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gap also improves the layout of the hashtag page in Explore tab for very long hashtag names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for long tags the start should be top aligned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like the tag to always be aligned with the text below. I proposed having the star to the right, but I see now that it isn't a good idea. Maybe we should have the star always at the top left, and then the tag and the text below to the right of it. Or the star could be at the right of the graph, kind of like the Follow button in the notification cards for people following you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I tried another layout by making the follow button an independent block and placing it on the left. This ensures both texts are aligned and more robust with a long hashtag.
For Hovercard,
items-center
looks lined up better than the top. For Hashtag, both look fine.@patak-dev Which position do you prefer if we use this layout?
Hovercard
align center (
items-center
)align top (
items-start
)Hashtag page