WIP contribution nav
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Râu Cao 2023-06-12 14:32:59 +02:00
parent 8eb5f093a4
commit 462dd24da3
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
7 changed files with 62 additions and 16 deletions

View File

@ -0,0 +1,3 @@
<%= link_to @path, class: @link_class do %>
<%= @name %>
<% end %>

View File

@ -0,0 +1,20 @@
# frozen_string_literal: true
class HeaderTabLinkComponent < ViewComponent::Base
def initialize(name:, path:, active: false, disabled: false)
@name = name
@path = path
@active = active
@disabled = disabled
@link_class = class_names_link(path)
end
def class_names_link(path)
common = "block md:inline-block px-5 py-2 rounded-md font-medium text-base md:text-xl"
if @active
"#{common} bg-gray-900/50 text-white"
else
"#{common} text-gray-300 hover:bg-gray-900/30 hover:text-white active:bg-gray-900/30 active:text-white"
end
end
end

View File

@ -0,0 +1,12 @@
<header class="py-10">
<div class="max-w-6xl md:flex md:gap-x-10 mx-auto px-4 sm:px-6 lg:px-8">
<% if @title.present? %>
<h1 class="text-3xl font-bold text-white">
<%= @title %>
</h1>
<% end %>
<nav class="md:grow flex gap-x-4 <%= @title.present? ? "justify-end" : "justify-start" %>" aria-label="Tabs">
<%= render partial: @tabnav_partial %>
</nav>
</div>
</header>

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
class HeaderWithTabsComponent < ViewComponent::Base
def initialize(title: nil, tabnav_partial:)
@title = title
@tabnav_partial = tabnav_partial
end
end

View File

@ -1,6 +1,10 @@
<%= render HeaderComponent.new(title: "Contributions") %>
<%# <%= render HeaderComponent.new(title: "Contributions") %>
<%= render HeaderWithTabsComponent.new(
# title: "Contributions",
tabnav_partial: "shared/tabnav_contributions"
) %>
<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>
<%= render MainSimpleComponent.new do %>
<section>
<% if @donations.any? %>
<p class="mb-12">

View File

@ -1,6 +1,9 @@
<%= render HeaderComponent.new(title: "Contributions") %>
<%= render HeaderWithTabsComponent.new(
# title: "Contributions",
tabnav_partial: "shared/tabnav_contributions"
) %>
<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>
<%= render MainSimpleComponent.new do %>
<section>
<p class="mb-8">
Project contributions are how we develop and run all Kosmos software and

View File

@ -1,12 +1,8 @@
<div class="border-b border-gray-200">
<nav class="-mb-px flex" aria-label="Tabs">
<%= render TabnavLinkComponent.new(
<%= render HeaderTabLinkComponent.new(
name: "Donations", path: contributions_donations_path,
active: current_page?(contributions_donations_path)
) %>
<%= render TabnavLinkComponent.new(
) %>
<%= render HeaderTabLinkComponent.new(
name: "Projects", path: contributions_projects_path,
active: current_page?(contributions_projects_path)
) %>
</nav>
</div>
) %>