From e14a408e65562fb6f8fc282a6133a7c9a2cd8651 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Mon, 2 Oct 2023 01:26:38 +0000 Subject: [PATCH] Style more links in the standard way --- app/helpers/application_helper.rb | 11 +++++++++-- app/views/_tailwind/alerts_new/edit.html.erb | 2 +- app/views/_tailwind/devise/registrations/new.html.erb | 4 ++-- app/views/_tailwind/home/_how_it_works.html.erb | 2 +- app/views/_tailwind/home/_trending.html.erb | 2 +- app/views/_tailwind/kaminari/_next_page.html.erb | 2 +- app/views/_tailwind/kaminari/_page.html.erb | 6 +----- app/views/_tailwind/kaminari/_paginator.html.erb | 2 +- app/views/_tailwind/kaminari/_prev_page.html.erb | 2 +- app/views/_tailwind/profiles/_comment.html.erb | 5 ++--- 10 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9ef66e1ce..d9b751b27 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,18 +13,25 @@ module ApplicationHelper # Only to be used in tailwind theme # TODO: Generalise to support all the variants - sig { params(body: String, url: String, html_options: T::Hash[Symbol, String]).returns(String) } + sig { params(body: T.untyped, url: String, html_options: T::Hash[Symbol, String]).returns(String) } def pa_link_to(body, url, html_options = {}) link_to(body, url, class: "#{html_options[:class]} text-fuchsia font-bold hover:underline") end # Only to be used in tailwind theme # TODO: Generalise to support all the variants - sig { params(body: String, url: String, html_options: T::Hash[Symbol, String]).returns(String) } + sig { params(body: T.untyped, url: String, html_options: T::Hash[Symbol, String]).returns(String) } def pa_link_to_unless_current(body, url, html_options = {}) link_to_unless_current(body, url, class: "#{html_options[:class]} text-fuchsia font-bold hover:underline") end + # Only to be used in tailwind theme + # TODO: Generalise to support all the variants + sig { params(condition: T::Boolean, body: T.untyped, url: String, html_options: T::Hash[Symbol, String]).returns(String) } + def pa_link_to_unless(condition, body, url, html_options = {}) + link_to_unless(condition, body, url, class: "#{html_options[:class]} text-fuchsia font-bold hover:underline") + end + sig { params(path: String, extra_classes: T::Array[Symbol], block: T.untyped).returns(T.untyped) } def menu_item(path, extra_classes: [], &block) li_selected(current_page?(path), extra_classes:) do diff --git a/app/views/_tailwind/alerts_new/edit.html.erb b/app/views/_tailwind/alerts_new/edit.html.erb index f2bc598e0..9da5869a6 100644 --- a/app/views/_tailwind/alerts_new/edit.html.erb +++ b/app/views/_tailwind/alerts_new/edit.html.erb @@ -1,4 +1,4 @@ -<%= link_to "< Back to menu", profile_alerts_path, class: "text-2xl font-medium underline text-navy" %> +<%= pa_link_to "< Back to menu", profile_alerts_path, class: "text-2xl" %>

<%= @alert.address %>

diff --git a/app/views/_tailwind/devise/registrations/new.html.erb b/app/views/_tailwind/devise/registrations/new.html.erb index bd6d2644f..f567b870b 100644 --- a/app/views/_tailwind/devise/registrations/new.html.erb +++ b/app/views/_tailwind/devise/registrations/new.html.erb @@ -37,8 +37,8 @@ Already have an account?

- <%= link_to "Sign in", new_user_session_path, class: "underline" %> or - <%= link_to "activate", new_users_activation_path, class: "underline" %>. + <%= pa_link_to "Sign in", new_user_session_path %> or + <%= pa_link_to "activate", new_users_activation_path %>.

diff --git a/app/views/_tailwind/home/_how_it_works.html.erb b/app/views/_tailwind/home/_how_it_works.html.erb index f29239572..d89d23352 100644 --- a/app/views/_tailwind/home/_how_it_works.html.erb +++ b/app/views/_tailwind/home/_how_it_works.html.erb @@ -32,6 +32,6 @@
- <%= link_to "> Learn more about Planning Alerts", about_path, class: "text-xl font-bold text-yellow" %> + <%= pa_link_to "> Learn more about Planning Alerts", about_path, class: "text-xl" %>
diff --git a/app/views/_tailwind/home/_trending.html.erb b/app/views/_tailwind/home/_trending.html.erb index 2462fc6a0..988407324 100644 --- a/app/views/_tailwind/home/_trending.html.erb +++ b/app/views/_tailwind/home/_trending.html.erb @@ -8,6 +8,6 @@ <%= render partial: "home/application_trending", collection: applications.limit(6), as: :application %>
- <%= link_to "> View more trending applications", trending_applications_path, class: "text-xl font-bold text-yellow" %> + <%= pa_link_to "> View more trending applications", trending_applications_path, class: "text-xl" %>
diff --git a/app/views/_tailwind/kaminari/_next_page.html.erb b/app/views/_tailwind/kaminari/_next_page.html.erb index 890365b99..40713a51f 100644 --- a/app/views/_tailwind/kaminari/_next_page.html.erb +++ b/app/views/_tailwind/kaminari/_next_page.html.erb @@ -6,4 +6,4 @@ per_page: number of items to fetch per page remote: data-remote -%> <%# Not using t("views.pagination.next") because we only want to override it in the tailwind theme %> -<%= link_to_unless current_page.last?, "Next page ›".html_safe, url, rel: "next", remote:, class: "underline" %> +<%= pa_link_to_unless current_page.last?, "Next page ›".html_safe, url, rel: "next", remote: %> diff --git a/app/views/_tailwind/kaminari/_page.html.erb b/app/views/_tailwind/kaminari/_page.html.erb index cc68b7fff..b79b8f323 100644 --- a/app/views/_tailwind/kaminari/_page.html.erb +++ b/app/views/_tailwind/kaminari/_page.html.erb @@ -6,8 +6,4 @@ total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> -<% if page.current? %> - <%= page %> -<% else %> - <%= link_to page, url, { remote:, rel: page.rel } %> -<% end %> +<%= pa_link_to_unless page.current?, page, url, { remote:, rel: page.rel } %> diff --git a/app/views/_tailwind/kaminari/_paginator.html.erb b/app/views/_tailwind/kaminari/_paginator.html.erb index 9256b135d..c16284327 100644 --- a/app/views/_tailwind/kaminari/_paginator.html.erb +++ b/app/views/_tailwind/kaminari/_paginator.html.erb @@ -6,7 +6,7 @@ remote: data-remote paginator: the paginator that renders the pagination tags inside -%> <%= paginator.render do -%> -