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

Improve navbar #2310

Merged
merged 1 commit into from
Jun 24, 2015
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
30 changes: 23 additions & 7 deletions app/assets/stylesheets/rails_admin/base/theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Keep it clean, people
*/

$avatar-size: 30px;

body.rails_admin {

.thumbnail {
Expand All @@ -12,12 +14,18 @@ body.rails_admin {
/* room for upper navbar */
padding-top: $navbar-height;

/* Application name */
.navbar .brand {
small {
color:#9d261d;
font-weight:bold;
line-height: 1;
.navbar {
.edit_user_root_link {
position: relative;

img {
position: absolute;
top: ((40px - $avatar-size) / 2);

& + span {
margin-left: ($avatar-size + 5px);
}
}
}
}

Expand Down Expand Up @@ -284,8 +292,16 @@ body.rails_admin {
}
}

@media screen and (min-width: $screen-sm-min) {
@media screen and (min-width: $grid-float-breakpoint) {
body.rails_admin {
.navbar {
.edit_user_root_link {
img {
top: (($navbar-height - $avatar-size) / 2);
}
}
}

.sidebar-nav {
position: fixed;
top: $navbar-height;
Expand Down
7 changes: 6 additions & 1 deletion app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def edit_user_link
return nil unless _current_user.respond_to?(:email)
return nil unless abstract_model = RailsAdmin.config(_current_user.class).abstract_model
return nil unless (edit_action = RailsAdmin::Config::Actions.find(:edit, controller: controller, abstract_model: abstract_model, object: _current_user)).try(:authorized?)
link_to _current_user.email, url_for(action: edit_action.action_name, model_name: abstract_model.to_param, id: _current_user.id, controller: 'rails_admin/main')
link_to url_for(action: edit_action.action_name, model_name: abstract_model.to_param, id: _current_user.id, controller: 'rails_admin/main') do
html = []
html << image_tag("#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", alt: '') if _current_user.email.present?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tagliala What do you think about to add the 'img-rounded' (or the 'img-circle') class to the avatar image?

Take a look at http://getbootstrap.com/css/#images-shapes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not anymore a big fan of circled avatars because they cut out part of the user profile picture.

btw no problems for me if authors decide to go for img-circle, I will edit this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be nice to go for a more modern/consolidated user drop down. I'll try and find an example, but you've probably seen them before - the ones where you click the username/image and a drop down appears with a profile and logout link. It would solve the red "danger-label" as mentioned above and tidy up the top nav bar... Just a thought!

html << content_tag(:span, _current_user.email)
html.join.html_safe
end
end

def logout_path
Expand Down
7 changes: 6 additions & 1 deletion app/views/layouts/rails_admin/_navigation.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.container-fluid
.navbar-header
%button.navbar-toggle.collapsed{ type: 'button', data: { toggle: 'collapse', target: '#secondary-navigation' } }
%span.sr-only= t('admin.toggle_navigation')
%span.icon-bar
%span.icon-bar
%span.icon-bar
%a.navbar-brand.pjax{href: dashboard_path}
= _get_plugin_name[0] || 'Rails'
%small= _get_plugin_name[1] || 'Admin'
.collapse.navbar-collapse
.collapse.navbar-collapse#secondary-navigation
= render partial: 'layouts/rails_admin/secondary_navigation'
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
%li= link_to t('admin.home.name'), main_app_root_path
- if _current_user
- if user_link = edit_user_link
%li= user_link
%li.edit_user_root_link= user_link
- if logout_path.present?
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-danger'), logout_path, method: logout_method
- if _current_user.respond_to?(:email) && _current_user.email.present?
%li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", style: 'padding-top:5px'
1 change: 1 addition & 0 deletions config/locales/rails_admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ en:
starts_with: Starts with
ends_with: Ends with
loading: "Loading..."
toggle_navigation: Toggle navigation
home:
name: "Home"
pagination:
Expand Down