Skip to content

Commit

Permalink
Generating components
Browse files Browse the repository at this point in the history
  • Loading branch information
devguilhermeribeiro committed Nov 10, 2024
1 parent 9a9d444 commit 43bc62f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/components/button_to_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= button_to @name, @path, method: @method %>
9 changes: 9 additions & 0 deletions app/components/button_to_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class ButtonToComponent < ViewComponent::Base
def initialize(name, path, method)
@name = name
@path = path
@method = method
end
end
14 changes: 9 additions & 5 deletions app/components/header_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<%= tag.header class: "header" do %>
<%= tag.h1 do %>
<%= link_to "Barber Agenda", @path %>
<% end %>
<%= tag.header class: "fixed top-0 left-0 z-50 w-full p-12 mb-16" do %>
<nav class="flex flex-row justify-between">
<%= tag.h1 do %>
<%= link_to "Barber Agenda", @path %>
<% end %>

<%= content %>
<div>
<%= content %>
</div>
</nav>
<% end %>
12 changes: 11 additions & 1 deletion app/components/navbar_component.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
<div>Add Navbar::Navbar template here</div>
<div data-controller="dropdown">
<button data-action="dropdown#toggle"><%= @resource ? @resource.email : "Barber Agenda" %></button>

<ul class="hidden" data-dropdown-target="menu">
<% @links.each do |link| %>
<li><%= link_to link[:name], link[:path] %></li>
<% end %>

<%= content %>
</ul>
</div>
6 changes: 5 additions & 1 deletion app/components/navbar_component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# frozen_string_literal: true

class Navbar::NavbarComponent < ViewComponent::Base
class NavbarComponent < ViewComponent::Base
def initialize(links: [], resource: nil)
@links = links
@resource = resource
end
end
3 changes: 3 additions & 0 deletions app/components/search_form_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= form_with(url: search_path) do %>

<% end %>
4 changes: 4 additions & 0 deletions app/components/search_form_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class SearchFormComponent < ViewComponent::Base
end

0 comments on commit 43bc62f

Please sign in to comment.