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

Visually show that toggles have been selected on libraries page without opening each toggle #361

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,51 @@ label {
padding-bottom: 10px;
}

/* -------------------- */
/* ACCORDION STYLES */
/* -------------------- */

.accordion {
--bs-accordion-bg: #191d20;
}

.accordion-body,
.card-group {
background-color: #212529;
padding-top: 10px;
padding-bottom: 10px;
}

/* ✅ Add a green left border when an accordion has selected items */
.accordion-header.selected {
border-left: 4px solid #00bc8c !important; /* Bright green left border */
padding-left: 10px !important; /* Space text from border */
}

/* ✅ Ensure expanded accordion does NOT fill with green */
.accordion-button:not(.collapsed) {
background-color: transparent !important; /* No background fill */
color: white !important;
border-color: #343a40 !important; /* Keep border subtle */
}

/* ✅ Prevent hover/focus from changing colors too much */
.accordion-button:not(.collapsed):hover,
.accordion-button:not(.collapsed):focus {
background-color: transparent !important;
color: white !important;
border-color: #343a40 !important;
}

/* ✅ Keep expand/collapse arrow white when expanded */
.accordion-button:not(.collapsed)::after {
color: white !important;
}

/* ✅ Keep expand/collapse arrow white when collapsed */
.accordion-button.collapsed::after {
color: white !important;
}

.mb-3.small {
margin-bottom: 0rem !important;
Expand Down Expand Up @@ -323,4 +368,4 @@ div#loading {

.img-fluid {
max-height: 500px;
}
}
51 changes: 51 additions & 0 deletions static/local-js/025-libraries.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
/* global $, showToast */

document.addEventListener('DOMContentLoaded', function () {
function updateAccordionHighlights () {
document.querySelectorAll('.accordion-item').forEach((accordion) => {
const isCheckedOrSelected = accordion.querySelector(
"input[type='checkbox']:checked, input[type='radio']:checked, select option:checked:not([value='']):not([value='none'])"
) !== null

const accordionHeader = accordion.querySelector('.accordion-header')

if (isCheckedOrSelected) {
highlightParentAccordions(accordionHeader)
} else {
removeHighlightIfEmpty(accordionHeader)
}
})
}
function highlightParentAccordions (element) {
while (element) {
if (element.classList.contains('accordion-header')) {
element.classList.add('selected')
}
element = element.closest('.accordion-item')?.parentElement.closest('.accordion-item')
}
}

function removeHighlightIfEmpty (element) {
if (!element) return
const accordionItem = element.closest('.accordion-item')
if (!accordionItem) return

const hasSelections = accordionItem.querySelector(
"input[type='checkbox']:checked, input[type='radio']:checked, select option:checked:not([value='']):not([value='none'])"
)

if (!hasSelections) {
element.classList.remove('selected')
}

// Recursively check parents
const parentAccordionHeader = accordionItem.parentElement.closest('.accordion-item')?.querySelector('.accordion-header')
removeHighlightIfEmpty(parentAccordionHeader)
}

// Attach event listeners to checkboxes, radio buttons, and dropdowns
document.querySelectorAll("input[type='checkbox'], input[type='radio'], select").forEach((input) => {
input.addEventListener('change', updateAccordionHighlights)
})

// Run on page load to update any previously selected items
updateAccordionHighlights()

fetch('/check_base_images')
.then(response => response.json())
.then(data => {
Expand All @@ -19,6 +69,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
})
.catch(error => console.error('Error checking base images:', error))

const previewMovieButton = document.getElementById('previewOverlayButtonMovie')
const previewShowButton = document.getElementById('previewOverlayButtonShow')
const uploadMovieInput = document.getElementById('baseImageUploadMovie')
Expand Down
Loading