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 full screen mode to section editor.

Matthew Kennedy14ac88ebfbba
diff --git a/backend/app/assets/javascripts/spree/backend/cms/live_preview.es6 b/backend/app/assets/javascripts/spree/backend/cms/live_preview.es6
index 8d9acccd72..26009eb4b6 100644
--- a/backend/app/assets/javascripts/spree/backend/cms/live_preview.es6
+++ b/backend/app/assets/javascripts/spree/backend/cms/live_preview.es6
@@ -1,14 +1,24 @@
document.addEventListener('DOMContentLoaded', function() {
- document.getElementById('LiveViewSwitcher').addEventListener('click', function (event) {
+ document.getElementById('LiveViewSwitcher').addEventListener('click', function(event) {
if (event.target && event.target.matches("input[type='radio']")) {
switchLiveViewClass(event.target.id)
}
})
- function switchLiveViewClass (value) {
+ function switchLiveViewClass(value) {
const liveViewCont = document.getElementById('liveViewCont')
liveViewCont.classList = ''
liveViewCont.classList.add(value)
}
+
+ const cmsSectionEditorFullScreen = document.getElementById('cmsSectionEditorFullScreen')
+
+ cmsSectionEditorFullScreen.addEventListener('click', function(event) {
+ if (event.target.getAttribute('aria-pressed') === 'true') {
+ document.body.classList.remove('cmsSectionFullScreenMode')
+ } else {
+ document.body.classList.add('cmsSectionFullScreenMode')
+ }
+ })
})
diff --git a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss
index 7ed0df8d0c..d6e747c2bf 100644
--- a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss
+++ b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss
@@ -1,4 +1,16 @@
#cmsPagesectionsArea {
+ overflow-x: hidden;
+ overflow-y: scroll;
+ max-height: 553px;
+ padding-top: 5px !important;
+ -ms-overflow-style: none; /* IE and Edge */
+ scrollbar-width: none; /* Firefox */
+
+ &::-webkit-scrollbar {
+ display: none;
+ }
+
+
.col-xl, .col-xl-auto, .col-xl-12,
.col-xl-11, .col-xl-10, .col-xl-9,
.col-xl-8, .col-xl-7, .col-xl-6,
@@ -51,6 +63,29 @@
}
}
+body.cmsSectionFullScreenMode {
+ .hide-on-full-screen-mode {
+ display: none;
+ }
+ #pageSectionsArea {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 9999;
+ background: white;
+ padding: 15px 15px 0 15px;
+ height: 100vh;
+
+ #cmsPagesectionsArea {
+ max-height: 90vh;
+ }
+
+ .embed-responsive-4by3 {
+ height: 90vh;
+ }
+ }
+ }
+
#pageLivePreview {
transform-origin: top left;
}
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 123172ff9e..f38d7c4fc5 100644
--- a/backend/app/views/spree/admin/cms_pages/edit.html.erb
+++ b/backend/app/views/spree/admin/cms_pages/edit.html.erb
@@ -13,6 +13,8 @@
<% if @cms_page.sections? %>
<div id="pageSectionsArea" class="col-12">
+
+ <hr class="mt-5 hide-on-full-screen-mode">
<div class="row">
<div class="col d-flex justify-content-start">
<%= button_link_to Spree.t('admin.pages.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' %>
@@ -29,10 +31,14 @@
<input type="radio" name="options" id="desktopLiveView" autocomplete="off" checked> Desktop
</label>
</div>
+
+ <div class="ml-2">
+ <button id="cmsSectionEditorFullScreen" type="button" class="btn btn-outline-primary" data-toggle="button" autocomplete="off">Full Screen Mode</button>
+ </div>
</div>
</div>
<div class="row no-gutters">
- <div class="col-12 col-md-4 bg-light border">
+ <div class="col-12 col-md-4 bg-light border border-right-0">
<% if @cms_page.cms_sections.any? %>
<div id="cmsPagesectionsArea" class="card-body row m-0 p-0 no-gutters">
<% @cms_page.cms_sections.each do |section| %>
diff --git a/core/app/models/spree/cms/sections/hero.rb b/core/app/models/spree/cms/sections/hero.rb
index 53f4f7ed13..501f8cf6b1 100644
--- a/core/app/models/spree/cms/sections/hero.rb
+++ b/core/app/models/spree/cms/sections/hero.rb
@@ -1,5 +1,7 @@
module Spree::Cms::Sections
class Hero < Spree::CmsSection
+ after_initialize :default_values
+
has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::Icon'
accepts_nested_attributes_for :icon, reject_if: :all_blank
@@ -8,7 +10,13 @@ module Spree::Cms::Sections
end
def widths
- ['Edge-to-Edge', 'Full', 'Half']
+ ['Edge-to-Edge', 'Full']
+ end
+
+ private
+
+ def default_values
+ self.width ||= 'Edge-to-Edge'
end
end
end
diff --git a/core/app/models/spree/cms/sections/promo.rb b/core/app/models/spree/cms/sections/promo.rb
index bc88bef5c7..28184232f9 100644
--- a/core/app/models/spree/cms/sections/promo.rb
+++ b/core/app/models/spree/cms/sections/promo.rb
@@ -1,5 +1,8 @@
module Spree::Cms::Sections
class Promo < Spree::CmsSection
+ has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::Icon'
+ accepts_nested_attributes_for :icon, reject_if: :all_blank
+
def links_to
['Spree::Taxon', 'Spree::Product']
end