Skip to content

Commit ad7c461

Browse files
committed
Redesign toggle button as vertical pill, remove icono dependency
- Replace icono-caret icons with slim vertical pill button (12x48px) - Chevron direction handled purely by CSS based on sidebar state - Simplify JS by removing icon class management - Remove active_admin_sidebar_pure_icons.scss (no longer needed)
1 parent fd8f8f9 commit ad7c461

3 files changed

Lines changed: 42 additions & 109 deletions

File tree

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
(function() {
22
$(document).ready(function() {
3-
var $aa_content, set_collapsed_sidebar, isLeftSidebar, collapseIcon, expandIcon;
43
if ($('body').hasClass('index') && ($('#active_admin_content').hasClass('collapsible_sidebar'))) {
5-
$aa_content = $('#active_admin_content');
6-
isLeftSidebar = $aa_content.hasClass('left_sidebar');
7-
var isCollapsed = $aa_content.hasClass('collapsed_sidebar');
8-
9-
if (isLeftSidebar) {
10-
collapseIcon = 'icono-caret-left';
11-
expandIcon = 'icono-caret-right';
12-
} else {
13-
collapseIcon = 'icono-caret-right';
14-
expandIcon = 'icono-caret-left';
15-
}
16-
17-
var initialIcon = isCollapsed ? expandIcon : collapseIcon;
18-
var $toggleBtn = $('<span class="sidebar_toggle_btn ' + initialIcon + '" title="Toggle sidebar"></span>');
19-
20-
// Place button inside #sidebar but outside .sidebar_section
21-
// so it stays visible when sections are hidden
4+
var $aa_content = $('#active_admin_content');
225
var $sidebar = $aa_content.find('#sidebar');
6+
7+
var $toggleBtn = $('<span class="sidebar_toggle_btn" title="Toggle sidebar"><span class="chevron"></span></span>');
238
$sidebar.prepend($toggleBtn);
249

25-
set_collapsed_sidebar = function(value) {
10+
var set_collapsed_sidebar = function(value) {
2611
return $.getJSON(this.href, {
2712
collapsed_sidebar: value
2813
});
@@ -32,16 +17,13 @@
3217
if (!$aa_content.hasClass('collapsed_sidebar')) {
3318
set_collapsed_sidebar(true);
3419
$aa_content.addClass('collapsed_sidebar');
35-
$toggleBtn.removeClass(collapseIcon).addClass(expandIcon);
3620
$aa_content.trigger('collapsible_sidebar:collapsed');
3721
} else {
3822
set_collapsed_sidebar(false);
3923
$aa_content.removeClass('collapsed_sidebar');
40-
$toggleBtn.removeClass(expandIcon).addClass(collapseIcon);
4124
$aa_content.trigger('collapsible_sidebar:uncollapsed');
4225
}
4326
});
4427
}
4528
});
46-
4729
}).call(this);

app/assets/stylesheets/active_admin_sidebar.scss

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
@import "active_admin_sidebar_pure_icons";
2-
3-
$toggle-btn-size: 19px;
1+
$toggle-btn-width: 12px;
2+
$toggle-btn-height: 48px;
43

54
// === Left sidebar layout ===
65
// Moves sidebar before main content in the DOM, so we need to
@@ -55,24 +54,50 @@ body.active_admin #active_admin_content.collapsible_sidebar {
5554
}
5655

5756
.sidebar_toggle_btn {
57+
width: $toggle-btn-width;
58+
height: $toggle-btn-height;
5859
background-color: #767270;
5960
border-radius: 3px;
60-
color: #ffffff;
6161
cursor: pointer;
6262
z-index: 10;
63-
// Override icono's position: relative so absolute works
64-
position: absolute !important;
65-
top: 5px;
63+
position: absolute;
64+
top: 12px;
65+
display: flex;
66+
align-items: center;
67+
justify-content: center;
68+
69+
&:hover {
70+
background-color: #5a5857;
71+
}
72+
73+
.chevron {
74+
width: 0;
75+
height: 0;
76+
border-top: 4px solid transparent;
77+
border-bottom: 4px solid transparent;
78+
}
6679
}
6780

68-
// Left sidebar: button flush on the right edge of sidebar
81+
// Left sidebar expanded: button on right edge, chevron points left (collapse)
6982
&.left_sidebar .sidebar_toggle_btn {
70-
right: -$toggle-btn-size;
83+
right: -$toggle-btn-width;
84+
.chevron { border-right: 5px solid #fff; border-left: none; }
7185
}
7286

73-
// Right sidebar: button flush on the left edge of sidebar
87+
// Left sidebar collapsed: chevron points right (expand)
88+
&.left_sidebar.collapsed_sidebar .sidebar_toggle_btn {
89+
.chevron { border-left: 5px solid #fff; border-right: none; }
90+
}
91+
92+
// Right sidebar expanded: button on left edge, chevron points right (collapse)
7493
&:not(.left_sidebar) .sidebar_toggle_btn {
75-
left: -$toggle-btn-size;
94+
left: -$toggle-btn-width;
95+
.chevron { border-left: 5px solid #fff; border-right: none; }
96+
}
97+
98+
// Right sidebar collapsed: chevron points left (expand)
99+
&:not(.left_sidebar).collapsed_sidebar .sidebar_toggle_btn {
100+
.chevron { border-right: 5px solid #fff; border-left: none; }
76101
}
77102
}
78103

@@ -87,12 +112,8 @@ body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar.le
87112
}
88113
}
89114

90-
.sidebar_toggle_btn {
91-
right: -$toggle-btn-size;
92-
}
93-
94115
#main_content_wrapper {
95-
margin-left: $toggle-btn-size + 8px;
116+
margin-left: $toggle-btn-width + 8px;
96117
}
97118
}
98119

@@ -108,12 +129,8 @@ body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar:no
108129
}
109130
}
110131

111-
.sidebar_toggle_btn {
112-
left: -$toggle-btn-size;
113-
}
114-
115132
#main_content_wrapper #main_content {
116-
margin-right: $toggle-btn-size + 8px;
133+
margin-right: $toggle-btn-width + 8px;
117134
}
118135
}
119136

app/assets/stylesheets/active_admin_sidebar_pure_icons.scss

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)