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

feat: Introduced Right Subsections for Seamless Topic Access #99

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

ankitkumar748846
Copy link
Contributor

Description: Added the appropriate right subsection where all the topics of the pages are listed, allowing users to easily navigate through different topics.

Issue fixed: #75

Changes done:

  • Task 1

Screenshots/Videos

✅️ By submitting this PR, I have verified the following

  • Checked to see if a similar PR has already been opened 🤔️
  • Reviewed the contributing guidelines 🔍️
  • Tried squashing the commits into one

@ankitkumar748846
Copy link
Contributor Author

@aaronbrethorst Sir I have implemented the right subsections. Please review it and suggest if any changes required ..

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

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

please move the code into the specified JS file. otherwise looks great 👍

frontend/javascript/code_snippets.js Outdated Show resolved Hide resolved
frontend/javascript/code_snippets.js Outdated Show resolved Hide resolved
@ankitkumar748846
Copy link
Contributor Author

@aaronbrethorst Done sir.

@@ -33,6 +33,32 @@ export function copyHeadingDirectLinks() {
});
}

export function setupSidebarItemEventListeners() {
Copy link
Member

Choose a reason for hiding this comment

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

this needs to move too.

@ankitkumar748846
Copy link
Contributor Author

@aaronbrethorst Please review it and suggest if any changes required ..

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

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

I'm going to merge this but I want you to look carefully at the changes that I'm making as an immediate followup to it so you can see what I wanted to see in this PR.

sidebar.style.height = '100%';

function appendSidebarItem(textContent, tagName) {
const newItem = document.createElement('p');
Copy link
Member

Choose a reason for hiding this comment

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

these should be anchor tags so that they are accessible. That would have the added advantage that you then don't need to apply custom colors on mouseenter and mouseleave.

const h2Elements = document.querySelectorAll('h2');
const sidebar = document.querySelector('.sidebar');

sidebar.style.position = 'fixed';
Copy link
Member

Choose a reason for hiding this comment

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

these styles should all be expressed as tailwind classes in the HTML


export function setupSidebar() {
const h1Elements = document.querySelectorAll('h1');
const h2Elements = document.querySelectorAll('h2');
Copy link
Member

Choose a reason for hiding this comment

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

changing this line to document.querySelectorAll('article h2') would mean you can get rid of the counting of categories down below. That also future-proofs your changes in case the number of h2 tags in the navigation panel changes. you can't trust that the number of elements on the page will remain fixed. and if you have to for some reason you have to leave a comment explaining your decision

const newItem = document.createElement('p');
newItem.textContent = textContent;
if (tagName === 'h1') {
newItem.classList.add('sidebar-item');
Copy link
Member

Choose a reason for hiding this comment

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

add() can take multiple arguments.

@aaronbrethorst aaronbrethorst merged commit 2e176e1 into OneBusAway:main Mar 20, 2024
2 checks passed
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.

feat: Create a subsection on the right side of the web page.
2 participants