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 <#-- Visibility of button title -->
26 <#local displayTitleClass = displaySettings(hideTitle,'inline') />
27 <#if color = 'default' || color='btn-default' || color='btn-secondary' || color='secondary'>
28 <#local buttonColor = 'btn-default' />
29 <#elseif color=''>
30 <#local buttonColor = 'btn-primary' />
31 <#else>
32 <#if color == 'primary' || color == 'secondary' || color == 'success' || color == 'info' || color == 'warning' || color == 'danger'>
33 <#local buttonColor = 'btn-' + color />
34 <#else>
35 <#local buttonColor = 'bg-' + color />
36 </#if>
37 </#if>
38 <#if style='card-control'>
39 <#assign style='text-right btn-link' />
40 </#if>
41 <#local class += alignmentSettings(align,'') />
42 <#-- Size class -->
43 <#if size == 'xs'>
44 <#local buttonSize = 'sm' />
45 <#elseif size == 'sm' || size == ''>
46 <#local buttonSize = '' />
47 <#elseif size == 'lg'>
48 <#local buttonSize = size />
49 <#else>
50 <#local buttonSize = '' />
51 </#if>
52 <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>>
53 <#if buttonIcon!='' && iconPosition='left'>
54 <#local buttonIcon = buttonIcon />
55 <@icon style=buttonIcon />
56 </#if>
57 <span class="${displayTitleClass}">${title}</span>
58 <#if buttonIcon!='' && iconPosition='right'>
59 <#local buttonIcon = buttonIcon />
60 <@icon style=buttonIcon />
61 </#if>
62 <#if !dropdownMenu>
63 <#nested>
64 </#if>
65 </a>
66 <#if dropdownMenu>
67 <div class="dropdown-menu"<#if id!=''> id="${id}" aria-labelledby="${id}"</#if>>
68 <#nested>
69 </div>
70 </#if>
71 </#macro>