{#
/**
 * @file
 * Theme implementation for a details element optionally using GCDS.
 *
 * If use_gcds is TRUE, this will theme with GCDS. Otherwise, it will theme like
 * core/themes/starterkit_theme/templates/form/details.html.twig.
 *
 * Available variables
 * - attributes: A list of HTML attributes for the details element.
 * - errors: (optional) Any errors for this details element, may not be set.
 * - title: (optional) The title of the element, may not be set.
 * - summary_attributes: A list of HTML attributes for the summary element.
 * - description: (optional) The description of the element, may not be set.
 * - children: (optional) The children of the element, may not be set.
 * - value: (optional) The value of the element, may not be set.
 *
 * @see template_preprocess_details()
 */
#}
{% set content %}
  <div class="details-wrapper">
    {% if errors %}
      <div class="form-item--error-message">
        <strong>{{ errors }}</strong>
      </div>
    {% endif %}
    {%- if description -%}
      <div class="details-description">{{ description }}</div>
    {%- endif -%}
    {%- if children -%}
      {{ children }}
    {%- endif -%}
    {%- if value -%}
      {{ value }}
    {%- endif -%}
  </div>
{% endset %}
{% if use_gcds %}
  {{ include('gcds:gcds-details', {
    'details_title': title,
    'open': attributes.open,
    'class': attributes.class,
    'default': content,
  }, with_context = false) }}
{% else %}
  <details{{ attributes }}>
    {%- if title -%}
      {%
        set summary_classes = [
          required ? 'js-form-required',
          required ? 'form-required',
        ]
      %}
      <summary{{ summary_attributes.addClass(summary_classes) }}>{{ title }}</summary>
    {%- endif -%}
    {{ content }}
  </details>
{% endif %}
