Skip to content

Commit

Permalink
Merge pull request #15180 from opf/fix/border-box-helper
Browse files Browse the repository at this point in the history
Introduce helper for border box that sets the correct position class
  • Loading branch information
HDinger committed Apr 8, 2024
2 parents 651e794 + 29a6c2e commit 2e83a45
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/components/op_primer/component_helpers.rb
Expand Up @@ -44,11 +44,15 @@ def component_collection(**, &)
render(OpPrimer::ComponentCollectionComponent.new(**), &)
end

def border_box_container(**system_args, &)
Primer::Beta::BorderBox.new(position: :relative, **system_args, &)
end

def border_box_row(wrapper_arguments, &)
if container
container.with_row(**wrapper_arguments, &)
else
container = Primer::Beta::BorderBox.new
container = border_box_container
row = container.registered_slots[:rows][:renderable_function]
.bind_call(container, **wrapper_arguments)

Expand Down
@@ -1,6 +1,6 @@
<%=
component_wrapper do
render(Primer::Beta::BorderBox.new(mt: 3, classes: 'op-project-custom-field-section', data: {
render(border_box_container(mt: 3, classes: 'op-project-custom-field-section', data: {
test_selector: "project-custom-field-section-#{@project_custom_field_section.id}"
})) do |component|
component.with_header(font_weight: :bold, py: 2) do
Expand Down
@@ -1,6 +1,6 @@
<%=
component_wrapper(class: "op-project-custom-field-section-container", data: { test_selector: "project-custom-field-section-container-#{@project_custom_field_section.id}" }) do
render(Primer::Beta::BorderBox.new(mt: 3, data: drag_and_drop_target_config)) do |component|
render(border_box_container(mt: 3, data: drag_and_drop_target_config)) do |component|
component.with_header(font_weight: :bold) do
flex_layout(justify_content: :space_between, align_items: :center) do |section_header_container|
section_header_container.with_column(flex_layout: true, align_items: :center) do |content_container|
Expand Down
Expand Up @@ -9,7 +9,7 @@
data: { 'test-selector': 'op-share-wp-active-list',
controller: 'work-packages--share--bulk-selection',
application_target: 'dynamic' }) do
render(Primer::Beta::BorderBox.new(list_id: insert_target_modifier_id)) do |border_box|
render(border_box_container(list_id: insert_target_modifier_id)) do |border_box|
border_box.with_header(color: :muted, data: { 'test-selector': 'op-share-wp-header' }) do
grid_layout('op-share-wp-modal-body--header', tag: :div, align_items: :center) do |header_grid|
header_grid.with_area(:counter, tag: :div) do
Expand Down
Expand Up @@ -2,7 +2,7 @@
component_wrapper(data: wrapper_data_attributes) do
# The borderBox needs to be `position: relative` because of bug #49853
# (The action menu items float somewhere on the page as soon as you have to scroll the Box in Firefox)
render(Primer::Beta::BorderBox.new(position: :relative)) do |border_box|
render(border_box_container) do |border_box|
if @meeting.agenda_items.empty? && @form_hidden
border_box.with_body(
scheme: :default
Expand Down
@@ -1,5 +1,5 @@
<%=
render(Primer::Beta::BorderBox.new(padding: :condensed,
render(border_box_container(padding: :condensed,
test_selector: "op-meeting-container-#{@meeting.id}")) do |border_box|
border_box.with_header do
flex_layout do |flex|
Expand Down
@@ -1,6 +1,6 @@
<%=
if storages.present?
render(Primer::Beta::BorderBox.new) do |component|
render(border_box_container) do |component|
component.with_header(color: :muted) do
grid_layout('op-storage-list--header', tag: :div, align_items: :center) do |grid|
grid.with_area(:name, tag: :div, mr: 3) do
Expand Down
@@ -1,5 +1,5 @@
<%=
render(Primer::Beta::BorderBox.new) do |component|
render(border_box_container) do |component|
component.with_header(color: :muted) do
render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t('storages.file_storage_view.general_information') }
end
Expand Down

0 comments on commit 2e83a45

Please sign in to comment.