Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Implement automatic DOM IDs and CSS classes for sections/blocks/links (#12538)
Damian Legawiecbf164fc847e6
diff --git a/storefront/app/helpers/spree/page_helper.rb b/storefront/app/helpers/spree/page_helper.rbindex 39d3d5cd02..ff026255f3 100644--- a/storefront/app/helpers/spree/page_helper.rb+++ b/storefront/app/helpers/spree/page_helper.rb@@ -17,11 +17,14 @@ module Spreevariables[:section] = sectionvariables[:loaded] = true+ css_id = "section-#{section.id}"+ css_class = "section-#{section.class.name.demodulize.underscore.dasherize}"+if page_builder_enabled?- turbo_frame_tag("section-#{section.id}") do+ turbo_frame_tag(css_id, class: css_class) docontent_tag(:div,data: {- editor_id: "section-#{section.id}",+ editor_id: css_id,editor_name: section.name,editor_link: spree.edit_admin_page_section_path(section)}@@ -35,11 +38,13 @@ module Spreepath = section.lazy_path(variables)- turbo_frame_tag("section-#{section.id}", src: path, loading: 'eager') do+ turbo_frame_tag(css_id, src: path, loading: 'eager', class: css_class) dorender('/' + section.to_partial_path, **variables)endelse- render('/' + section.to_partial_path, **variables)+ content_tag(:div, id: css_id, class: css_class) do+ render('/' + section.to_partial_path, **variables)+ endendrescue ActionView::MissingTemplate, ActionView::Template::Error => eraise e unless Rails.env.production?diff --git a/storefront/app/helpers/spree/theme_helper.rb b/storefront/app/helpers/spree/theme_helper.rbindex 0b6c2a53f1..1de489bfd2 100644--- a/storefront/app/helpers/spree/theme_helper.rb+++ b/storefront/app/helpers/spree/theme_helper.rb@@ -138,6 +138,8 @@ module Spreeeditor_parent_id: "section-#{block.section_id}",editor_link: spree.respond_to?(:edit_admin_page_section_block_path) ? spree.edit_admin_page_section_block_path(block.section, block) : nil},+ id: "block-#{block.id}",+ class: "block-#{block.class.name.demodulize.underscore.dasherize}",style: block_styles(block, allowed_styles: allowed_styles),width_desktop: has_width_desktop}.compact_blank@@ -167,7 +169,9 @@ module Spreewhen :blockspree.edit_admin_page_link_path(link, block_id: link.parent_id)end- }+ },+ id: "link-#{link.id}",+ class: "link-#{link.class.name.demodulize.underscore.dasherize}"}else{}