diff options
| author | winter | 2025-03-30 19:00:19 +0100 |
|---|---|---|
| committer | winter | 2025-03-30 19:00:19 +0100 |
| commit | cd10f94269d7dcdd93df9fcda142a1e5a4441ae9 (patch) | |
| tree | 75a00ef94c94259d3e6308d67e491b3800b47d89 /templates/note/interaction_button.php | |
| parent | c26a1dca22fcced7b9cd37ace7a20ae71491fd66 (diff) | |
implement basic interaction controls
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 |
