details.html.twig 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a details element.
  5. *
  6. * Available variables
  7. * - attributes: A list of HTML attributes for the details element.
  8. * - errors: (optional) Any errors for this details element, may not be set.
  9. * - title: (optional) The title of the element, may not be set.
  10. * - description: (optional) The description of the element, may not be set.
  11. * - children: (optional) The children of the element, may not be set.
  12. * - value: (optional) The value of the element, may not be set.
  13. *
  14. * @see template_preprocess_details()
  15. */
  16. #}
  17. {#
  18. Prefix 'details' class to avoid collision with Modernizr.
  19. @todo Remove prefix after https://www.drupal.org/node/2981732 has been solved.
  20. #}
  21. <details{{ attributes.addClass('seven-details') }}>
  22. {%- if title -%}
  23. {%
  24. set summary_classes = [
  25. 'seven-details__summary',
  26. required ? 'js-form-required',
  27. required ? 'form-required',
  28. ]
  29. %}
  30. <summary{{ summary_attributes.addClass(summary_classes) }}>
  31. {{- title -}}
  32. </summary>
  33. {%- endif -%}
  34. <div class="seven-details__wrapper details-wrapper">
  35. {% if errors %}
  36. <div class="form-item form-item--error-message">
  37. <strong>{{ errors }}</strong>
  38. </div>
  39. {% endif %}
  40. {%- if description -%}
  41. <div class="seven-details__description">{{ description }}</div>
  42. {%- endif -%}
  43. {%- if children -%}
  44. {{ children }}
  45. {%- endif -%}
  46. {%- if value -%}
  47. {{ value }}
  48. {%- endif -%}
  49. </div>
  50. </details>