linstrom/frontend-reactive/app/components/note/interactions.ts

54 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2024-09-23 15:09:19 +00:00
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import isLandscape from 'frontend-reactive/helpers/isLandscape';
2024-09-23 07:18:35 +00:00
export interface NoteInteractionsSignature {
2024-09-23 15:09:19 +00:00
// The arguments accepted by the component
Args: {
boostCount: number;
totalLikeCount: number;
reactions: {
[key: string]: number;
};
hasBoosted: boolean;
hasReacted: boolean;
};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
2024-09-23 07:18:35 +00:00
}
export default class NoteInteractions extends Component<NoteInteractionsSignature> {
2024-09-23 15:09:19 +00:00
@tracked hasBoosted = this.args.hasBoosted;
@tracked hasReacted = this.args.hasReacted;
@tracked expandReactions = false;
2024-09-23 07:18:35 +00:00
2024-09-23 15:09:19 +00:00
@action
toggleBoost() {
this.hasBoosted = !this.hasBoosted;
console.log('boosted', this.hasBoosted);
}
2024-09-23 07:18:35 +00:00
2024-09-23 15:09:19 +00:00
@action
toggleDefaultLike() {
this.hasReacted = !this.hasReacted;
console.log('reacted', this.hasReacted);
}
2024-09-23 07:18:35 +00:00
2024-09-23 15:09:19 +00:00
@action
openCustomReactionSelector() {
this.hasReacted = !this.hasReacted;
console.log('sent custom reaction', this.hasReacted);
}
2024-09-23 07:18:35 +00:00
2024-09-23 15:09:19 +00:00
@action
openAllReactions() {
console.log('Toggle all reactions overview');
this.expandReactions = !this.expandReactions;
}
2024-09-23 07:18:35 +00:00
}