Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEL-3547: Added collapse/expand buttons in accordion. #632

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

tibi2303
Copy link
Collaborator

@tibi2303 tibi2303 commented Dec 4, 2024

[skip chromatic]

Copy link

github-actions bot commented Dec 4, 2024

🚀 Deployed on https://preview-632--oelibrary.netlify.app

@github-actions github-actions bot temporarily deployed to pull request December 4, 2024 19:31 Inactive
Comment on lines 40 to 52
static init() {
if (AccordionToggle.isInitialized) {
return;
}

const toggleButtons = SelectorEngine.find('[data-action][data-target]');
toggleButtons.forEach(buttonElement => new AccordionToggle(buttonElement));

AccordionToggle.isInitialized = true;
}
}

document.addEventListener("DOMContentLoaded", () => AccordionToggle.init());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are drupal behaviours for these, I'd rather init using those

@github-actions github-actions bot temporarily deployed to pull request January 10, 2025 11:02 Inactive
{%- block content _content -%}
</div>
{% endif %}
<div class="accordion-items-wrapper">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested and we can drop this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the default bootstrap styles
image

on :first-of-type on accordion items it adds a border, when we have the buttons, it no longer adds the border styles because it is not :first-of-type, so i encaspsulate them in a div to have the styles for border

{% if not _item.stay_open %}
data-bs-parent="#accordion-{{ _id }}"
{% if _items|length > 1 and (_expand_button is not empty or _collapse_button is not empty) %}
<div class="d-flex justify-content-end gap-3 mb-3">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we transfer these to a class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i created an attribute for them.

class="accordion-collapse collapse{{ _open_item ? ' show' }}"
aria-labelledby="heading-{{ _id }}-{{ loop.index }}"
role="region"
{% if not _item.stay_open and _expand_button is empty %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and _expand_button is empty why is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this attribute helps the accordion to close other 'tab' when another is opened. And when expand_button is clicked, the behaviour of the accordion does not know how to open all of them, only one because of this attribute. For the collapse_button i dont care, because it only closses all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when this attribute is not present, all the tabs can be opened separately

[skip chromatic]
@github-actions github-actions bot temporarily deployed to pull request January 29, 2025 21:39 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants