Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascumsille committed Oct 2, 2024
1 parent 81b00a3 commit 8a81781
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
41 changes: 41 additions & 0 deletions www/docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,47 @@ function wrap_error($message){
return '<div class="donate-form__error-wrapper"><p class="donate-form__error">' + $message + '</p></div>';
}

function createAccordion(triggerSelector, contentSelector) {
var triggers = document.querySelectorAll(triggerSelector);

triggers.forEach(function(trigger) {
var content = document.querySelector(trigger.getAttribute('href'));

var openAccordion = function() {
content.style.maxHeight = content.scrollHeight + "px"; // Dynamically calculate height
content.setAttribute('aria-hidden', 'false');
trigger.setAttribute('aria-expanded', 'true');
};

var closeAccordion = function() {
content.style.maxHeight = null; // Collapse
content.setAttribute('aria-hidden', 'true');
trigger.setAttribute('aria-expanded', 'false');
};

trigger.addEventListener('click', function(e) {
e.preventDefault();

if (content.style.maxHeight) {
closeAccordion();
} else {
openAccordion();
}
});

// Accessibility
trigger.setAttribute('aria-controls', content.getAttribute('id'));
trigger.setAttribute('aria-expanded', 'false');
content.setAttribute('aria-hidden', 'true');
content.style.maxHeight = null;
});
}

// Initialize accordion when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
createAccordion('.accordion-trigger', '.accordion-content');
});

$(function() {

$('#how-often-annually').click(function() {
Expand Down
22 changes: 22 additions & 0 deletions www/docs/style/sass/accordion.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.accordion-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
}

.accordion-button[aria-expanded="true"] + .accordion-content {
max-height: 1000px;
transition: max-height 0.3s ease;
}

.accordion-button {
display: block;
width: 100%;
text-align: left;
padding: 10px;
font-size: 1.2em;
cursor: pointer;
border: none;
background: #f0f0f0;
}

1 change: 1 addition & 0 deletions www/docs/style/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
@import "compass/css3";
@import "_twfy-mixins.scss";
@import "accessible-autocomplete";
@import "accordion";

@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700,400italic&display=swap);
@import url(https://fonts.googleapis.com/css2?family=Manrope:wght@700&family=Merriweather:wght@400;700&display=swap);
Expand Down
26 changes: 26 additions & 0 deletions www/includes/easyparliament/templates/html/alert/alert-mockup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="accordion">
<button class="accordion-trigger" href="#accordion-content-1" aria-expanded="false">
Accordion Title 1
</button>
<div id="accordion-content-1" class="accordion-content" aria-hidden="true">
<p>ero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque n</p>
</div>
</div>

<div class="accordion">
<button class="accordion-trigger" href="#accordion-content-2" aria-expanded="false">
Accordion Title 2
</button>
<div id="accordion-content-2" class="accordion-content" aria-hidden="true">
<p>ero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque n</p>
</div>
</div>

<div class="accordion">
<button class="accordion-trigger" href="#accordion-content-3" aria-expanded="false">
Accordion Title 3
</button>
<div id="accordion-content-3" class="accordion-content" aria-hidden="true">
<p>ero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque n</p>
</div>
</div>
2 changes: 1 addition & 1 deletion www/includes/easyparliament/templates/html/alert/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
</div>

<div class="alert-section__primary">

<?php include 'alert-mockup.php'; ?>
<?php if ($pid) { ?>
<h3>
<?php
Expand Down

0 comments on commit 8a81781

Please sign in to comment.