Browse Source

Zaps in templates

imwald
Nuša Pukšič 2 months ago
parent
commit
3b898a4698
  1. 19
      templates/components/Molecules/ZapButton.html.twig
  2. 15
      templates/pages/article.html.twig
  3. 2
      templates/partial/_author-section.html.twig

19
templates/components/Molecules/ZapButton.html.twig

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
{# Zap Button - always visible #}
<button
type="button"
class="btn btn-sm btn-outline-warning zap-trigger"
class="btn btn-outline-warning zap-trigger {{ btnClass|default('') }}"
data-action="live#action"
data-live-action-param="openDialog"
title="Send a zap"
@ -28,6 +28,23 @@ @@ -28,6 +28,23 @@
{# Phase: Input #}
{% if this.phase == 'input' %}
{# Display zap splits information if configured #}
{% if this.zapSplits|length > 0 %}
<div class="alert alert-info mb-3">
<strong>⚡ Split Payment</strong>
<p class="mb-1 small">This zap will be split between {{ this.zapSplits|length + 1 }} recipients:</p>
<ul class="mb-0 small">
<li>Primary recipient</li>
{% for split in this.zapSplits %}
<li>
{{ split.recipient|slice(0, 8) }}...{{ split.recipient|slice(-8) }}
{% if split.weight %}(weight: {{ split.weight }}){% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<form data-action="submit->live#action:prevent" data-live-action-param="createInvoice">
<div class="mb-3">
<label for="zap-amount" class="form-label">Amount (sats)</label>

15
templates/pages/article.html.twig

@ -59,6 +59,21 @@ @@ -59,6 +59,21 @@
{% if app.user %}
<twig:ReadingListDropdown coordinate="30023:{{ article.pubkey }}:{{ article.slug }}" />
{% endif %}
{# Zap Button with split payment support #}
{% set zapSplits = article.advancedMetadata.zapSplits|default([]) %}
<twig:Molecules:ZapButton
recipientPubkey="{{ article.pubkey }}"
recipientLud16="{{ author.lud16 is iterable ? author.lud16|first : author.lud16 }}"
:zapSplits="zapSplits" />
{# Display split payment indicator #}
{% if zapSplits|length > 0 %}
<small class="text-muted ms-2">
<em>(Split between {{ zapSplits|length + 1 }} recipients)</em>
</small>
{% endif %}
</div>

2
templates/partial/_author-section.html.twig

@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
{% if author.lud16 is defined and author.lud16 %}
<twig:Molecules:ZapButton
class="mt-2 mb-2"
btnClass="btn-sm"
recipientPubkey="{{ pubkey }}"
recipientLud16="{{ author.lud16 is iterable ? author.lud16|first : author.lud16 }}"
/>

Loading…
Cancel
Save