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

Burger menu #47

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem "webdrivers", "~> 5.3"
gem "vcr", "~> 6.1"
gem "webmock"
end
Expand Down
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ GEM
racc (~> 1.4)
nokogiri (1.15.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-linux)
racc (~> 1.4)
oj (3.15.0)
Expand Down Expand Up @@ -293,6 +295,7 @@ GEM
sorbet-runtime (0.5.10888)
sqlite3 (1.6.3-aarch64-linux)
sqlite3 (1.6.3-arm64-darwin)
sqlite3 (1.6.3-x86_64-darwin)
sqlite3 (1.6.3-x86_64-linux)
standard (1.29.0)
language_server-protocol (~> 3.17.0.2)
Expand Down Expand Up @@ -332,10 +335,10 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.2.0)
webdrivers (5.3.1)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
selenium-webdriver (~> 4.0, < 4.11)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand All @@ -352,6 +355,7 @@ GEM
PLATFORMS
aarch64-linux
arm64-darwin-22
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -389,7 +393,7 @@ DEPENDENCIES
vcr (~> 6.1)
vite_rails (~> 3.0)
web-console
webdrivers
webdrivers (~> 5.3)
webmock

RUBY VERSION
Expand Down
26 changes: 26 additions & 0 deletions app/javascript/controllers/navbar_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
document.addEventListener('turbo:load', function () {
Copy link
Collaborator

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? :)

Copy link
Author

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!

Copy link
Owner

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

Copy link
Author

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?

Screenshot 2023-08-07 at 13 57 12

Copy link
Owner

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.

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'
}
})
}
})
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%= render "shared/top_banner" %>
<%= render "shared/navbar" %>
<%= render "shared/flashes" %>
<div class="min-h-screen">
<div class="min-h-screen" id="main">
<%= yield %>
</div>
</body>
Expand Down
59 changes: 44 additions & 15 deletions app/views/shared/_navbar.html.erb
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>
Loading