Skip to content

Commit

Permalink
Switch over more links
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 1, 2023
1 parent d3cd275 commit ac24f28
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ 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) }
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

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
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/alerts_new/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
Alerts are sent to your email at
<%= current_user.email %>
</p>
<%= link_to "Change", edit_user_registration_path, class: "text-orange underline font-bold text-2xl mt-1 inline-block" %>
<%= pa_link_to "Change", edit_user_registration_path, class: "text-2xl mt-1 inline-block" %>
</div>

<% if @alerts.empty? %>
<div class="flex items-center justify-between border mt-11 border-light-grey2">
<div class="flex justify-center flex-grow">
<div class="ml-12 mr-4">
<p class="text-2xl font-normal text-navy">You have no saved alerts</p>
<%= link_to "Create your first one", new_profile_alert_path, class: "text-orange text-2xl font-bold underline" %>
<%= pa_link_to "Create your first one", new_profile_alert_path, class: "text-2xl" %>
</div>
</div>
<%= image_tag "tailwind/illustration/woman-looking-off.svg", class: "mt-6", alt: "Illustration of a woman looking off into the distance" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/_tailwind/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<% unless resource.comments.visible.empty? %>
<p class="mt-8 text-2xl text-navy">
Note that the
<%= link_to pluralize(resource.comments.visible.count, "comment"), comments_profile_path, class: "text-orange underline" %>
<%= pa_link_to pluralize(resource.comments.visible.count, "comment"), comments_profile_path %>
you have made (including the name attached to the comment) will not be removed
as it is part of the public record. However the private information, your email address, will be removed.
</p>
Expand Down
18 changes: 9 additions & 9 deletions app/views/_tailwind/profiles/_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<ul class="ml-5 text-xl font-semibold text-orange list-image-dash">
<li><%= link_to "Your alerts", profile_alerts_path, class: class_names("block", "pl-4", "underline" => current_page?(profile_alerts_path)) %></li>
<li><%= link_to "Create new alert", new_profile_alert_path, class: class_names("block", "pl-4", "underline" => current_page?(new_profile_alert_path)) %></li>
<li><%= link_to "Your comments", comments_profile_path, class: class_names("block", "pl-4", "underline" => current_page?(comments_profile_path)) %></li>
<li><%= link_to "Edit account", edit_user_registration_path, class: class_names("block", "pl-4", "underline" => current_page?(edit_user_registration_path)) %></li>
<ul class="ml-5 text-xl font-bold text-navy list-image-dash">
<li><div class="pl-4"><%= pa_link_to_unless_current "Your alerts", profile_alerts_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Create new alert", new_profile_alert_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Your comments", comments_profile_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Edit account", edit_user_registration_path %></div></li>
<%# Setting "Sign out" to a block breaks on ios/safari %>
<li><%= button_to "Sign out", destroy_user_session_path, method: :delete, class: "cursor-pointer pl-4" %></li>
<li><div class="pl-4"><%= button_to "Sign out", destroy_user_session_path, method: :delete, class: "text-fuchsia hover:underline font-bold cursor-pointer" %></div></li>
</ul>

<% if current_user.admin? %>
<ul class="mt-10 ml-5 text-xl font-semibold text-orange list-image-dash">
<li><%= link_to "Administration panel", admin_root_path, class: "block pl-4" %></li>
<li><%= link_to "Feature flags", admin_flipper_path, class: "block pl-4" %></li>
<ul class="mt-10 ml-5 text-xl list-image-dash">
<li><div class="pl-4"><%= pa_link_to_unless_current "Administration panel", admin_root_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Feature flags", admin_flipper_path %></div></li>
</ul>
<% end %>

0 comments on commit ac24f28

Please sign in to comment.