Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "back" link to the navigation #1376

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/assets/stylesheets/administrate/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ input[type="submit"],
}
}
}

.button--alt {
background-color: transparent;
border: $base-border;
border-color: $blue;
color: $blue;
margin-bottom: $base-spacing;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ $_navigation-link-padding: 0.6em;

.navigation {
flex: 1 0 10rem;
padding-bottom: $base-spacing;
padding-right: calc(#{$base-spacing} - #{$_navigation-link-padding});
padding-top: $base-spacing;
padding: $base-spacing;
padding-left: 0;
}

.navigation__link {
Expand Down
2 changes: 2 additions & 0 deletions app/views/administrate/application/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ as defined by the routes in the `admin/` namespace
%>

<nav class="navigation" role="navigation">
<%= link_to "Back to app", root_url, class: "button button--alt" %>

<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
<%= link_to(
display_resource_name(resource),
Expand Down
7 changes: 7 additions & 0 deletions spec/features/navigation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "rails_helper"

describe "navigation" do
it "has the link of back to application" do
visit admin_customers_path

navigation = find(".navigation")
expect(navigation).to have_link("Back to app")
end

it "highlights the link to the current page's resource type" do
visit admin_customers_path

Expand Down