Skip to content
Snippets Groups Projects
Commit fe29d4f3 authored by Syd's avatar Syd
Browse files

Issue #3436913 by donquixote: Field label inline not working - again

parent 8826d8a9
No related branches found
Tags 8.x-1.21
No related merge requests found
Pipeline #140026 passed with warnings
......@@ -30,61 +30,63 @@
*
*/
#}
{% apply spaceless %}
{% set title = title|default('') %}
{% set title_tag = title_tag|default('h2') %}
{% set title_link = title_link|default({}) %}
{% set title_attributes = title_attributes ?: create_attribute() %}
{% set id = id|default('accordion-' ~ random(1000)) %}
{% set flush = flush ?? false %}
{% set items = items|default([]) %}
{% set open_item_id = open_item_id|default(0) %}
{% set accordion_classes = [
'accordion'
]|merge(accordion_utility_classes ? accordion_utility_classes : []) %}
{% apply spaceless %}
{% set accordion_item_classes = [
{% set title = title|default('') %}
{% set title_tag = title_tag|default('h2') %}
{% set title_link = title_link|default({}) %}
{% set title_attributes = title_attributes ?: create_attribute() %}
{% set id = id|default('accordion-' ~ random(1000)) %}
{% set flush = flush ?? false %}
{% set items = items|default([]) %}
{% set open_item_id = open_item_id|default(0) %}
{%
set accordion_classes = [
'accordion'
]|merge(accordion_utility_classes ? accordion_utility_classes : [])
%}
{% set accordion_item_classes = [
'accordion-item'
]|merge(accordion_item_utility_classes ? accordion_item_utility_classes : []) %}
{% if flush %}
{% set accordion_classes = accordion_classes|merge(['accordion-flush']) %}
{% endif %}
{% set accordion_attributes = accordion_attributes ?: create_attribute() %}
{% set accordion_item_attributes = accordion_item_attributes ?: create_attribute() %}
{% set accordion_attributes = accordion_attributes.addClass(accordion_classes).setAttribute('id', id) %}
{% if items is not empty %}
<div {{ accordion_attributes.addClass(accordion_classes) }}>
{% if title is not empty %}
{% include 'radix:heading' with {
{% if flush %}
{% set accordion_classes = accordion_classes|merge(['accordion-flush']) %}
{% endif %}
{% set accordion_attributes = accordion_attributes ?: create_attribute() %}
{% set accordion_item_attributes = accordion_item_attributes ?: create_attribute() %}
{% set accordion_attributes = accordion_attributes.addClass(accordion_classes).setAttribute('id', id) %}
{% if items is not empty %}
<div {{ accordion_attributes.addClass(accordion_classes) }}>
{% if title is not empty %}
{% include 'radix:heading' with {
heading_html_tag: 'h2',
content: title,
heading_attributes: title_attributes,
}
%}
{% endif %}
{% for item in items %}
{% set open_item = open_item_id == loop.index %}
{% set button_classes = [
{% endif %}
{% for item in items %}
{% set open_item = open_item_id == loop.index %}
{% set button_classes = [
'accordion-button',
'text-wrap',
] %}
{% if not open_item %}
{% set button_classes = button_classes|merge(['collapsed']) %}
{% endif %}
<div {{ accordion_item_attributes.addClass(accordion_item_classes) }}>
{% set item_title_tag = item.title_tag|default('h3') %}
<{{item_title_tag}} class="accordion-header" id="heading-{{ id }}-{{ loop.index }}">
{% set button_attributes = create_attribute()
{% if not open_item %}
{% set button_classes = button_classes|merge(['collapsed']) %}
{% endif %}
<div {{ accordion_item_attributes.addClass(accordion_item_classes) }}>
{% set item_title_tag = item.title_tag|default('h3') %}
<{{item_title_tag}} class="accordion-header" id="heading-{{ id }}-{{ loop.index }}">
{% set button_attributes = create_attribute()
.addClass(button_classes)
.setAttribute('data-bs-toggle', 'collapse')
.setAttribute('autocomplete', 'off')
......@@ -93,24 +95,24 @@
.setAttribute('aria-expanded', open_item ? 'true' : 'false')
%}
{% include 'radix:button' with {
{% include 'radix:button' with {
content: item.title,
button_attributes,
} %}
</{{item_title_tag}}>
<div id="collapse-{{ id }}-{{ loop.index }}" class="accordion-collapse collapse{{ open_item ? ' show' }}" aria-labelledby="heading-{{ id }}-{{ loop.index }}" role="region" {% if not item.stay_open %} data-bs-parent="#accordion-{{ id }}" {% endif %}>
<div class="accordion-body">
{% set content = item.content|default('') %}
{% block content %}
{{ content }}
{% endblock %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endapply %}
\ No newline at end of file
</{{item_title_tag}}>
<div id="collapse-{{ id }}-{{ loop.index }}" class="accordion-collapse collapse{{ open_item ? ' show' }}" aria-labelledby="heading-{{ id }}-{{ loop.index }}" role="region" {% if not item.stay_open %} data-bs-parent="#accordion-{{ id }}" {% endif %}>
<div class="accordion-body">
{% set content = item.content|default('') %}
{% block content %}
{{ content }}
{% endblock %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endapply %}
......@@ -38,13 +38,15 @@
*/
#}
{%
set classes = [
set field_classes = [
'field',
'field--name-' ~ field_name|clean_class,
'field--type-' ~ field_type|clean_class,
'field--label-' ~ label_display,
]
label_display == 'inline' ? 'd-flex',
]|merge(field_classes_utility_classes ? field_classes_utility_classes : [])
%}
{%
set title_classes = [
'field__label',
......@@ -53,28 +55,28 @@
%}
{% if label_hidden %}
{% if multiple %}
<div{{ attributes.addClass(classes, 'field__items') }}>
{% for item in items %}
<div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
{% endfor %}
</div>
{% else %}
{% for item in items %}
<div{{ attributes.addClass(classes, 'field__item') }}>{{ item.content }}</div>
{% endfor %}
{% endif %}
{% if multiple %}
<div{{attributes.addClass(field_classes,'field__items')}}>
{% for item in items %}
<div{{item.attributes.addClass('field__item')}}>{{ item.content }}</div>
{% endfor %}
</div>
{% else %}
{% for item in items %}
<div{{attributes.addClass(field_classes,'field__item')}}>{{ item.content }}</div>
{% endfor %}
{% endif %}
{% else %}
<div{{ attributes.addClass(classes) }}>
<div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
{% if multiple %}
<div class="field__items">
{% endif %}
{% for item in items %}
<div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
{% endfor %}
{% if multiple %}
</div>
{% endif %}
</div>
<div{{attributes.addClass(field_classes)}}>
<div{{title_attributes.addClass(title_classes)}}>{{ label }}</div>
{% if multiple %}
<div class="field__items">
{% endif %}
{% for item in items %}
<div{{item.attributes.addClass('field__item')}}>{{ item.content }}</div>
{% endfor %}
{% if multiple %}
</div>
{% endif %}
</div>
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment