diff --git a/app/components/main_with_tabnav_component.html.erb b/app/components/main_with_tabnav_component.html.erb new file mode 100644 index 0000000..40829db --- /dev/null +++ b/app/components/main_with_tabnav_component.html.erb @@ -0,0 +1,14 @@ +
+
+
+
+ +
+
+
+ <%= content %> +
+
+
diff --git a/app/components/main_with_tabnav_component.rb b/app/components/main_with_tabnav_component.rb new file mode 100644 index 0000000..73816cc --- /dev/null +++ b/app/components/main_with_tabnav_component.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class MainWithTabnavComponent < ViewComponent::Base + def initialize(tabnav_partial:) + @tabnav_partial = tabnav_partial + end +end diff --git a/app/components/tabnav_link_component.html.erb b/app/components/tabnav_link_component.html.erb new file mode 100644 index 0000000..f01d622 --- /dev/null +++ b/app/components/tabnav_link_component.html.erb @@ -0,0 +1,3 @@ +<%= link_to @path, class: @link_class do %> + <%= @name %> +<% end %> diff --git a/app/components/tabnav_link_component.rb b/app/components/tabnav_link_component.rb new file mode 100644 index 0000000..9994d8d --- /dev/null +++ b/app/components/tabnav_link_component.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class TabnavLinkComponent < 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) + if @active + "border-indigo-500 text-indigo-600 w-1/2 py-4 px-1 text-center border-b-2" + elsif @disabled + "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2" + else + "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2" + end + end +end diff --git a/app/controllers/donations_controller.rb b/app/controllers/contributions/donations_controller.rb similarity index 74% rename from app/controllers/donations_controller.rb rename to app/controllers/contributions/donations_controller.rb index 7800e09..5839030 100644 --- a/app/controllers/donations_controller.rb +++ b/app/controllers/contributions/donations_controller.rb @@ -1,4 +1,4 @@ -class DonationsController < ApplicationController +class Contributions::DonationsController < ApplicationController before_action :require_user_signed_in # GET /donations diff --git a/app/controllers/contributions/projects_controller.rb b/app/controllers/contributions/projects_controller.rb new file mode 100644 index 0000000..77e9fdf --- /dev/null +++ b/app/controllers/contributions/projects_controller.rb @@ -0,0 +1,8 @@ +class Contributions::ProjectsController < ApplicationController + before_action :require_user_signed_in + + # GET /contributions + def index + @current_section = :contributions + end +end diff --git a/app/views/donations/index.html.erb b/app/views/contributions/donations/index.html.erb similarity index 73% rename from app/views/donations/index.html.erb rename to app/views/contributions/donations/index.html.erb index bbb4f3c..6217149 100644 --- a/app/views/donations/index.html.erb +++ b/app/views/contributions/donations/index.html.erb @@ -1,6 +1,6 @@ -<%= render HeaderComponent.new(title: "Donations") %> +<%= render HeaderComponent.new(title: "Contributions") %> -<%= render MainSimpleComponent.new do %> +<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>

Your financial contributions to the development and upkeep of Kosmos @@ -34,7 +34,9 @@ <% else %>

- No donations to show. + The donation process is not automated yet. Please + contact us + if you'd like to contribute this way right now.

<% end %>
diff --git a/app/views/contributions/projects/index.html.erb b/app/views/contributions/projects/index.html.erb new file mode 100644 index 0000000..b13d7c9 --- /dev/null +++ b/app/views/contributions/projects/index.html.erb @@ -0,0 +1,16 @@ +<%= render HeaderComponent.new(title: "Contributions") %> + +<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %> +
+

+ Project contributions are how we develop and run all Kosmos software and + services. Everything we create and provide is free and open-source + software, even the page you're looking at right now! +

+

+ Soon you will find a summary of your contributions here. Until then, + please refer to the + Kredits dashboard. +

+
+<% end %> diff --git a/app/views/donations/index.json.jbuilder b/app/views/donations/index.json.jbuilder deleted file mode 100644 index 9df428c..0000000 --- a/app/views/donations/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @donations, partial: "donations/donation", as: :donation diff --git a/app/views/shared/_main_nav.html.erb b/app/views/shared/_main_nav.html.erb index 2e49a05..90e4428 100644 --- a/app/views/shared/_main_nav.html.erb +++ b/app/views/shared/_main_nav.html.erb @@ -1,9 +1,9 @@ <%= link_to "Services", root_path, class: main_nav_class(@current_section, :dashboard) %> +<%= link_to "Contributions", contributions_donations_path, + class: main_nav_class(@current_section, :contributions) %> <%= link_to "Invitations", invitations_path, class: main_nav_class(@current_section, :invitations) %> -<%= link_to "Donations", donations_path, - class: main_nav_class(@current_section, :contributions) %> <%= link_to "Wallet", wallet_path, class: main_nav_class(@current_section, :wallet) %> <%= link_to "Settings", security_path, diff --git a/app/views/shared/_tabnav_contributions.html.erb b/app/views/shared/_tabnav_contributions.html.erb new file mode 100644 index 0000000..ac75cba --- /dev/null +++ b/app/views/shared/_tabnav_contributions.html.erb @@ -0,0 +1,8 @@ +<%= render TabnavLinkComponent.new( + name: "Donations", path: contributions_donations_path, + active: current_page?(contributions_donations_path) +) %> +<%= render TabnavLinkComponent.new( + name: "Projects", path: contributions_projects_path, + active: current_page?(contributions_projects_path) +) %> diff --git a/config/routes.rb b/config/routes.rb index b0cf70e..5791972 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,9 +15,13 @@ Rails.application.routes.draw do get 'security', to: 'security#index' - resources :invitations, only: ['index', 'show', 'create', 'destroy'] + namespace :contributions do + root to: 'donations#index' + get 'projects', to: 'projects#index' + resources :donations, only: ['index'] + end - resources :donations + resources :invitations, only: ['index', 'show', 'create', 'destroy'] get 'wallet', to: 'wallet#index' get 'wallet/transactions', to: 'wallet#transactions'