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,45 +46,45 @@
:attentions="status.attentions" :attentions="status.attentions"
@parse-ready="onParseReady" @parse-ready="onParseReady"
/> />
<div
<button v-show="shouldShowToggle"
v-show="hideSubjectStatus" :class="toggleButtonClasses"
class="button-unstyled -link cw-status-hider"
@click.prevent="toggleShowMore"
> >
{{ $t("status.show_content") }} <button
<FAIcon class="btn button-default toggle-button"
v-if="attachmentTypes.includes('image')" :class="{ '-focused': focused }"
icon="image" :aria-expanded="showingMore"
/> @click.prevent="toggleShowMore"
<FAIcon >
v-if="attachmentTypes.includes('video')" {{ toggleText }}
icon="video" <template v-if="!showingMore">
/> <FAIcon
<FAIcon v-if="attachmentTypes.includes('image')"
v-if="attachmentTypes.includes('audio')" icon="image"
icon="music" />
/> <FAIcon
<FAIcon v-if="attachmentTypes.includes('video')"
v-if="attachmentTypes.includes('unknown')" icon="video"
icon="file" />
/> <FAIcon
<FAIcon v-if="attachmentTypes.includes('audio')"
v-if="status.poll && status.poll.options" icon="music"
icon="poll-h" />
/> <FAIcon
<FAIcon v-if="attachmentTypes.includes('unknown')"
v-if="status.card" icon="file"
icon="link" />
/> <FAIcon
</button> v-if="status.poll && status.poll.options"
<button icon="poll-h"
v-show="showingMore && !fullContent" />
class="button-unstyled -link status-unhider" <FAIcon
@click.prevent="toggleShowMore" v-if="status.card"
> icon="link"
{{ tallStatus ? $t("general.show_less") : $t("status.hide_content") }} />
</button> </template>
</button>
</div>
</div> </div>
</div> </div>
<slot v-if="!hideSubjectStatus" /> <slot v-if="!hideSubjectStatus" />