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
Add promo section and CSS for edge-to-edge hero.
Matthew Kennedy32dd4ca88de1
diff --git a/backend/app/views/spree/admin/cms_pages/sections/_promo.html.erb b/backend/app/views/spree/admin/cms_pages/sections/_promo.html.erbnew file mode 100644index 0000000000..6d01b42d9d--- /dev/null+++ b/backend/app/views/spree/admin/cms_pages/sections/_promo.html.erb@@ -0,0 +1,22 @@+<div class="<%= width %>" data-section-id="<%= section.id %>">+ <div class="row m-0 p-0 py-3 mb-3 border bg-white">+ <div class="col" style="width:30px; max-width: 70px; text-align: center;">+ <span class="move-handle"><%= svg_icon(name: 'sort.svg', width: '20', height: '20') %></span>+ </div>+ <div class="col text-center">+ <div>Name: <%= section.name %></div>+ <div>Type: <%= section.kind %></div>+ <div class="m-auto" style="width:50px;">+ <% if section.icon.present? %>+ <div class="cms_section_preview_image_holder">+ <%= image_tag main_app.url_for(section.icon.attachment) %>+ </div>+ <% end %>+ </div>+ </div>+ <div class="col actions" style="width:30px; max-width: 70px; text-align: center;">+ <%= link_to_edit(section, no_text: true, url: spree.edit_admin_cms_page_cms_section_path(@cms_page, section)) %>+ <%= link_to_delete(section, no_text: true, url: spree.admin_cms_page_cms_section_path(@cms_page, section)) if can?(:destroy, section) %>+ </div>+ </div>+</div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_promo.html.erb b/backend/app/views/spree/admin/cms_sections/types/_promo.html.erbnew file mode 100644index 0000000000..1f83985ed3--- /dev/null+++ b/backend/app/views/spree/admin/cms_sections/types/_promo.html.erb@@ -0,0 +1,53 @@+<%= f.field_container :title, class: ['form-group'] do %>+ <%= f.label :title, Spree.t(:title) %>+ <%= f.text_field :title, class: 'form-control' %>+ <%= f.error_message_on :title %>+<% end %>++<%= f.field_container :subtitle, class: ['form-group'] do %>+ <%= f.label :subtitle, Spree.t(:subtitle) %>+ <%= f.text_field :subtitle, class: 'form-control' %>+ <%= f.error_message_on :subtitle %>+<% end %>++<% @cms_section.build_icon unless @cms_section.icon %>+ <%= f.fields_for :icon do |icon_field| %>+ <%= f.field_container :icon_attachment do %>+ <% unless @cms_section.icon.new_record? %>+ <div id="menuItemImgContainer" class="my-3 ">+ <%= image_tag(main_app.url_for(@cms_section.icon.attachment)) %>+ <%#= link_to Spree.t(:remove_image), remove_icon_admin_menu_menu_item_path(@cms_page, @cms_section), method: :delete %>+ </div>+ <% end %>+ <div id="<% unless @cms_section.icon.new_record? %>MenuItemImageButton<% end %>">+ <%= icon_field.file_field :attachment %>+ </div>+ <% end %>++ <%= f.field_container :icon_alt do %>+ <% unless @cms_section.icon.new_record? %>+ <div class="form-group my-3">+ <%= icon_field.label :alt, Spree.t('admin.navigation.image_alt_text') %>+ <%= icon_field.text_field :alt, class: 'form-control' %>+ </div>+ <% end %>+ <% end %>+<% end %>++<%= f.field_container :linked_resource_type, class: ['form-group'] do %>+ <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>+ <%= f.select(:linked_resource_type, @cms_section_links_to, {include_blank: false}) %>+ <%= f.error_message_on :linked_resource_type %>+<% end %>++<%= render 'link_inputx', linked_resource_type: @cms_section.linked_resource_type, f: f %>++<div id="alertToClickUpdate" class="d-none">+ <div class="alert alert-warning mt-3">+ <% if %w[new create].include? controller.action_name %>+ <%= raw Spree.t('admin.navigation.click_create_to_load_new_link') %>+ <% else %>+ <%= raw Spree.t('admin.navigation.click_update_to_load_new_link') %>+ <% end %>+ </div>+</div>diff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex 9895d57df1..b939db6cb9 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -11,7 +11,7 @@ module Spreeaccepts_nested_attributes_for :icon, reject_if: :all_blankSECTION_WIDTHS = ['Full', 'Half']- SECTION_TYPES = ['Text Block', 'Hero']+ SECTION_TYPES = ['Text Block', 'Hero', 'Promo']SECTION_LINKS_TO = ['None', 'Spree::Taxon', 'Spree::Product']enddiff --git a/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss b/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scssindex 3b596c4ab9..c1562d626a 100644--- a/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss+++ b/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss@@ -291,3 +291,13 @@}}}+++.full-width {+ width: 100vw;+ position: relative;+ left: 50%;+ right: 50%;+ margin-left: -50vw;+ margin-right: -50vw;+}diff --git a/frontend/app/views/spree/cms_pages/sections/_hero.html.erb b/frontend/app/views/spree/cms_pages/sections/_hero.html.erbindex 14372075a5..e11592c566 100644--- a/frontend/app/views/spree/cms_pages/sections/_hero.html.erb+++ b/frontend/app/views/spree/cms_pages/sections/_hero.html.erb@@ -1,14 +1,18 @@-<div class="homepage-hero-image mb-3 position-relative">- <% if section.icon.present? %>- <%= image_tag main_app.url_for(section.icon.attachment) %>- <% end %>+<div class="col-12">+ <div class="full-width">+ <div class="homepage-hero-image mb-3 position-relative p-0">+ <% if section.icon.present? %>+ <%= image_tag main_app.url_for(section.icon.attachment) %>+ <% end %>- <div class="hero-content">- <div class="homepage-hero-image-text mb-2 mx-auto pb-3 pb-md-4">- <%= section.title %>- </div>- <div>- <%= link_to section.subtitle, spree.products_path, class: 'btn btn-primary spree-btn px-5' %>+ <div class="hero-content">+ <div class="homepage-hero-image-text mb-2 mx-auto pb-3 pb-md-4">+ <%= section.title %>+ </div>+ <div>+ <%= link_to section.subtitle, spree.products_path, class: 'btn btn-primary spree-btn px-5' %>+ </div>+ </div></div></div></div>diff --git a/frontend/app/views/spree/cms_pages/sections/_promo.html.erb b/frontend/app/views/spree/cms_pages/sections/_promo.html.erbnew file mode 100644index 0000000000..b4cbd9c114--- /dev/null+++ b/frontend/app/views/spree/cms_pages/sections/_promo.html.erb@@ -0,0 +1,18 @@+<div class="<%= width %>">+ <%= link_to spree.nested_taxons_path('streetstyle') do %>+ <div class="homepage-bottom-box text-center mb-3">+ <% if section.icon.present? %>+ <%= image_tag main_app.url_for(section.icon.attachment) %>+ <% end %>++ <div class="homepage-bottom-box-inner" role="img" aria-label="New Collection">+ <div class="homepage-bottom-box-inner-small-text">+ New Collection+ </div>+ <div class="homepage-bottom-box-inner-big-text">+ Streetstyle+ </div>+ </div>+ </div>+ <% end %>+</div>diff --git a/frontend/app/views/spree/cms_pages/sections/_text_block.html.erb b/frontend/app/views/spree/cms_pages/sections/_text_block.html.erbindex a414f1cb53..bc0fa3b123 100644--- a/frontend/app/views/spree/cms_pages/sections/_text_block.html.erb+++ b/frontend/app/views/spree/cms_pages/sections/_text_block.html.erb@@ -1 +1,3 @@-<%= raw section.content %>+<div class="<%= width %>">+ <%= raw section.content %>+</div>diff --git a/frontend/app/views/spree/cms_pages/show.html.erb b/frontend/app/views/spree/cms_pages/show.html.erbindex 1f1982dac0..5a999b9939 100644--- a/frontend/app/views/spree/cms_pages/show.html.erb+++ b/frontend/app/views/spree/cms_pages/show.html.erb@@ -7,7 +7,11 @@</div></div><% else %>- <% @cms_page.cms_sections.each do |section| %>- <%= build_section(section) %>- <% end %>+<div class="container">+ <div class="row">+ <% @cms_page.cms_sections.each do |section| %>+ <%= build_section(section) %>+ <% end %>+ </div>+ </div><% end %>