Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add an InsetBox component to OpPrimer

Jan Sandbrink4a8c8753f7f9
diff --git a/app/components/op_primer/inset_box.html.erb b/app/components/op_primer/inset_box.html.erb
new file mode 100644
index 00000000000..9c7bd227299
--- /dev/null
+++ b/app/components/op_primer/inset_box.html.erb
@@ -0,0 +1,42 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%=
+ render(
+ Primer::Box.new(
+ border:,
+ border_radius: 2,
+ bg: :inset,
+ p: 3,
+ **system_arguments
+ )
+ ) do
+ content
+ end
+%>
diff --git a/app/components/op_primer/inset_box.rb b/app/components/op_primer/inset_box.rb
new file mode 100644
index 00000000000..2a9c3d986f5
--- /dev/null
+++ b/app/components/op_primer/inset_box.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module OpPrimer
+ class InsetBox < Primer::Component
+ attr_reader :border, :system_arguments
+
+ def initialize(border: true, **system_arguments)
+ @border = border
+ @system_arguments = system_arguments
+ end
+ end
+end
diff --git a/app/components/projects/copy_form_component.html.erb b/app/components/projects/copy_form_component.html.erb
index 4011da0064b..25ce9b5cd60 100644
--- a/app/components/projects/copy_form_component.html.erb
+++ b/app/components/projects/copy_form_component.html.erb
@@ -32,7 +32,7 @@ See COPYRIGHT and LICENSE files for more details.
settings_primer_form_with(model: target_project, url: copy_project_path(source_project), method: :post) do |f|
flex_layout do |container|
container.with_row(mb: 3) do
- render(Primer::Box.new(border: true, border_radius: 2, bg: :inset, p: 3)) do
+ render(OpPrimer::InsetBox.new) do
render(Projects::CopyForm.new(f, copy_options:))
end
end
diff --git a/app/components/projects/new_component.html.erb b/app/components/projects/new_component.html.erb
index 43c99ab1d2a..0f791cc80f8 100644
--- a/app/components/projects/new_component.html.erb
+++ b/app/components/projects/new_component.html.erb
@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
flex_layout do |container|
if template
container.with_row(mb: 3) do
- render(Primer::Box.new(border: true, border_radius: 2, bg: :inset, p: 3)) do
+ render(OpPrimer::InsetBox.new) do
render(
Projects::TemplateForm.new(f, template:, copy_options:)
)
diff --git a/app/components/projects/source_project_select_component.html.erb b/app/components/projects/source_project_select_component.html.erb
index ae5644df8db..4eac9e0fe85 100644
--- a/app/components/projects/source_project_select_component.html.erb
+++ b/app/components/projects/source_project_select_component.html.erb
@@ -34,13 +34,7 @@ See COPYRIGHT and LICENSE files for more details.
method: :get
) do |f|
render(
- Primer::Box.new(
- border: true,
- border_radius: 2,
- bg: :inset,
- my: 3,
- p: 3
- )
+ OpPrimer::InsetBox.new(my: 3)
) do
source_project_id_value = source_project_id
render_inline_form(f) do |form|
diff --git a/app/components/projects/template_select_component.html.erb b/app/components/projects/template_select_component.html.erb
index 9e91a844827..0eb499e111d 100644
--- a/app/components/projects/template_select_component.html.erb
+++ b/app/components/projects/template_select_component.html.erb
@@ -39,13 +39,7 @@ See COPYRIGHT and LICENSE files for more details.
}
) do |f|
render(
- Primer::Box.new(
- border: true,
- border_radius: 2,
- bg: :inset,
- my: 3,
- p: 3
- )
+ OpPrimer::InsetBox.new(my: 3)
) do
template_id_value = template_id
parent_id_value = parent_id
diff --git a/app/components/shares/project_queries/public_flag_component.html.erb b/app/components/shares/project_queries/public_flag_component.html.erb
index 5b952aea94b..ff1b2c4929d 100644
--- a/app/components/shares/project_queries/public_flag_component.html.erb
+++ b/app/components/shares/project_queries/public_flag_component.html.erb
@@ -1,11 +1,7 @@
<%=
container.with_row do
render(
- Primer::Box.new(
- border: true,
- border_radius: BOX_BORDER_RADIUS,
- p: BOX_PADDING
- )
+ OpPrimer::InsetBox.new
) do
content_tag(:div, class: tooltip_wrapper_classes, data: { tooltip: tooltip_message }) do
render(
diff --git a/app/components/shares/project_queries/public_flag_component.rb b/app/components/shares/project_queries/public_flag_component.rb
index cfbd02dcc79..4976a94c6a2 100644
--- a/app/components/shares/project_queries/public_flag_component.rb
+++ b/app/components/shares/project_queries/public_flag_component.rb
@@ -31,8 +31,6 @@
module Shares
module ProjectQueries
class PublicFlagComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
- BOX_PADDING = 3
- BOX_BORDER_RADIUS = 2
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
index 91876bca162..aecb61a056b 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
@@ -1,6 +1,7 @@
<%=
component_wrapper do
- render(Primer::Box.new(pt: 3, pl: 3, pr: 3, classes: "outcome-container", border_radius: 2)) do
+ # TODO: validate paddings (InsetBox would probably overwrite "p" here, giving an unintended padding at the bottom)
+ render(OpPrimer::InsetBox.new(border: false, pt: 3, pl: 3, pr: 3, classes: "outcome-container")) do
grid_layout("op-meeting-outcome-notes", tag: :div, id: "outcome-#{@meeting_outcome.id}") do |grid|
grid.with_area(:title, tag: :span, classes: "title") do
render(Primer::Beta::Heading.new(tag: :h5)) { t(:label_agenda_outcome) }
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.sass b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.sass
index d93a8664427..819826b065a 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.sass
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.sass
@@ -1,8 +1,6 @@
@import 'helpers'
.outcome-container
- background-color: var(--bgColor-muted)
-
// To prevent flickering when changing meeting states due to the actions button icon
.title
min-height: 32px
diff --git a/modules/meeting/app/components/work_package_meetings_tab/meeting_agenda_item_component.html.erb b/modules/meeting/app/components/work_package_meetings_tab/meeting_agenda_item_component.html.erb
index b96e240e2ea..d0099403cda 100644
--- a/modules/meeting/app/components/work_package_meetings_tab/meeting_agenda_item_component.html.erb
+++ b/modules/meeting/app/components/work_package_meetings_tab/meeting_agenda_item_component.html.erb
@@ -13,7 +13,7 @@
if @meeting_agenda_item.outcomes.exists?
outcome = @meeting_agenda_item.outcomes.information_kind.last
flex.with_row do
- render(Primer::Box.new(mt: 2, p: 3, classes: "outcome-container", border_radius: 2)) do
+ render(OpPrimer::InsetBox.new(border: false, mt: 2, classes: "outcome-container")) do
concat render(Primer::Beta::Heading.new(tag: :h5)) { t(:label_agenda_outcome) }
concat render(Primer::Box.new(classes: "op-uc-container", pb: 0, mt: 1)) { format_text(outcome, :notes) }
end