Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
feat(post): show snackbar for all post actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gvn committed Nov 28, 2023
1 parent 49f2cef commit f840101
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
22 changes: 15 additions & 7 deletions components/publish/PublishSnackbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function show() {
setTimeout(() => {
hide()
}, 10000)
}, 5000)
}
function hide() {
Expand All @@ -22,20 +22,28 @@ defineExpose({
</script>

<template>
<div class="snackbar-wrapper">
<div
:class="{ active: isVisible }"
class="snackbar"
>
<div
:class="{ active: isVisible }"
class="snackbar-wrapper"
>
<div class="snackbar">
Your post was published
</div>
</div>
</template>

<style scoped>
.snackbar-wrapper {
bottom: -100px;
display: flex;
justify-content: center;
position: sticky;
transition: bottom 500ms ease-in-out;
width: 100%;
z-index: 1000;
}
.snackbar-wrapper.active {
bottom: 50px;
}
.snackbar {
background: var(--c-primary);
Expand All @@ -51,7 +59,7 @@ defineExpose({
text-align: center;
transition: opacity 800ms ease-in-out;
}
.snackbar.active {
.snackbar-wrapper.active .snackbar {
opacity: 1;
}
</style>
5 changes: 4 additions & 1 deletion components/timeline/TimelineHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ import { ref } from 'vue'
const paginator = useMastoClient().v1.timelines.listHome({ limit: 30 })
const stream = $(useStreaming(client => client.v1.stream.streamUser()))
const homePaginator = ref(null)
const publishSnackbar = ref(null)
function reorderAndFilter(items: mastodon.v1.Status[]) {
return reorderedTimeline(items, 'home')
}
function onPublish(status) {
homePaginator.value.percolateStatus(status)
publishSnackbar.value.show()
}
</script>

<template>
<div>
<div relative>
<PublishWidget draft-key="home" border="b base" feed-name="home" @published="onPublish" />
<TimelinePaginator ref="homePaginator" v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="home" feed-name="home.feed" />
<PublishSnackbar ref="publishSnackbar" />
</div>
</template>
6 changes: 4 additions & 2 deletions pages/compose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function onPublish() {
</script>

<template>
<PublishWidgetFull @published="onPublish" />
<PublishSnackbar ref="publishSnackbar" />
<div relative>
<PublishWidgetFull @published="onPublish" />
<PublishSnackbar ref="publishSnackbar" />
</div>
</template>

0 comments on commit f840101

Please sign in to comment.