Component Library of SaaS Hammer

@register_form_class(ModalParamsForm)
def small_modal(
self,
modal_title="Modal title",
modal_content="This is an example modal dialog box.",
**kwargs,
):
template = Template(
"""
{% load viewcomponent_tags %}
{% component 'modal' size="sm" as component %}
{% call component.trigger %}
<button class="btn btn-blue" data-action="click->modal#open:prevent">Open Small Modal</button>
{% endcall %}
{% call component.body %}
<h2 class="mb-4 text-xl">{{ modal_title }}</h2>
<p class="mb-4">{{ modal_content }}</p>
{% endcall %}
{% call component.actions %}
<button class="btn btn-white" data-action="click->modal#close:prevent">Cancel</button>
<button class="btn btn-blue" data-action="click->modal#close:prevent">Close</button>
{% endcall %}
{% endcomponent %}
""",
)
return template.render(
Context(
{
"modal_title": modal_title,
"modal_content": modal_content,
},
),
)