Skip to content

Instantly share code, notes, and snippets.

@prince-neres
Created November 9, 2024 00:28
Show Gist options
  • Select an option

  • Save prince-neres/3701044fba8a712e70cb08e2977b3877 to your computer and use it in GitHub Desktop.

Select an option

Save prince-neres/3701044fba8a712e70cb08e2977b3877 to your computer and use it in GitHub Desktop.
Useful macro to use in fragments and templates
<#macro button configuration>
<div class="po-custom-btn">
<#if configuration.type=="action">
<button
class="btn btn-${configuration.buttonSize} btn-${configuration.buttonType}"
data-lfr-editable-id="action"
data-lfr-editable-type="action"
>
Go Somewhere
</button>
<#else>
<div class="component-button text-break">
<a
class="btn btn-${configuration.buttonSize} btn-${configuration.buttonType}"
data-lfr-editable-id="link"
data-lfr-editable-type="link"
href=""
id="fragment-${fragmentEntryLinkNamespace}-link"
>
Go Somewhere
</a>
</div>
</#if>
</div>
<#-- TODO: move to globalCSS -->
<style>
.po-custom-btn .btn {
border-width: ${configuration.borderWidth} !important;
}
<#if configuration.clayIcon != "">
.po-custom-btn .btn::after {
content: '';
margin-left: .5rem;
height: ${configuration.iconSize};
width: ${configuration.iconSize};
display: inline-block;
background-color: ${configuration.iconColor};
mask-image: url(${themeDisplay.getPathThemeImages()}/clay/${configuration.clayIcon}.svg);
mask-size: cover;
mask-repeat: no-repeat;
}
</#if>
</style>
</#macro>
[#if request.getParameterNames()??]
[#assign
groupId = request.getParameterNames()?sequence?seq_contains("groupId")?string(paramUtil.getString(request, "groupId"), scopeGroupId)
/]
[#assign templatePath]
_TEMPLATE_CONTEXT_/${themeDisplay.getCompanyId()}/${groupId}/${serviceLocator
.findService("com.liferay.portal.kernel.service.ClassNameLocalService")
.getClassNameId("com.liferay.portal.kernel.theme.NavItem")}
[/#assign]
[#import "${templatePath}/PORTAL-ONE-MACROS" as po/]
[@po.button configuration /]
[/#if]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment