-
Notifications
You must be signed in to change notification settings - Fork 29
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
Burger menu #47
Closed
Closed
Burger menu #47
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
02d2e47
Adds mobile hamburg style menu
awalsh3 3852038
Adds navbar js controller to toggle menu open and close
awalsh3 4bee221
Adds id of main to application layout for drop-down menu formatting
awalsh3 6a6d319
Updates webdrivers to pass failing linters test
awalsh3 36ca1da
Runs standardrb --fix to style gem file correctly
awalsh3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
document.addEventListener('turbo:load', function () { | ||
const hamburger = document.getElementById('hamburger') | ||
if (hamburger) { | ||
hamburger.addEventListener('click', function () { | ||
const mobileMenu = document.getElementById('mobile-menu') | ||
const content = document.getElementById('main') | ||
const openIcon = document.getElementById('menu-open-icon') | ||
const closeIcon = document.getElementById('menu-close-icon') | ||
|
||
if ( | ||
mobileMenu.style.display === 'none' || | ||
mobileMenu.style.display === '' | ||
) { | ||
mobileMenu.style.display = 'block' | ||
content.style.marginTop = '200px' // adjust the value as needed | ||
openIcon.style.display = 'none' | ||
closeIcon.style.display = 'block' | ||
} else { | ||
mobileMenu.style.display = 'none' | ||
content.style.marginTop = '0' | ||
openIcon.style.display = 'block' | ||
closeIcon.style.display = 'none' | ||
} | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
<nav class="navbar"> | ||
<nav class="navbar relative md:flex"> | ||
<div class="flex justify-between w-full"> | ||
<ul> | ||
<li> | ||
<%= link_to root_path, class: "text-white flex gap-4 items-center" do %> | ||
<title>Ruby Video</title> | ||
<% end %> | ||
</li> | ||
</ul> | ||
<ul class="hidden md:flex"> | ||
<%= render "shared/navbar/link", link_title: "Talks", path: talks_path %> | ||
<%= render "shared/navbar/link", link_title: "Speakers", path: speakers_path %> | ||
<% if Current.user&.admin? %> | ||
<%= render "shared/navbar/link", link_title: "Events", path: events_path %> | ||
|
||
<%= render "shared/navbar/link", link_title: "Suggestions", path: admin_suggestions_path %> | ||
<% end %> | ||
<li> | ||
<%= link_to "https://github.com/adrienpoly/rubyvideo", target: "_blank", alt: "github repository for the Ruby video project" do %> | ||
<%= icon "github", size: :lg %> | ||
<!-- Mobile menu button --> | ||
<menu id="hamburger" class="md:hidden flex items-center px-3 py-2"> | ||
<button type="button" class="relative inline-flex items-center justify-center rounded-md p-2 text-gray-400 hover:bg-gray-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white" aria-controls="mobile-menu" aria-expanded="false"> | ||
<span class="absolute -inset-0.5"></span> | ||
<span class="sr-only">Open main menu</span> | ||
<svg id="menu-open-icon" class="block h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" /> | ||
</svg> | ||
<svg id="menu-close-icon" class="hidden h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /> | ||
</svg> | ||
</button> | ||
</menu> | ||
<ul class="hidden md:flex" id="main-menu"> | ||
<%= render "shared/navbar/link", link_title: "Talks", path: talks_path %> | ||
<%= render "shared/navbar/link", link_title: "Speakers", path: speakers_path %> | ||
<% if Current.user&.admin? %> | ||
<%= render "shared/navbar/link", link_title: "Events", path: events_path %> | ||
<%= render "shared/navbar/link", link_title: "Suggestions", path: admin_suggestions_path %> | ||
<% end %> | ||
</li> | ||
<li><a href="https://github.com/adrienpoly/rubyvideo/blob/main/docs/contributing.md" role="button" target="_blank">Contribute</a></li> | ||
</ul> | ||
<li> | ||
<%= link_to "https://github.com/adrienpoly/rubyvideo", target: "_blank", alt: "github repository for the Ruby video project" do %> | ||
<%= icon "github", size: :lg %> | ||
<% end %> | ||
</li> | ||
<li><a href="https://github.com/adrienpoly/rubyvideo/blob/main/docs/contributing.md" role="button" target="_blank">Contribute</a></li> | ||
</ul> | ||
<ul class="hidden md:hidden absolute top-full left-0 z-20 bg-brand bg-opacity-50 p-4 rounded shadow-md md:hidden w-full" id="mobile-menu"> | ||
<%= render "shared/navbar/link", link_title: "Talks", path: talks_path %> <br> | ||
<%= render "shared/navbar/link", link_title: "Speakers", path: speakers_path %> <br> | ||
<% if Current.user&.admin? %> | ||
<%= render "shared/navbar/link", link_title: "Events", path: events_path %> | ||
<%= render "shared/navbar/link", link_title: "Suggestions", path: admin_suggestions_path %> | ||
<% end %> | ||
<li class="block"> | ||
<%= link_to "https://github.com/adrienpoly/rubyvideo", target: "_blank", alt: "github repository for the Ruby video project" do %> | ||
<%= icon "github", size: :lg %> | ||
<% end %> | ||
<br> | ||
</li> | ||
<li class="block"><a href="https://github.com/adrienpoly/rubyvideo/blob/main/docs/contributing.md" role="button" target="_blank">Contribute</a></li> | ||
</ul> | ||
</div> | ||
</nav> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point this is just vanilla js stored in a folder for stimulus controllers.
why don't you use an actual stimulus controller? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! I am new to stimulus but I should follow the convention. I will work on it sometime this week. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @awalsh3 thanks for taking this issue.
I would like to suggest an alternative path at the same time with less JS or maybe none. the details/summary html tags can be used to create dropdowns. This is What Basecamp uses in Hey as an example
Here is an article on that subject but they are also several others available :
https://dev.to/ayushn21/details-summary-tags-html-s-best-kept-secret-4ak4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! I can take a look. So would you want something like this then? Talks, Speakers, Github icon and contribute button to dropdown on the right side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I mentioned Basecamp/Hey it was more for the technical part not really the way it looks. Your personal site looks clean I am sure you can make a good judgement on what looks best. I don't have a very strong option on this.