templates/hc/button-button.html.twig line 1

Open in your IDE?
  1. {% set icon = _args.icon|default(null) %}
  2. {% set text = _args.text|default(null) %}
  3. {% set image = _args.image|default(null) %}
  4. {% set type = _args.type|default('button') %}
  5. {% set styles = _args.styles|default(['default']) %}
  6. {% set dropdown = _args.dropdown|default(null) %}
  7. {% set drop = _args.drop|default('down') %}
  8. {% set modal = _args.modal|default(null) %}
  9. {% set sidepanel = _args.sidepanel|default(null) %}
  10. {% set attr = _args.attr|default({}) %}
  11. {% set class = attr.class|default('') %}
  12. {% set churnzero = _args.churnzero|default(null) %}
  13. {% if styles is not iterable %}
  14.     {% set styles = styles|split(' ') %}
  15. {% endif %}
  16. {% if text is empty and icon is not empty %}
  17.     {% set styles = styles|merge(['icon']) %}
  18. {% endif %}
  19. {% if dropdown %}
  20.     {% set styles = styles|merge(['dropdown']) %}
  21.     {% set class = (class is not empty ?  class ~ ' hc-button--dropdown hc-dropdown-toggle-button' : 'hc-button--dropdown hc-dropdown-toggle-button') %}
  22.     {% if dropdown.caret is defined and dropdown.caret %}
  23.         {% set class = class ~ ' hc-button--dropdown--add-caret' %}
  24.     {% endif %}
  25. {% endif %}
  26. {% set attr = attr|merge({
  27.     class: 'hc-button hc-button--%s %s'|format(
  28.         styles|join(' hc-button--')|trim,
  29.         class,
  30.     )|trim,
  31.     type: type,
  32.     'data-toggle': sidepanel ? 'sidepanel' : null,
  33.     'data-target': sidepanel ? ('#' ~ sidepanel) : (modal ? ('#' ~ modal) : null),
  34.     'data-churnzero': churnzero and churnzero.event is defined ? churnzero.event : null,
  35.     'data-churnzero-extras': churnzero and churnzero.extras is defined ? churnzero.extras|json_encode : null,
  36. }) %}
  37. {% if text %}
  38.     {% set attr = attr|merge({'aria-label': text}) %}
  39. {% endif %}
  40. <button {{ attributes(attr) }}>
  41.     {% if block('content') is defined %}
  42.         {{ block('content') }}
  43.     {% else %}
  44.         {% if icon %}
  45.             {% include 'hc/icon.html.twig' with (icon is iterable ? icon : {
  46.                 glyph: icon,
  47.             }) %}
  48.         {% endif %}
  49.         {% if text %}{{ text }}{% endif %}
  50.     {% endif %}
  51. </button>