Skip to content

Commit

Permalink
refactor: use the <details> tag for the accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
jdreesen committed Oct 25, 2024
1 parent 154bf1b commit a9a9633
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
13 changes: 4 additions & 9 deletions public/css/admin-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

/* Accordion */
#neusta_areabrick_config .accordion button {
#neusta_areabrick_config details.accordion > summary {
background-color: #efefef;
color: #444;
cursor: pointer;
Expand All @@ -94,19 +94,14 @@
margin-bottom: 3px;
}

#neusta_areabrick_config .accordion button.active,
#neusta_areabrick_config .accordion button:hover {
#neusta_areabrick_config details[open].accordion > summary,
#neusta_areabrick_config details.accordion > summary:hover {
background-color: #ccc;
}

#neusta_areabrick_config .accordion ul {
#neusta_areabrick_config details.accordion > ul {
padding: 0 18px;
display: none;
overflow-x: hidden;
overflow-y: auto;
max-height: 500px;
}

#neusta_areabrick_config .accordion ul.active {
display: block;
}
6 changes: 0 additions & 6 deletions public/js/areabrick-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ neusta.areabrick_config.areabrick_overview = Class.create({
this.handleClick('#neusta_areabrick_config a[data-page-id]', el => {
pimcore.helpers.openDocument(el.dataset.pageId, el.dataset.pageType);
})

this.handleClick('#neusta_areabrick_config .accordion', (el, event) => {
if (event.target.tagName === 'BUTTON') {
el.querySelectorAll('button, ul').forEach(el => el.classList.toggle('active'));
}
})
}

return this.panel;
Expand Down
14 changes: 6 additions & 8 deletions templates/bricks/overview.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
{% set unpublished_pages = brick.pages|filter(page => not page.published) %}

{% if published_pages is not empty %}
<!-- Published Pages Accordion -->
<div class="accordion">
<button>{{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.published_pages'|trans }}</button>
<details class="accordion">
<summary>{{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.published_pages'|trans }}</summary>
<ul>
{% for page in published_pages %}
<li>
Expand All @@ -39,13 +38,12 @@
</li>
{% endfor %}
</ul>
</div>
</details>
{% endif %}

{% if unpublished_pages is not empty %}
<!-- Unpublished Pages Accordion -->
<div class="accordion">
<button>{{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.unpublished_pages'|trans }}</button>
<details class="accordion">
<summary>{{ 'neusta_pimcore_areabrick_config.areabricks.overview.table.unpublished_pages'|trans }}</summary>
<ul>
{% for page in unpublished_pages %}
<li>
Expand All @@ -55,7 +53,7 @@
</li>
{% endfor %}
</ul>
</div>
</details>
{% endif %}
</td>
{% if hasAdditionalProperties %}
Expand Down

0 comments on commit a9a9633

Please sign in to comment.