fix invisible old popover, cleanup, add selection indicator in mentionlinks

This commit is contained in:
Henry Jameson 2022-06-27 14:26:47 +03:00
parent a0ddfa499f
commit 81bf18a311
3 changed files with 28 additions and 31 deletions

View File

@ -36,6 +36,11 @@ const MentionLink = {
type: String type: String
} }
}, },
data () {
return {
hasSelection: false
}
},
methods: { methods: {
onClick () { onClick () {
if (this.shouldShowTooltip) return if (this.shouldShowTooltip) return
@ -44,8 +49,17 @@ const MentionLink = {
this.userScreenName || this.user.screen_name this.userScreenName || this.user.screen_name
) )
this.$router.push(link) this.$router.push(link)
},
handleSelection () {
this.hasSelection = document.getSelection().containsNode(this.$refs.full, true)
} }
}, },
mounted () {
document.addEventListener('selectionchange', this.handleSelection)
},
unmounted () {
document.removeEventListener('selectionchange', this.handleSelection)
},
computed: { computed: {
user () { user () {
return this.url && this.$store && this.$store.getters.findUserByUrl(this.url) return this.url && this.$store && this.$store.getters.findUserByUrl(this.url)
@ -91,7 +105,8 @@ const MentionLink = {
return [ return [
{ {
'-you': this.isYou && this.shouldBoldenYou, '-you': this.isYou && this.shouldBoldenYou,
'-highlighted': this.highlight '-highlighted': this.highlight,
'-has-selection': this.hasSelection
}, },
this.highlightType this.highlightType
] ]

View File

@ -55,11 +55,14 @@
.new { .new {
&.-you { &.-you {
& .shortName, .shortName {
& .full {
font-weight: 600; font-weight: 600;
} }
} }
&.-has-selection {
color: var(--alertNeutralText, $fallback--text);
background-color: var(--alertNeutral, $fallback--fg);
}
.at { .at {
color: var(--link); color: var(--link);
@ -72,8 +75,7 @@
} }
&.-striped { &.-striped {
& .shortName, & .shortName {
& .full {
background-image: background-image:
repeating-linear-gradient( repeating-linear-gradient(
135deg, 135deg,
@ -86,31 +88,25 @@
} }
&.-solid { &.-solid {
& .shortName, .shortName {
& .full {
background-image: linear-gradient(var(--____highlight-tintColor2), var(--____highlight-tintColor2)); background-image: linear-gradient(var(--____highlight-tintColor2), var(--____highlight-tintColor2));
} }
} }
&.-side { &.-side {
& .shortName, .shortName {
& .userNameFull {
box-shadow: 0 -5px 3px -4px inset var(--____highlight-solidColor); box-shadow: 0 -5px 3px -4px inset var(--____highlight-solidColor);
} }
} }
} }
&:hover .new .full { .full {
pointer-events: initial; pointer-events: none;
} }
.serverName.-faded { .serverName.-faded {
color: var(--faintLink, $fallback--link); color: var(--faintLink, $fallback--link);
} }
.full .-faded {
color: var(--faint, $fallback--faint);
}
} }
.mention-link-popover { .mention-link-popover {

View File

@ -54,24 +54,10 @@
:class="{ '-you': shouldBoldenYou }" :class="{ '-you': shouldBoldenYou }"
> {{ ' ' + $t('status.you') }}</span> > {{ ' ' + $t('status.you') }}</span>
<!-- eslint-enable vue/no-v-html --> <!-- eslint-enable vue/no-v-html -->
</a><span </a><span class="full" ref="full">
v-if="shouldShowTooltip"
class="full"
>
<span
class="userNameFull"
>
<!-- eslint-disable vue/no-v-html --> <!-- eslint-disable vue/no-v-html -->
@<span @<span v-html="userName" /><span v-html="'@' + serverName" />
class="userName"
v-html="userName"
/><span
class="serverName"
:class="{ '-faded': shouldFadeDomain }"
v-html="'@' + serverName"
/>
<!-- eslint-enable vue/no-v-html --> <!-- eslint-enable vue/no-v-html -->
</span>
</span> </span>
</span> </span>
</UserPopover> </UserPopover>