{% import "macros/icons.html" as icons %}

{% macro clipboard(text) %}
<button
  type="button"
  _="
    on click call navigator.clipboard.writeText('{{ text }}')
    then add @disabled to me
    then toggle .hidden on <svg /> in me
    then wait 5s
    then toggle .hidden on <svg /> in me
    then remove @disabled from me
  "
>
  {{ icons.clipboard('h-4 w-4') }}
  {{ icons.clipboard_document_check('h-4 w-4 hidden') }}
</button>
{% endmacro %}

{% macro submit(class) %}
<button
  type="submit"
  class="{{ class }} group bg-primary-500 hover:bg-primary-600 text-white disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400 disabled:cursor-not-allowed"
>
  {{ icons.spinner('hidden group-disabled:block w-4 h-4 shrink-0 mr-2') }}
  {{ caller() }}
</button>
{% endmacro %}
