aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/interaction_button.php
blob: b3d072dd7c36193640b53706e724e3f687e5f926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$active = $active ?? false;
$tooltip = match ($action) {
    'like' => __('note.action.like'),
    'dislike' => __('note.action.dislike'),
    'reshare' => __('note.action.reshare')
};
$icon = match ($action) {
    'like' => 'favorite',
    'dislike' => 'heart_broken',
    'reshare' => $active ? 'repeat_on' : 'repeat'
};
$id = "interactButton-$action-$note->id";
?>
<div class="interactButtonContainer <?= $action . ($active ? ' active' : '') ?>">
    <button title="<?= $tooltip ?>" class="icon material-symbols-outlined <?= $active ? 'active' : '' ?>"
        hx-post="<?= "/fragment/note/$note->id/$action" ?>" hx-swap="outerHTML"
        hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="<?= $id ?>"
        _="on click wait 1s then trigger update on #liveTimelineUpdater">
        <?= $icon ?>
    </button>
    <label for="<?= $id ?>" class="interactionCount"><?= $count ?? '' ?></label>
</div>