Extract helper with fallback for the "go to back" and use consistently

This commit is contained in:
Jorge Manrubia
2025-04-07 11:14:50 +02:00
parent 598d933565
commit a7aae833d1
8 changed files with 16 additions and 31 deletions
+6
View File
@@ -6,4 +6,10 @@ module NavigationHelper
icon_tag(icon) + tag.span(label, class: "for-screen-reader")
end
end
def link_to_back(fallback_path: root_path)
link_to "#", class: "btn flex-item-justify-start", data: { controller: "back-navigation hotkey", action: "keydown.esc@document->hotkey#click", back_navigation_fallback_destination_value: fallback_path } do
icon_tag("arrow-left") + tag.span("Go Back", class: "for-screen-reader")
end
end
end
+1 -5
View File
@@ -22,12 +22,8 @@
<nav class="align-start max-width">
<%= link_to_home %>
<%= link_to "#", class: "btn flex-item-justify-start", data: { controller: "back-navigation hotkey", action: "keydown.esc@document->hotkey#click", back_navigation_fallback_destination_value: bubbles_path(bucket_id: @bubble.bucket) } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Go Back</span>
<% end %>
<%= link_to_back fallback_path: bubbles_path(bucket_id: @bubble.bucket) %>
<div class="card__actions-container card__actions-container--top center border-radius flex-inline align-center justify-center gap" style="--bubble-color: <%= @bubble.color %>;">
<span>Considering</span>
<% if @bubble.doing? %>
+1 -4
View File
@@ -2,10 +2,7 @@
<% content_for :header do %>
<nav>
<%= link_to bubbles_path(bucket_ids: [ @bbucket ]), class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Go back</span>
<% end %>
<%= link_to_back fallback_path: bubbles_path(bucket_ids: [ @bbucket ]) %>
<%= form_with model: @bucket, class: "flex-item-justify-end", method: :delete do |form| %>
<%= form.button class: "btn btn--negative", data: { turbo_confirm: "Are you sure you want to delete this?" } do %>
@@ -2,10 +2,7 @@
<% content_for :header do %>
<nav class="align-start">
<%= link_to notifications_path, class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Go back</span>
<% end %>
<%= link_to_back fallback_path: notifications_path %>
<h1 class="txt-x-large"><%= @page_title %></h1>
+3 -6
View File
@@ -2,10 +2,7 @@
<% content_for :header do %>
<nav>
<%= link_to user_path(@user), class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Back</span>
<% end %>
<%= link_to_back fallback_path: user_path(@user) %>
</nav>
<% end %>
@@ -19,7 +16,7 @@
<label class="btn avatar input--file txt-xx-large center fill-white">
<%= image_tag user_avatar_path(@user), aria: { hidden: "true" }, class: "avatar", size: 128, data: { upload_preview_target: "image" } %>
<%= form.file_field :avatar, id: "file", class: "input", accept: "image/*",
data: { upload_preview_target: "input", action: "upload-preview#previewImage" } %>
data: { upload_preview_target: "input", action: "upload-preview#previewImage" } %>
<span class="for-screen-reader">Profile avatar for <%= @user.name %></span>
</label>
@@ -54,7 +51,7 @@
</div>
<button type="submit" id="log_in" class="btn btn--reversed center">
<%= icon_tag "check" %>
<span class="for-screen-reader">Sign in</span>
<span class="for-screen-reader">Sign in</span>
</button>
<%= link_to "Cancel and go back", user_path(@user), data: { form_target: "cancel", turbo_frame: "_top" }, hidden: true %>
+1 -4
View File
@@ -2,10 +2,7 @@
<% content_for :header do %>
<nav>
<%= link_to "javascript:window.history.back()", class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Back</span>
<% end %>
<%= link_to_back %>
<% if Current.user == @user %>
<%= link_to edit_user_path(@user), class: "btn flex-item-justify-end", data: { turbo_frame: dom_id(@user) } do %>
+2 -4
View File
@@ -2,10 +2,8 @@
<% content_for :header do %>
<nav>
<%= link_to account_users_path, class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Go back</span>
<% end %>
<%= link_to_back fallback_path: account_users_path %>
<span class="btn btn--placeholder"></span>
<h1 class="txt-large"><%= @page_title %></h1>
+1 -4
View File
@@ -2,10 +2,7 @@
<% content_for :header do %>
<nav>
<%= link_to workflows_path, class: "btn flex-item-justify-start", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<%= icon_tag "arrow-left" %>
<span class="for-screen-reader">Go back</span>
<% end %>
<%= link_to_back fallback_path: workflows_path %>
<h1 class="txt-large center"><%= @page_title %></h1>
<span class="btn btn--placeholder flex-item-justify-end"></span>
</nav>