diff options
Diffstat (limited to 'templates/note/interaction_button.php')
| -rw-r--r-- | templates/note/interaction_button.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/templates/note/interaction_button.php b/templates/note/interaction_button.php new file mode 100644 index 0000000..bfcbd85 --- /dev/null +++ b/templates/note/interaction_button.php @@ -0,0 +1,23 @@ +<?php +$active = $active ?? false; +$forbidden = $disabled ? '.forbidden' : ''; +$tooltip = match ($action) { + 'like' => __("note.action.like$forbidden"), + 'dislike' => __("note.action.dislike$forbidden"), + 'reshare' => __("note.action.reshare$forbidden") +}; +$icon = match ($action) { + 'like' => $active ? 'favorite' : 'favorite-outline', + 'dislike' => $active ? 'heart-broken' : 'heart-broken-outline', + 'reshare' => $active ? 'repeat-on' : 'repeat' +}; +$id = "interactButton-$action-$note->id"; +?> +<div class="interactButtonContainer <?= $action . ($active ? ' active' : '') ?>"> + <button title="<?= $tooltip ?>" class="material-symbols <?= $icon ?>" + hx-post="<?= "/fragment/note/$note->id/$action" ?>" hx-swap="outerHTML" + hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="<?= $id ?>" + _="on htmx:afterOnLoad trigger update on #liveTimelineUpdater" <?= ($disabled ?? false) ? 'disabled' : '' ?>> + </button> + <label for="<?= $id ?>" class="interactionCount"><?= $count ?? '' ?></label> +</div>
\ No newline at end of file |
