Skip to content

Commit 20446d2

Browse files
authored
Merge pull request #19170 from opf/implementation/63889-move-toggle-button-to-the-sidebar
[63889] Move toggle button to the sidebar
2 parents a00b1ac + d3b9e40 commit 20446d2

File tree

46 files changed

+405
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+405
-273
lines changed

app/components/_index.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@import "open_project/common/attribute_help_text_component"
77
@import "open_project/common/attribute_label_component"
88
@import "open_project/common/submenu_component"
9+
@import "open_project/common/main_menu_toggle_component"
910
@import "projects/row_component"
1011
@import "projects/phases/hover_card_component"
1112
@import "shares/invite_user_form_component"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# frozen_string_literal: true
2+
3+
# -- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
# ++
30+
#
31+
module OpenProject
32+
module Common
33+
class MainMenuToggleComponent < ApplicationComponent
34+
def initialize(expanded:)
35+
super()
36+
37+
@expanded = expanded
38+
end
39+
40+
def call
41+
render(Primer::Beta::IconButton.new(icon:,
42+
id:,
43+
aria: { label: aria_label },
44+
scheme:,
45+
size:,
46+
data:))
47+
end
48+
49+
private
50+
51+
def icon
52+
@expanded ? "sidebar-expand" : :"sidebar-collapse"
53+
end
54+
55+
def id
56+
"menu-toggle--#{@expanded ? 'collapse-button' : 'expand-button'}"
57+
end
58+
59+
def aria_label
60+
@expanded ? I18n.t("js.label_hide_project_menu") : I18n.t("js.label_expand_project_menu")
61+
end
62+
63+
def scheme
64+
:invisible
65+
end
66+
67+
def size
68+
@expanded ? :medium : :small
69+
end
70+
71+
def data
72+
{
73+
action: "click->menus--main-toggle#toggleNavigation"
74+
}
75+
end
76+
end
77+
end
78+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//-- copyright
2+
// OpenProject is an open source project management software.
3+
// Copyright (C) the OpenProject GmbH
4+
//
5+
// This program is free software; you can redistribute it and/or
6+
// modify it under the terms of the GNU General Public License version 3.
7+
//
8+
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
9+
// Copyright (C) 2006-2013 Jean-Philippe Lang
10+
// Copyright (C) 2010-2013 the ChiliProject Team
11+
//
12+
// This program is free software; you can redistribute it and/or
13+
// modify it under the terms of the GNU General Public License
14+
// as published by the Free Software Foundation; either version 2
15+
// of the License, or (at your option) any later version.
16+
//
17+
// This program is distributed in the hope that it will be useful,
18+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
// GNU General Public License for more details.
21+
//
22+
// You should have received a copy of the GNU General Public License
23+
// along with this program; if not, write to the Free Software
24+
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25+
//
26+
// See COPYRIGHT and LICENSE files for more details.
27+
//++
28+
29+
#menu-toggle--expand-button
30+
position: absolute
31+
left: 11px
32+
z-index: 1
33+
34+
@at-root .nosidebar &
35+
display: none
36+
37+
#menu-toggle--collapse-button
38+
margin-right: 5px
39+
40+
.Button-visual
41+
color: var(--main-menu-font-color)
42+
43+
#wrapper
44+
.hidden-navigation
45+
// Push the breadcrumb to the right when the sidebar is collapsed
46+
.PageHeader-contextBar,
47+
.op-breadcrumbs
48+
margin-left: 30px
49+
50+
&:not(.hidden-navigation)
51+
#menu-toggle--expand-button
52+
display: none

app/components/open_project/common/submenu_component.sass

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
&--search
77
position: sticky
8-
// Header item + 10px padding + 77px project selector
9-
top: calc(var(--main-menu-item-height) + 10px + 77px)
8+
top: 0
109
z-index: 1
1110
background: var(--main-menu-bg-color)
1211
padding: 12px var(--main-menu-x-spacing)
@@ -52,10 +51,9 @@
5251
cursor: pointer
5352
width: 100%
5453

55-
5654
&:hover
57-
background: var(--main-menu-bg-hover-background)
58-
color: var(--main-menu-hover-font-color)
55+
background: var(--control-transparent-bgColor-hover)
56+
color: var(--main-menu-font-color)
5957
border-color: var(--main-menu-hover-border-color)
6058

6159
&--items
@@ -71,8 +69,8 @@
7169
padding: 8px 12px 8px 32px
7270

7371
&:hover
74-
background: var(--main-menu-bg-hover-background)
75-
color: var(--main-menu-hover-font-color)
72+
background: var(--control-transparent-bgColor-hover)
73+
color: var(--main-menu-font-color)
7674

7775
&_active
7876
background: var(--main-menu-bg-selected-background)

app/models/attribute_help_text.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class AttributeHelpText < ApplicationRecord
3030
acts_as_attachable viewable_by_all_users: true
3131

3232
def self.cached(user)
33-
OpenProject::Cache.fetch([name, user]) { visible(user).select(:id, :attribute_name).index_by(&:attribute_name) }
33+
RequestStore.fetch(name) do
34+
visible(user).select(:id, :attribute_name).index_by(&:attribute_name)
35+
end
3436
end
3537

3638
def self.for(model)

app/views/custom_styles/_inline_css.erb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ See COPYRIGHT and LICENSE files for more details.
5151
<% if design_color.variable == "main-menu-bg-selected-background" %>
5252
--main-menu-selected-font-color: <%= design_color.contrasting_font_color %>;
5353
<% end %>
54-
<% if design_color.variable == "main-menu-bg-hover-background" %>
55-
--main-menu-hover-font-color: <%= design_color.contrasting_font_color %>;
56-
<% end %>
5754
<% if design_color.variable == "primary-button-color" %>
5855
--primary-button-color--major1: <%= design_color.darken 0.18 %>;
5956
--primary-button-color--minor1: <%= design_color.lighten 0.8 %>;

app/views/custom_styles/_primer_color_mapping.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
--header-item-bg-hover-color: var(--control-transparent-bgColor-hover);
5353
--header-item-font-hover-color: var(--fgColor-default);
5454
--header-border-bottom-color: var(--borderColor-muted) !important;
55-
--main-menu-hover-font-color: var(--fgColor-default);
56-
--main-menu-bg-selected-background: var(--control-transparent-bgColor-hover);
57-
--main-menu-bg-hover-background: var(--control-transparent-bgColor-hover);
55+
--main-menu-bg-selected-background: var(--control-checked-borderColor-rest);
5856
--main-menu-border-color: var(--borderColor-muted);
5957
--main-menu-resizer-color: var(--borderColor-muted);
6058
--main-menu-fieldset-header-color: var(--fgColor-muted) !important;

app/views/layouts/base.html.erb

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ See COPYRIGHT and LICENSE files for more details.
3030
<html xmlns="http://www.w3.org/1999/xhtml"
3131
lang="<%= I18n.locale.to_s %>"
3232
xml:lang="<%= I18n.locale.to_s %>"
33-
class="<%= 'in_modal' unless show_decoration %>">
33+
class="<%= "in_modal" unless show_decoration %>">
3434
<head>
35-
<%= render partial: 'layouts/common_head' %>
35+
<%= render partial: "layouts/common_head" %>
3636
<!-- project specific tags -->
3737
<%= call_hook :view_layouts_base_html_head %>
3838
<!-- page specific tags -->
@@ -43,13 +43,13 @@ See COPYRIGHT and LICENSE files for more details.
4343
</head>
4444
<%= content_tag :body,
4545
class: "#{body_css_classes} __overflowing_element_container __overflowing_body",
46-
data: body_data_attributes(local_assigns) do %>
47-
<%= render partial: 'warning_bar/warning_bar' %>
46+
data: body_data_attributes(local_assigns) do %>
47+
<%= render partial: "warning_bar/warning_bar" %>
4848
<noscript>
4949
<div class="top-shelf">
5050
<p>
5151
<span>
52-
<%= op_icon 'icon3 icon-warning' %>
52+
<%= op_icon "icon3 icon-warning" %>
5353
<strong><%= t(:noscript_heading) %></strong>
5454
</span>
5555
<%= t(:noscript_description) %>
@@ -69,16 +69,15 @@ See COPYRIGHT and LICENSE files for more details.
6969
<% initial_classes = initial_menu_classes(side_displayed, show_decoration) %>
7070
<div id="wrapper" style="<%= initial_menu_styles(side_displayed) %>" class="<%= initial_classes %>">
7171
<% if show_decoration %>
72-
<header class="op-app-header<%= ' op-app-header_development' if OpenProject::Configuration.development_highlight_enabled? %>">
72+
<header class="op-app-header<%= " op-app-header_development" if OpenProject::Configuration.development_highlight_enabled? %>">
7373
<div class="op-app-header--start">
7474
<h1 class="hidden-for-sighted">
7575
<%= t(:label_top_menu) %>
7676
</h1>
77-
<opce-main-menu-toggle></opce-main-menu-toggle>
7877
<a href="" class="hidden-for-sighted skip-navigation-link"
7978
id="skip-navigation--content"
80-
aria-label="<%= I18n.t('js.work_packages.jump_marks.label_content') %>">
81-
<%= I18n.t('js.work_packages.jump_marks.content') %>
79+
aria-label="<%= I18n.t("js.work_packages.jump_marks.label_content") %>">
80+
<%= I18n.t("js.work_packages.jump_marks.content") %>
8281
</a>
8382
<%= render_top_menu_left %>
8483
</div>
@@ -92,23 +91,37 @@ See COPYRIGHT and LICENSE files for more details.
9291
</header>
9392
<% end %>
9493
<div id="main"
95-
class="<%= initial_classes %>">
94+
class="<%= initial_classes %>"
95+
data-controller="menus--main-toggle">
9696
<% if (side_displayed && show_decoration) %>
9797
<div
9898
id="main-menu"
9999
class="main-menu"
100-
data-controller="menus--main"
101-
>
100+
data-controller="menus--main">
102101
<h1 class="hidden-for-sighted"><%= t(:label_main_menu) %></h1>
103102
<opce-main-menu-resizer></opce-main-menu-resizer>
104103
<div id="menu-sidebar">
105-
<%= render_projects_top_menu_node %>
106-
<%= render(Primer::BaseComponent.new(tag: :hr,
107-
classes: "main-menu--projects-divider",
108-
role: :presentation,
109-
aria: {
110-
hidden: true
111-
})) %>
104+
<div class="main-menu--top-container">
105+
<%= render(Primer::OpenProject::FlexLayout.new(align_items: :center, pt: 3)) do |flex|
106+
flex.with_column(overflow: :hidden, ml: 2) do
107+
render_projects_top_menu_node
108+
end
109+
flex.with_column(text_align: :right, flex: :auto) do
110+
render(OpenProject::Common::MainMenuToggleComponent.new(expanded: true))
111+
end
112+
end %>
113+
114+
<%= render(
115+
Primer::BaseComponent.new(
116+
tag: :hr,
117+
classes: "main-menu--projects-divider",
118+
role: :presentation,
119+
aria: {
120+
hidden: true
121+
}
122+
)
123+
) %>
124+
</div>
112125
<%= main_menu %>
113126
<%= content_for :main_menu %>
114127
<%= call_hook :view_layouts_base_main_menu %>
@@ -130,11 +143,11 @@ See COPYRIGHT and LICENSE files for more details.
130143
<section data-augmented-model-wrapper
131144
data-modal-initialize-now="true"
132145
data-modal-class-name="onboarding-modal">
133-
<%= render partial: '/onboarding/configuration_modal' %>
146+
<%= render partial: "/onboarding/configuration_modal" %>
134147
</section>
135148
<% end %>
136149
<%= content_tag :div,
137-
id: 'content',
150+
id: "content",
138151
class: "#{initial_classes} #{'content--split' if content_for?(:content_body_right)}" do %>
139152
<h1 class="hidden-for-sighted accessibility-helper"><%= t(:label_content) %></h1>
140153
<% if content_for?(:content_header) %>
@@ -144,6 +157,7 @@ See COPYRIGHT and LICENSE files for more details.
144157
<% end %>
145158

146159
<div id="content-body">
160+
<%= render(OpenProject::Common::MainMenuToggleComponent.new(expanded: false)) %>
147161
<%= content_for :content_body %>
148162
<% unless local_assigns[:no_layout_yield] %>
149163
<%= yield %>

config/locales/en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ en:
7575
header-item-bg-hover-color: "Header background on hover"
7676
main-menu-bg-color: "Main menu background"
7777
main-menu-bg-selected-background: "Main menu when selected"
78-
main-menu-bg-hover-background: "Main menu on hover"
7978
custom_colors: "Custom colors"
8079
manage_colors: "Edit color select options"
8180
instructions:

config/locales/js-en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ en:
373373
label_added_time_by: 'Added by <a href="%{authorLink}">%{author}</a> at %{age}'
374374
label_ago: "days ago"
375375
label_all: "all"
376+
label_all_projects: "All projects"
376377
label_all_uppercase: "All"
377378
label_all_work_packages: "all work packages"
378379
label_and: "and"
@@ -482,7 +483,6 @@ en:
482483
label_repository_plural: "Repositories"
483484
label_save_as: "Save as"
484485
label_search_columns: "Search a column"
485-
label_select_project: "Select a project"
486486
label_select_watcher: "Select a watcher..."
487487
label_selected_filter_list: "Selected filters"
488488
label_show_attributes: "Show all attributes"

0 commit comments

Comments
 (0)