Merge branch 'tusooa/unify-show-hide' into 'develop'

Unify show/hide content buttons

Closes #1294

See merge request pleroma/pleroma-fe!2178
This commit is contained in:
HJ 2025-06-25 13:07:18 +00:00
commit 8e9f0ae4a5
4 changed files with 72 additions and 48 deletions

View file

@ -0,0 +1 @@
Unify show/hide content buttons

View file

@ -72,6 +72,23 @@ const StatusContent = {
hideTallStatus () { hideTallStatus () {
return this.mightHideBecauseTall && !this.showingTall return this.mightHideBecauseTall && !this.showingTall
}, },
shouldShowToggle () {
return this.mightHideBecauseSubject || this.mightHideBecauseTall
},
toggleButtonClasses () {
return {
'cw-status-hider': !this.showingMore && this.mightHideBecauseSubject,
'tall-status-hider': !this.showingMore && this.mightHideBecauseTall,
'status-unhider': this.showingMore,
}
},
toggleText () {
if (this.showingMore) {
return this.mightHideBecauseSubject ? this.$t('status.hide_content') : this.$t('general.show_less')
} else {
return this.mightHideBecauseSubject ? this.$t('status.show_content') : this.$t('general.show_more')
}
},
showingMore () { showingMore () {
return (this.mightHideBecauseTall && this.showingTall) || (this.mightHideBecauseSubject && this.expandingSubject) return (this.mightHideBecauseTall && this.showingTall) || (this.mightHideBecauseSubject && this.expandingSubject)
}, },

View file

@ -62,7 +62,6 @@
&.-tall-status { &.-tall-status {
position: relative; position: relative;
height: 16em; height: 16em;
overflow: hidden;
z-index: 1; z-index: 1;
.media-body { .media-body {
@ -82,6 +81,10 @@
mask-composite: exclude; mask-composite: exclude;
} }
} }
&.-expanded {
overflow: visible;
}
} }
& .tall-status-hider, & .tall-status-hider,
@ -95,6 +98,13 @@
text-align: center; text-align: center;
} }
.status-unhider {
margin-top: auto;
position: sticky;
bottom: 0;
padding-bottom: 1em;
}
.tall-status-hider { .tall-status-hider {
position: absolute; position: absolute;
height: 5em; height: 5em;
@ -118,6 +128,10 @@
} }
} }
.toggle-button {
padding: 0.5em;
}
&.-compact { &.-compact {
align-items: start; align-items: start;
flex-direction: row; flex-direction: row;

View file

@ -31,17 +31,9 @@
</button> </button>
</div> </div>
<div <div
:class="{'-tall-status': hideTallStatus}"
class="text-wrapper" class="text-wrapper"
:class="{'-tall-status': hideTallStatus, '-expanded': showingMore}"
> >
<button
v-show="hideTallStatus"
class="button-unstyled -link tall-status-hider"
:class="{ '-focused': focused }"
@click.prevent="toggleShowMore"
>
{{ $t("general.show_more") }}
</button>
<RichContent <RichContent
v-if="!hideSubjectStatus && !(singleLine && status.summary_raw_html)" v-if="!hideSubjectStatus && !(singleLine && status.summary_raw_html)"
:class="{ '-single-line': singleLine }" :class="{ '-single-line': singleLine }"
@ -54,13 +46,18 @@
:attentions="status.attentions" :attentions="status.attentions"
@parse-ready="onParseReady" @parse-ready="onParseReady"
/> />
<div
v-show="shouldShowToggle"
:class="toggleButtonClasses"
>
<button <button
v-show="hideSubjectStatus" class="btn button-default toggle-button"
class="button-unstyled -link cw-status-hider" :class="{ '-focused': focused }"
:aria-expanded="showingMore"
@click.prevent="toggleShowMore" @click.prevent="toggleShowMore"
> >
{{ $t("status.show_content") }} {{ toggleText }}
<template v-if="!showingMore">
<FAIcon <FAIcon
v-if="attachmentTypes.includes('image')" v-if="attachmentTypes.includes('image')"
icon="image" icon="image"
@ -85,14 +82,9 @@
v-if="status.card" v-if="status.card"
icon="link" icon="link"
/> />
</template>
</button> </button>
<button </div>
v-show="showingMore && !fullContent"
class="button-unstyled -link status-unhider"
@click.prevent="toggleShowMore"
>
{{ tallStatus ? $t("general.show_less") : $t("status.hide_content") }}
</button>
</div> </div>
</div> </div>
<slot v-if="!hideSubjectStatus" /> <slot v-if="!hideSubjectStatus" />