Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/routes/_components/IconButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{#if checked}
<SvgIcon className="icon-button-svg icon-button-check" ref:check href="#fa-check" />
{/if}
{#if count}
<span class="icon-button-count">{count}</span>
{/if}
</button>
<style>
.icon-button {
Expand All @@ -28,6 +31,11 @@
pointer-events: auto;
}

:global(.icon-button-count) {
margin-left: 10px;
color: var(--action-button-fill-color);
}

:global(.icon-button-svg) {
width: 24px;
height: 24px;
Expand Down Expand Up @@ -77,6 +85,10 @@
* muted
*/

:global(.icon-button.muted-style .icon-button-count) {
color: var(--action-button-deemphasized-fill-color);
}

:global(.icon-button.muted-style .icon-button-svg) {
fill: var(--action-button-deemphasized-fill-color);
}
Expand Down Expand Up @@ -141,7 +153,8 @@
sameColorWhenPressed: false,
ariaHidden: false,
clickListener: true,
checked: false
checked: false,
count: 0
}),
store: () => store,
computed: {
Expand Down
22 changes: 18 additions & 4 deletions src/routes/_components/status/StatusToolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
href={replyIcon}
clickListener={false}
elementId={replyKey}
count={repliesCount}
/>
<IconButton
label={reblogLabel}
Expand All @@ -19,6 +20,7 @@
href={reblogIcon}
clickListener={false}
elementId={reblogKey}
count={reblogsCount}
ref:reblogIcon
/>
<IconButton
Expand All @@ -30,6 +32,7 @@
href="#fa-star"
clickListener={false}
elementId={favoriteKey}
count={favoritesCount}
ref:favoriteIcon
/>
<IconButton
Expand Down Expand Up @@ -119,22 +122,28 @@
store: () => store,
methods: {
toggleFavorite (announce) {
const { originalStatusId, favorited } = this.get()
const { originalStatusId, favorited, originalStatus } = this.get()
const newFavoritedValue = !favorited
/* no await */ setFavorited(originalStatusId, newFavoritedValue)
if (newFavoritedValue) {
this.refs.favoriteIcon.animate(FAVORITE_ANIMATION, CHECKMARK_ANIMATION)
originalStatus.favourites_count++
} else {
originalStatus.favourites_count--
}
if (announce) {
announceAriaLivePolite(newFavoritedValue ? 'intl.favorited' : 'intl.unfavorited')
}
},
reblog (announce) {
const { originalStatusId, reblogged } = this.get()
const { originalStatusId, reblogged, originalStatus } = this.get()
const newRebloggedValue = !reblogged
/* no await */ setReblogged(originalStatusId, newRebloggedValue)
if (newRebloggedValue) {
this.refs.reblogIcon.animate(REBLOG_ANIMATION, CHECKMARK_ANIMATION)
originalStatus.reblogs_count++
} else {
originalStatus.reblogs_count--
}
if (announce) {
announceAriaLivePolite(newRebloggedValue ? 'intl.reblogged' : 'intl.unreblogged')
Expand Down Expand Up @@ -166,12 +175,14 @@
onPostedStatus (realm, inReplyToUuid) {
const {
originalStatusId,
uuid
uuid,
originalStatus
} = this.get()
if (realm !== originalStatusId ||
inReplyToUuid !== uuid) {
return
}
originalStatus.replies_count++
try {
// return status to the reply button after posting a reply
this.refs.node.querySelector('.status-toolbar-reply-button').focus({ preventScroll: true })
Expand Down Expand Up @@ -229,7 +240,10 @@
favoriteKey: ({ uuid }) => `fav-${uuid}`,
reblogKey: ({ uuid }) => `reblog-${uuid}`,
replyKey: ({ uuid }) => `reply-${uuid}`,
optionsKey: ({ uuid }) => `options-${uuid}`
optionsKey: ({ uuid }) => `options-${uuid}`,
repliesCount: ({ originalStatus }) => originalStatus.replies_count,
reblogsCount: ({ originalStatus }) => originalStatus.reblogs_count,
favoritesCount: ({ originalStatus }) => originalStatus.favourites_count
}
}
</script>