custom/plugins/MsrTheme/src/Resources/views/storefront/utilities/alert.html.twig line 1

Open in your IDE?
  1. {#
  2. Global messages template
  3. https://getbootstrap.com/docs/4.3/components/alerts/
  4. *Type:
  5. The template provides an easy way to display messages in the storefront. The following types are supported:
  6. * primary
  7. * secondary
  8. * danger (red)
  9. * success (green)
  10. * warning (yellow)
  11. * info (blue)
  12. * light (white)
  13. * dark (dark gray)
  14.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  15.         type:"primary",
  16.         content:"Primary Lorem ipsum dolor"
  17.     } %}
  18. *Icons:
  19. Icons are shown by default. To hide the icon within the alert, set the value of "icon" to false:
  20.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  21.         type:"primary",
  22.         content:"Primary Lorem ipsum dolor",
  23.         icon: false
  24.     } %}
  25. *Message Content:
  26. The component requires the parameters ```content``` or ```list``` to display a message. If no ```type``` is defined it
  27. will use the fallback option (success).
  28.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  29.         type:"primary",
  30.         content:"Primary Lorem ipsum dolor"
  31.     } %}
  32. *Message List:
  33. If you need to display a bunch of messages (for example error messages in the registration), you can pass an array
  34. of messages to the template using the parameter ```list```:
  35.      {% set list1 = [
  36.         'Error message 1',
  37.         'Error message 2',
  38.         'Error message 3'
  39.     ] %}
  40.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  41.         type:"secondary",
  42.         list: list1
  43.     } %}
  44. *Heading:
  45. To display a heading, use "heading".
  46.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  47.         type:"primary",
  48.         content:"Primary Lorem ipsum dolor",
  49.         heading: "Test Heading"
  50.     } %}
  51. *Dismissible Button:
  52. To display a dismissible button set the value of "dismissible" to true.
  53.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  54.         type:"primary",
  55.         content:"Primary Lorem ipsum dolor",
  56.         dismissible: true
  57.     } %}
  58. #}
  59. {% sw_extends '@Storefront/storefront/utilities/alert.html.twig' %}
  60. {% block utilities_alert %}
  61.     <div role="alert"
  62.          class="alert {% if type %}alert-{{ type }}{% endif %}{% if dismissible %} alert-dismissible fade show{% endif %}{% if icon != "error" %} alert-has-icon{% endif %}">
  63.         {% block utilities_alert_icon %}
  64.             {% if icon != "false" %}
  65.                 {% if type == "danger" %}
  66.                     {% sw_icon 'blocked' %}
  67.                 {% elseif type == "warning" %}
  68.                     {% sw_icon 'warning' %}
  69.                 {% elseif type == "info" %}
  70.                     {% sw_icon 'info' %}
  71.                 {% elseif type == "success" %}
  72.                     {% sw_icon 'checkmark-circle' %}
  73.                 {% else %}
  74.                     {% sw_icon 'alert' %}
  75.                 {% endif %}
  76.             {% endif %}
  77.         {% endblock %}
  78.         {% block utilities_alert_content_container %}
  79.             <div class="alert-content-container">
  80.                 {% block utilities_alert_heading %}
  81.                     {% if heading %}
  82.                         <div class="alert-heading h5">
  83.                             {{ heading }}
  84.                         </div>
  85.                     {% endif %}
  86.                 {% endblock %}
  87.                 {% block utilities_alert_content %}
  88.                     <div class="alert-content">
  89.                         {% if list|length > 1 %}
  90.                             <ul class="alert-list">
  91.                                 {% for entry in list %}
  92.                                     <li>
  93.                                         <p class="mb-0">
  94.                                             {{ entry|sw_sanitize }}
  95.                                         </p>
  96.                                     </li>
  97.                                 {% endfor %}
  98.                             </ul>
  99.                         {% elseif list|length == 1 %}
  100.                             {% for entry in list %}
  101.                                 <p class="mb-0">
  102.                                     {{ entry|sw_sanitize }}
  103.                                 </p>
  104.                             {% endfor %}
  105.                         {% else %}
  106.                             <p class="mb-0">
  107.                                 {{ content|sw_sanitize }}
  108.                             </p>
  109.                         {% endif %}
  110.                     </div>
  111.                 {% endblock %}
  112.                 {% block utilities_alert_dismissible %}
  113.                     {% if dismissible %}
  114.                         <button type="button"
  115.                                 class="close"
  116.                                 {{ dataBsDismissAttr }}="alert"
  117.                                 aria-label="Close">
  118.                             <span aria-hidden="true">&times;</span>
  119.                         </button>
  120.                     {% endif %}
  121.                 {% endblock %}
  122.             </div>
  123.         {% endblock %}
  124.     </div>
  125. {% endblock %}