mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
* Receipt: Add payment proof Closes #4685. * shice * Add truncate-center component * Improve view * Hide button and link when printed * Describe component * Remove transaction ID from UI * Remove modification to interface --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BTCPayServer.Components.TruncateCenter;
|
|
|
|
/// <summary>
|
|
/// Truncates long strings in the center with ellipsis: Turns e.g. a BOLT11 into "lnbcrt7…q2ns60y"
|
|
/// </summary>
|
|
/// <param name="text">The full text, e.g. a Bitcoin address or BOLT11</param>
|
|
/// <param name="link">Optional link, e.g. a block explorer URL</param>
|
|
/// <param name="classes">Optional additional CSS classes</param>
|
|
/// <param name="padding">The number of characters to show on each side</param>
|
|
/// <param name="copy">Display a copy button</param>
|
|
/// <returns>HTML with truncated string</returns>
|
|
public class TruncateCenter : ViewComponent
|
|
{
|
|
public IViewComponentResult Invoke(string text, string link = null, string classes = null, int padding = 7, bool copy = true)
|
|
{
|
|
var vm = new TruncateCenterViewModel
|
|
{
|
|
Classes = classes,
|
|
Padding = padding,
|
|
Copy = copy,
|
|
Text = text,
|
|
Link = link,
|
|
Truncated = text.Length > 2 * padding ? $"{text[..padding]}…{text[^padding..]}" : text
|
|
};
|
|
return View(vm);
|
|
}
|
|
}
|