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

Collapsible Sections #455

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Collapsible Sections #455

merged 2 commits into from
Dec 12, 2024

Conversation

Justinabes007
Copy link
Contributor

@Justinabes007 Justinabes007 commented Dec 10, 2024

Functionality to allow Collapsible sections for Mobile + Facility styles

This update introduces collapsible sections to improve the mobile user experience and enhance the layout for facilities styles. The following changes have been made:

CSS Enhancements:

  1. Added mobile-friendly styles for collapsible sections, ensuring a more compact and user-friendly layout.
  2. Improved alignment and spacing for facility lists and fast facts sections using flexbox-based styling.
  3. Introduced new styles to handle the display of collapsible content, maintaining accessibility and readability on smaller screens.

JavaScript Functionality:

  1. Implemented toggle functionality for collapsible sections, allowing users to expand or collapse sections for a cleaner interface.
  2. Integrated visual feedback (e.g., a tick icon) to indicate expanded sections.

New Assets:

  1. Added new assets, including the tick.svg, to visually represent the expanded/collapsed state.

Impact:

  • Improves the layout and interactivity for mobile users.
  • Ensures better management of content visibility without overcrowding the screen.

Testing:

  • Verified functionality on mobile and desktop devices.
  • Ensured the collapsible sections work as expected without affecting other components.

Summary by CodeRabbit


  • New Feature: Introduced collapsible sections for mobile and facility styles, enhancing user navigation on smaller screens.
  • Style: Improved the visual appeal of 'fast facts' sections with enhanced CSS styling, including flexbox properties, image/icon styling, and text alignment.
  • New Feature: Added a dynamic toggle button to expand/collapse sections, improving user interaction and content accessibility.
  • Style: Implemented responsive design adjustments using media queries, ensuring optimal viewing and interaction across a range of devices.

Functionality to allow Collapsible sections for Mobile + Facility styles
@Justinabes007 Justinabes007 added [Dev] CSS Styling Related to editor and front end styles, CSS-specific issues. javascript Pull requests that update Javascript code labels Dec 10, 2024
@Justinabes007 Justinabes007 added this to the 2.1.0 milestone Dec 10, 2024
@Justinabes007 Justinabes007 self-assigned this Dec 10, 2024
Copy link

coderabbitai bot commented Dec 10, 2024

Warning

CodeRabbit GitHub Action detected

The repository is using both CodeRabbit Pro and CodeRabbit Open Source (via GitHub Actions), which is not recommended as it may lead to duplicate comments and extra noise. Please remove the CodeRabbit GitHub Action.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Dec 10, 2024

Image description CodeRabbit

Walkthrough

This update introduces enhancements to the collapsible sections of the website, improving both functionality and aesthetics. It includes responsive design adjustments for smaller screens, improved styling for fast facts sections, and dynamic toggle buttons for expanding/collapsing sections.

Changes

Files Summaries
assets/css/style.css, assets/js/src/custom.js Introduced enhancements for collapsible sections including CSS styling and JavaScript functionality. Improved styling for fast facts sections, added responsive adjustments for smaller screens, and enabled collapsible sections for mobile and facility styles. The changes include flexbox properties, image/icon styling, text alignment, the addition of a tick icon, and dynamically creating toggle buttons to expand/collapse sections, updating the display icons accordingly. Media queries are used for responsive design.

🐰 "In the land of code, where logic is king,

We dance with functions, in loops we swing.

With style and grace, our sites take flight,

Responsive and sleek, oh what a sight!

Collapsible sections, a tick icon too,

For small screens and large, these changes are for you!" 🎉


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between d60a963 and 95095de commits.
Files selected (2)
  • assets/css/style.css (1)
  • assets/js/src/custom.js (1)
Files ignored due to filter (1)
  • assets/img/tick.svg
Review comments generated (8)
  • Review: 3
  • LGTM: 5

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +338 to +359

.facilities-list li::marker{display:none;}
.facilities-list{padding-left:0!important;}

.facilities-list li {
margin-left: 10px;
list-style: none; /* Remove default list marker */
position: relative; /* Position for pseudo-element */}

.facilities-list li::before{
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%); /* Center the icon vertically */
width: 20px; /* Adjust the size of the tick icon */
height: 20px;
background-image: url('../img/tick.svg'); /* Replace with the path to your tick.svg */
background-size: contain;
background-repeat: no-repeat;
left:-28px
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

The CSS rule for .facilities-list li::before uses a relative path to the tick.svg image. This could potentially cause issues if the CSS file is moved or if the website structure changes. Consider using an absolute path or a path that starts from the root of your project.

-    background-image: url('../img/tick.svg');
+    background-image: url('/path/to/img/tick.svg');

Comment on lines +374 to +380

sections.forEach(section => {
// Locate the first <h2> within the section
const heading = section.querySelector('h2');
// Locate the second div with the class wp-block-group
const toggleTarget = section.querySelectorAll('.wp-block-group')[1];

Choose a reason for hiding this comment

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

Image description CodeRabbit

The debug console.log statements should be removed from the production code. They are useful during development but can expose potentially sensitive information in a production environment.

- 			console.log('Processing Section:', section); // Debug
- 			console.log('Found Heading:', heading); // Debug
- 			console.log('Toggle Target:', toggleTarget); // Debug

Comment on lines +396 to +413
// Insert the button after the heading
heading.insertAdjacentElement('afterend', toggleButton);

// Add click event listener to toggle visibility of the second wp-block-group
toggleButton.addEventListener('click', function () {
toggleTarget.classList.toggle('collapsed'); // Add or remove the collapsed class

// Toggle the display of the up/down icons
const iconDown = toggleButton.querySelector('.icon-down');
const iconUp = toggleButton.querySelector('.icon-up');

if (toggleTarget.classList.contains('collapsed')) {
iconDown.style.display = 'none';
iconUp.style.display = 'inline';
} else {
iconDown.style.display = 'inline';
iconUp.style.display = 'none';
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

This block of code is responsible for toggling the visibility of sections and changing the icon accordingly. However, it directly manipulates the style of the elements which can lead to issues with CSS specificity and maintainability. It would be better to use CSS classes to control the display of the icons.

- 					if (toggleTarget.classList.contains('collapsed')) {
- 						iconDown.style.display = 'none';
- 						iconUp.style.display = 'inline';
- 					} else {
- 						iconDown.style.display = 'inline';
- 						iconUp.style.display = 'none';
- 					}
+ 					if (toggleTarget.classList.contains('collapsed')) {
+ 						iconDown.classList.add('hidden');
+ 						iconUp.classList.remove('hidden');
+ 					} else {
+ 						iconDown.classList.remove('hidden');
+ 						iconUp.classList.add('hidden');
+ 					}

In your CSS, you can then define these classes as follows:

.hidden {
    display: none;
}

:not(.hidden) {
    display: inline;
}

Copy link
Contributor

@ZaredRogers ZaredRogers left a comment

Choose a reason for hiding this comment

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

Looks great, thanks Justin

@krugazul krugazul merged commit e93103c into 2.0-beta-3 Dec 12, 2024
5 of 6 checks passed
@krugazul krugazul deleted the collapsible-sections branch December 12, 2024 14:30
@krugazul krugazul restored the collapsible-sections branch December 12, 2024 14:30
@ZaredRogers ZaredRogers linked an issue Jan 9, 2025 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Dev] CSS Styling Related to editor and front end styles, CSS-specific issues. javascript Pull requests that update Javascript code
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Anchor Tag Links in Secondary Sticky Bar
3 participants