aButton.ftl

 1   <#--
 2   Macro: aButton
 3   Description: Generates an HTML button or link with various customization options, including color, size, alignment, icon, and title.
 4   Parameters:
 5   - name (string, optional): the name attribute of the button element.
 6   - id (string, optional): the ID attribute of the button element.
 7   - href (string, optional): the URL to which the button will link.
 8   - target (string, optional): the target of the link, such as "_blank".
 9   - size (string, optional): the size of the button, such as "sm" or "lg".
 10   - color (string, optional): the color of the button, such as "primary" or "warning".
 11   - style (string, optional): the style of the button, such as "btn" or "card-control".
 12   - align (string, optional): the alignment of the button, such as "left" or "right".
 13   - class (string, optional): additional CSS classes to apply to the button.
 14   - params (string, optional): additional HTML parameters to apply to the button element.
 15   - title (string, optional): the title of the button.
 16   - tabIndex (string, optional): the tab index of the button.
 17   - hideTitle (list, optional): a list of screen reader text to hide the title of the button.
 18   - buttonIcon (string, optional): the icon to display inside the button.
 19   - disabled (boolean, optional): whether or not the button is disabled.
 20   - iconPosition (string, optional): the position of the icon inside the button, such as "left" or "right".
 21   - dropdownMenu (boolean, optional): whether or not to include a dropdown menu inside the button.
 22   -->
 23   <#macro aButton name='' id='' href='' target='' size='' color='primary' style='btn' align='' class='' title='' tabIndex='' hideTitle=[] buttonIcon='' disabled=false iconPosition='left' dropdownMenu=false  params='' deprecated...>
 24   <@deprecatedWarning args=deprecated />
 25   <#local params = params />
 26   <#-- Visibility of button title -->
 27   <#local displayTitleClass = displaySettings( hideTitle, 'block' ) />
 28   <#if color = 'default' || color='btn-default' || color='btn-secondary' || color='secondary'>
 29   	<#local buttonColor = 'btn-default' />
 30   <#elseif color=''>
 31   	<#local buttonColor = 'btn-primary' />
 32   <#else>
 33   	<#if color == 'primary' || color == 'secondary' || color == 'success' || color == 'info' || color == 'warning' || color == 'danger'>
 34   		<#local buttonColor = 'btn-' + color />
 35   	<#else>
 36   		<#local buttonColor = 'bg-' + color />
 37   	</#if>
 38   </#if>
 39   <#if style='card-control'>
 40   	<#assign style='text-right btn-link' />
 41   </#if>
 42   <#local class += alignmentSettings(align,'') />
 43   <#-- Size class -->
 44   <#local buttonSize = '' />
 45   	<#if size?starts_with('style') == true >
 46   		<#local params = params + ' ' + size />
 47   	<#else>
 48   		<#local buttonSize = size />
 49   	</#if>	
 50   <#if dropdownMenu>
 51   <div class="btn-group">
 52   </#if>
 53   <a class="${style}<#if buttonSize!=''> btn-${buttonSize}</#if><#if color!=''> ${buttonColor}</#if><#if class!=''> ${class}</#if>"<#if name!=''> name="${name}"</#if><#if id!=''> id="${id}"</#if> href="${href}" title="${title}"<#if target!=''> target="${target}"</#if><#if params!=''> ${params}</#if><#if disabled> disabled</#if><#if dropdownMenu> data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"</#if>>
 54   	<#if buttonIcon!='' && iconPosition='left'>
 55   		<#local buttonIcon = buttonIcon + ' me-1' />
 56   		<@icon style=buttonIcon />
 57   	</#if>
 58   	<span class="${displayTitleClass}">${title}</span>
 59   	<#if buttonIcon!='' && iconPosition='right'>
 60   		<#local buttonIcon = buttonIcon + ' ms-1' />
 61   		<@icon style=buttonIcon />
 62   	</#if>
 63   	<#if !dropdownMenu>
 64   	<#nested>
 65   	</#if>
 66   </a>
 67   <#if dropdownMenu>
 68   <div class="dropdown-menu"<#if id!=''> id="${id}" aria-labelledby="${id}"</#if>>
 69   	<#nested>
 70   </div>
 71   </div>
 72   </#if>
 73   </#macro>