Skip to content

Commit

Permalink
added coderabbit js and css suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oufattole committed Oct 23, 2024
1 parent 5545136 commit 1a37dcd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
38 changes: 35 additions & 3 deletions docs/javascripts/directory-tree.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
function toggleFolder(folderId) {
function toggleFolder(folderId, event) {
if (!folderId) {
console.error('Folder ID is required');
return;
}

const content = document.getElementById(folderId);
if (!content) {
console.error(`Element with ID ${folderId} not found`);
return;
}

const folderItem = content.previousElementSibling;
if (!folderItem) {
console.error(`No folder item found for content ${folderId}`);
return;
}

const isExpanded = folderItem.classList.contains('active');

// Update ARIA attributes
folderItem.setAttribute('role', 'button');
folderItem.setAttribute('aria-expanded', !isExpanded);
folderItem.setAttribute('aria-controls', folderId);
content.setAttribute('role', 'region');

// Toggle active state on folder item
folderItem.classList.toggle('active');

// Toggle visibility of content
content.classList.toggle('visible');

// Prevent event bubbling
event.stopPropagation();
if (event) {
event.stopPropagation();
}
}

// Add keyboard support
document.addEventListener('keydown', (event) => {
if (event.target.hasAttribute('aria-controls') &&
(event.key === 'Enter' || event.key === ' ')) {
event.preventDefault();
toggleFolder(event.target.getAttribute('aria-controls'), event);
}
});
7 changes: 4 additions & 3 deletions docs/stylesheets/directory-tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
.md-typeset .admonition.folder,
.md-typeset details.folder {
border: none;
border-left: 3px solid rgb(40, 72, 214);
border-left: 3px solid var(--md-primary-fg-color);
box-shadow: none;
background: none;
background: var(--md-default-bg-color--light);
}

.md-typeset .folder > .admonition-title,
Expand All @@ -18,8 +18,9 @@
font-weight: normal;
display: flex;
align-items: center;
min-height: 24px; /* Ensure consistent height */
min-height: 40px; /* Better touch target size */
gap: 0.5rem; /* Add space between icon and text */
color: var(--md-typeset-color); /* Ensure sufficient contrast */
}

.md-typeset .folder > .admonition-title::before,
Expand Down

0 comments on commit 1a37dcd

Please sign in to comment.