diff --git a/src/backend/views/components/copy-button.twig b/src/backend/views/components/copy-button.twig new file mode 100644 index 0000000..2db7ee1 --- /dev/null +++ b/src/backend/views/components/copy-button.twig @@ -0,0 +1,25 @@ +{# + Reusable copy button component. + Available props: + - ariaLabel: label for better accessibility + - class: additional class for the button + - textToCopy: text to be copied to the clipboard (use '#' for anchor links) + + Usage examples: + {% include 'components/copy-button.twig' with { textToCopy: 'Lorem ipsum dolor' } %} + {% include 'components/copy-button.twig' with { textToCopy: '#anchor-link-dolor' } %} +#} + +{% set attrNameForTextToCopy = 'data-text-to-copy' %} + +{% set ariaLabel = ariaLabel ?? 'Copy to the Clipboard' %} + +{% set mainTag = 'button' %} +{% set mainClass = 'copy-button' %} + +<{{ mainTag }} class="{{ mainClass }} {{ class ?? '' }}" aria-label="{{ ariaLabel }}" {{ attrNameForTextToCopy }}="{{ textToCopy }}"> +