Hallo. Ich nutze ein Accordion um Details darzustellen - insgesamt 3 Titel mit Content. Nun möchte ich, dass immer das erste (Highlights) offen ist. Wie kann ich das machen?
Hier der Code!
{%- comment -%}
----------------------------------------------------------------------------------------------------------------------
ACCORDION COMPONENT
----------------------------------------------------------------------------------------------------------------------
This component is used to create an accordion (also called as collapsible). It internally uses the "details" HTML
tag so that it can also be used without any JavaScript.
********************************************
Supported parameters
********************************************
* title: the title to use for the toggle button
* icon: an optional icon attached to the title
* content: the hidden content inside the accordion
* open: if set to true the accordion is open by default
* size: if set to "lg", the font is and spacing is bigger
* class: any additional class
* id: an optional ID for the accordion
Mein Test mit for:
{% for i in (1..3) -%}
{%- if i == 1 -%}
{% assign open = 'false' %}
{%- else -%}
{% assign open = 'false' %}
{%- endif -%}
{%- endfor %}
{%- endcomment -%}
<details {% if id %}id="{{ id | escape }}"{% endif %} class="{{ class }} accordion {% if size %}accordion--{{ size }}{% endif %} group" aria-expanded="{% if open %}true{% else %}false{% endif %}" is="accordion-disclosure" {% if open %}open{% endif %} {{ block.shopify_attributes }}>
<summary>
{%- comment -%}iOS 14 does not support flex on the summary itself, so we have to use this extra div{%- endcomment -%}
<div class="accordion__toggle bold">
{%- if icon -%}
<div class="text-with-icon">
{%- render 'icon' with icon -%}
<span style="color:#9DCC4C" class="h4">{{- title | escape -}}</span>
</div>
{%- else -%}
{% if page.id == 106658988348 %}
<span style="color:#000000" class="h6">{{- title | escape -}}</span>
{%- else -%}
<span style="color:#9DCC4C" class="h6">{{- title | escape -}}</span>
{% endif %}
{%- endif -%}
<span class="circle-chevron group-hover:colors group-expanded:colors group-expanded:rotate">{%- render 'icon' with 'chevron-bottom-small' -%}</span>
</div>
</summary>
<div class="accordion__content">
{{- content -}}
</div>
</details>
Ich habe es schon mit der Schleife for probiert - das zerschießt aber alles bzw. stellt jeden Titel 3x dar…
Hat jemand eine Idee?
Viele Grüße S

