Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Add brands bar.

Matthew Kennedy5dc36c7afd8d
diff --git a/backend/app/views/spree/admin/cms_pages/edit.html.erb b/backend/app/views/spree/admin/cms_pages/edit.html.erb
index cda3df1ac1..fac0dfba28 100644
--- a/backend/app/views/spree/admin/cms_pages/edit.html.erb
+++ b/backend/app/views/spree/admin/cms_pages/edit.html.erb
@@ -19,7 +19,7 @@
<div class="col d-flex justify-content-start">
<%= button_link_to Spree.t('admin.cms.add_new_section'), spree.new_admin_cms_page_cms_section_path(@cms_page), icon: 'add.svg', class: 'no-wrap btn btn-success align-self-center' %>
</div>
- <div class="col d-flex justify-content-end">
+ <div class="col d-none d-md-flex justify-content-end">
<div id="LiveViewSwitcher" class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-outline-primary active">
<input type="radio" name="options" id="mobileLiveView" autocomplete="off"> Mobile
diff --git a/backend/app/views/spree/admin/cms_sections/types/_brands.html.erb b/backend/app/views/spree/admin/cms_sections/types/_brands.html.erb
new file mode 100644
index 0000000000..5bb3c6ceb6
--- /dev/null
+++ b/backend/app/views/spree/admin/cms_sections/types/_brands.html.erb
@@ -0,0 +1,15 @@
+<div class="row">
+ <div class="col-12 col-md-6">
+ <%= 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 %>
+ </div>
+</div>
diff --git a/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erb b/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erb
index d20035eb6f..2b4ce9d92d 100644
--- a/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erb
+++ b/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erb
@@ -14,7 +14,7 @@
<% end %>
<%= f.field_container :title, class: ['form-group'] do %>
- <%= f.label :title, Spree.t(:title) %>
+ <%= f.label :title, Spree.t('admin.cms.taxon_category.section_one') %>
<%= f.select :title,
options_from_collection_for_select([@cms_section],
:title, :title, @cms_section.title || nil),
@@ -43,7 +43,7 @@
<% end %>
<% end %>
<%= f.field_container :subtitle, class: ['form-group'] do %>
- <%= f.label :subtitle, Spree.t(:subtitle) %>
+ <%= f.label :subtitle, Spree.t('admin.cms.taxon_category.section_two') %>
<%= f.select :subtitle,
options_from_collection_for_select([@cms_section],
:subtitle, :subtitle, @cms_section.subtitle || nil),
@@ -72,7 +72,7 @@
<% end %>
<% end %>
<%= f.field_container :button_text, class: ['form-group'] do %>
- <%= f.label :button_text, Spree.t(:button_text) %>
+ <%= f.label :button_text, Spree.t('admin.cms.taxon_category.section_three') %>
<%= f.select :button_text,
options_from_collection_for_select([@cms_section],
:button_text, :button_text, @cms_section.button_text || nil),
diff --git a/backend/app/views/spree/admin/menus/_form.html.erb b/backend/app/views/spree/admin/menus/_form.html.erb
index 5f3ea5bfda..600a7b38d7 100644
--- a/backend/app/views/spree/admin/menus/_form.html.erb
+++ b/backend/app/views/spree/admin/menus/_form.html.erb
@@ -8,7 +8,7 @@
<%= f.field_container :location, class: ['form-group'] do %>
<%= f.label :location, Spree.t('location') %>
- <%= f.select(:location, spree_humanize_dropdown_values('Spree::Menu', { const: 'MENU_LOCATIONS'}), {include_blank: false}, class: 'select2') %>
+ <%= f.select(:location, spree_humanize_dropdown_values('Spree::Menu', { const: 'MENU_LOCATIONS', paramterize_values: true }), {include_blank: false}, class: 'select2') %>
<%= f.error_message_on :location %>
<% end %>
</div>
diff --git a/core/app/models/spree/cms/sections/brands.rb b/core/app/models/spree/cms/sections/brands.rb
new file mode 100644
index 0000000000..86911ddef3
--- /dev/null
+++ b/core/app/models/spree/cms/sections/brands.rb
@@ -0,0 +1,16 @@
+module Spree::Cms::Sections
+ class Brands < Spree::CmsSection
+ after_initialize :default_values
+
+ def widths
+ ['Full']
+ end
+
+ private
+
+ def default_values
+ self.width ||= 'Full'
+ self.boundary ||= 'Screen'
+ end
+ end
+end
diff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rb
index 7573199e70..ab7f3000bb 100644
--- a/core/app/models/spree/cms_section.rb
+++ b/core/app/models/spree/cms_section.rb
@@ -15,7 +15,8 @@ module Spree
'Spree::Cms::Sections::Promo',
'Spree::Cms::Sections::FeaturedArticle',
'Spree::Cms::Sections::Carousel',
- 'Spree::Cms::Sections::TaxonCategory']
+ 'Spree::Cms::Sections::TaxonCategory',
+ 'Spree::Cms::Sections::Brands']
# Overide this per section type
def boundaries
diff --git a/core/app/models/spree/menu.rb b/core/app/models/spree/menu.rb
index 4067818213..c481dd9e0c 100644
--- a/core/app/models/spree/menu.rb
+++ b/core/app/models/spree/menu.rb
@@ -1,6 +1,6 @@
module Spree
class Menu < Spree::Base
- MENU_LOCATIONS = ['Header', 'Footer']
+ MENU_LOCATIONS = ['Header', 'Footer', 'Brands']
MENU_LOCATIONS_PARAMETERIZED = []
MENU_LOCATIONS.each do |location|
diff --git a/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss b/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss
index 2a60c4f693..923b2f2f55 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
@@ -2,6 +2,13 @@
--spree-border-color: transparent;
}
+.brand {
+ img {
+ width: 85%;
+ max-width: 140px;
+ }
+}
+
.homepage {
&-hero-image {
display: flex;
diff --git a/frontend/app/controllers/spree/home_controller.rb b/frontend/app/controllers/spree/home_controller.rb
index c858a2ca9b..d6a7aef58d 100644
--- a/frontend/app/controllers/spree/home_controller.rb
+++ b/frontend/app/controllers/spree/home_controller.rb
@@ -29,8 +29,8 @@ module Spree
end
def last_modified_index
- page_last_modified = @cms_home_page.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)
- current_store_last_modified = current_store.updated_at.utc
+ page_last_modified = @cms_home_page&.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)
+ current_store_last_modified =current_store.updated_at.utc
[page_last_modified, current_store_last_modified].compact.max
end
diff --git a/frontend/app/views/spree/shared/cms/sections/_brands.html.erb b/frontend/app/views/spree/shared/cms/sections/_brands.html.erb
new file mode 100644
index 0000000000..21fa688cb2
--- /dev/null
+++ b/frontend/app/views/spree/shared/cms/sections/_brands.html.erb
@@ -0,0 +1,32 @@
+<div class="<%= width %> mb-3">
+ <div class="<%= boundary %>">
+ <div class="row py-4">
+ <% if section.title.present? || section.subtitle.present? %>
+ <div class="col-12 mb-3 text-center">
+ <% if section.title %>
+ <h3 class="mb-0"><%= section.title %></h3>
+ <% end %>
+ <% if section.subtitle %>
+ <h5 class="text-muted"><%= section.subtitle %></h5>
+ <% end %>
+ </div>
+
+ <% end %>
+ <% if spree_menu('brands').present? %>
+ <% spree_menu('brands').children.each do |brand| %>
+ <div class="col d-flex justify-content-center">
+ <%= spree_nav_link_tag(brand, { class: "brand d-flex align-middle justify-content-center" }) do %>
+ <% if brand.icon.present? %>
+ <img class="lazyload"
+ data-src="<%= main_app.url_for(brand.icon.attachment) %>"
+ data-srcset="<%= main_app.url_for(brand.icon.attachment) %>"
+ alt="<%= brand.icon.alt %>"
+ title="<%= brand.name %>">
+ <% end %>
+ <% end %>
+ </div>
+ <% end %>
+ <% end %>
+ </div>
+ </div>
+</div>
diff --git a/frontend/app/views/spree/shared/cms/sections/_hero.html.erb b/frontend/app/views/spree/shared/cms/sections/_hero.html.erb
index bc4efb542f..78c87a8379 100644
--- a/frontend/app/views/spree/shared/cms/sections/_hero.html.erb
+++ b/frontend/app/views/spree/shared/cms/sections/_hero.html.erb
@@ -37,7 +37,7 @@
<div class="hero-content align-self-center">
<% if section.title.present? %>
- <div class="homepage-hero-image-text mb-2 mx-auto pb-3 pb-md-4">
+ <div class="homepage-hero-image-text mx-auto pb-0 pb-sm-2 pb-md-3">
<%= section.title %>
</div>
<% end %>