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

Dl/navbar test #123

Merged
merged 2 commits into from
Sep 7, 2024
Merged

Dl/navbar test #123

merged 2 commits into from
Sep 7, 2024

Conversation

loftwah
Copy link
Owner

@loftwah loftwah commented Sep 7, 2024

Added Stimulus Controller (dropdown_controller.js):

This introduces proper separation of concerns, moving the dropdown logic out of the HTML and into a dedicated JavaScript file.
It allows for more complex behavior and easier maintenance.

Updated application.js:

Added Stimulus initialization and controller registration.
Using stimulus-vite-helpers for easier controller registration.

Changes in application.html.erb:

Removed inline JavaScript.
Added Stimulus data attributes for the dropdown, connecting the HTML to the Stimulus controller.

Package updates:

Added @hotwired/stimulus, stimulus-vite-helpers, and vite-plugin-stimulus-hmr.
These packages provide the Stimulus framework and tools for better integration with Vite.

Updated vite.config.mts:

Added StimulusHMR plugin, which enables Hot Module Replacement for Stimulus controllers.

Key improvements:

Better organization: JavaScript logic is now in dedicated files instead of inline in the HTML.
Enhanced maintainability: Easier to update and extend functionality.
Improved development experience: Hot Module Replacement allows for faster development cycles.
Follows modern best practices: Aligns with current standards in Rails and JavaScript development.
Scalability: This structure makes it easier to add more interactive elements as your app grows.

@loftwah loftwah self-assigned this Sep 7, 2024
@loftwah loftwah merged commit 169f61c into main Sep 7, 2024
1 check passed
@loftwah loftwah deleted the dl/navbar-test branch September 7, 2024 23:49
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.

1 participant