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
Improve Draft Mode toggle
Matthew Kennedy48d6ae4aceed
diff --git a/backend/app/assets/images/backend-eye-slash-fill.svg b/backend/app/assets/images/backend-eye-slash-fill.svgnew file mode 100644index 0000000000..9339262877--- /dev/null+++ b/backend/app/assets/images/backend-eye-slash-fill.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-slash-fill" viewBox="0 0 16 16">+ <path d="m10.79 12.912-1.614-1.615a3.5 3.5 0 0 1-4.474-4.474l-2.06-2.06C.938 6.278 0 8 0 8s3 5.5 8 5.5a7.029 7.029 0 0 0 2.79-.588zM5.21 3.088A7.028 7.028 0 0 1 8 2.5c5 0 8 5.5 8 5.5s-.939 1.721-2.641 3.238l-2.062-2.062a3.5 3.5 0 0 0-4.474-4.474L5.21 3.089z"/>+ <path d="M5.525 7.646a2.5 2.5 0 0 0 2.829 2.829l-2.83-2.829zm4.95.708-2.829-2.83a2.5 2.5 0 0 1 2.829 2.829zm3.171 6-12-12 .708-.708 12 12-.708.708z"/>+</svg>\ No newline at end of filediff --git a/backend/app/assets/javascripts/spree/backend/cms/page.es6 b/backend/app/assets/javascripts/spree/backend/cms/page.es6index a7d3f0c76c..c15224c1f2 100644--- a/backend/app/assets/javascripts/spree/backend/cms/page.es6+++ b/backend/app/assets/javascripts/spree/backend/cms/page.es6@@ -55,10 +55,13 @@ function handleTogglePageVisibility(obj) {function toggleVisibilityState(obj) {const statusHolder = document.getElementById('visibilityStatus')const pageHidden = statusHolder.querySelector('.page_hidden')+ const pageVisible = statusHolder.querySelector('.page_visible')if (obj.checked) {pageHidden.classList.add('d-none')+ pageVisible.classList.remove('d-none')} else {+ pageVisible.classList.add('d-none')pageHidden.classList.remove('d-none')}}diff --git a/backend/app/assets/stylesheets/spree/backend/global/_mixins.scss b/backend/app/assets/stylesheets/spree/backend/global/_mixins.scssindex 3426b86448..918260e952 100644--- a/backend/app/assets/stylesheets/spree/backend/global/_mixins.scss+++ b/backend/app/assets/stylesheets/spree/backend/global/_mixins.scss@@ -17,3 +17,58 @@#{$property}: $value;}}+++@mixin switch($res: 'sm') {+ $index: 1rem;+ $mainVal: 1rem;++ @if $res == 'md' {+ $index: 2rem;+ $mainVal: 1.5rem;+ min-height: $index;+ } @else if $res == 'lg' {+ $index: 3rem;+ $mainVal: 2rem;+ } @else if $res == 'xl' {+ $index: 4rem;+ $mainVal: 2.5rem;+ }++ .custom-control-label {+ padding-left: #{$index};+ padding-bottom: #{$mainVal};+ }++ .custom-control-label::before {+ height: $mainVal;+ width: calc(#{$index} + 0.75rem);+ border-radius: $mainVal * 2;+ }++ .custom-control-label::after {+ width: calc(#{$mainVal} - 4px);+ height: calc(#{$mainVal} - 4px);+ border-radius: calc(#{$index} - (#{$mainVal} / 2));+ }++ .custom-control-input:checked ~ .custom-control-label::after {+ transform: translateX(calc(#{$mainVal} - 0.25rem));+ }+}++.custom-switch.custom-switch-sm {+ @include switch();+}++.custom-switch.custom-switch-md {+ @include switch('md');+}++.custom-switch.custom-switch-lg {+ @include switch('lg');+}++.custom-switch.custom-switch-xl {+ @include switch('xl');+}diff --git a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss b/backend/app/assets/stylesheets/spree/backend/shared/_base.scssindex abc44df6f7..87d30cfbe3 100644--- a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss+++ b/backend/app/assets/stylesheets/spree/backend/shared/_base.scss@@ -16,7 +16,7 @@}figure.admin-img-holder {- max-width: 200px;+ max-width: 275px;border: 2px dashed grey;border-radius: $border-radius;overflow: hidden;diff --git a/backend/app/views/spree/admin/cms_pages/_form.html.erb b/backend/app/views/spree/admin/cms_pages/_form.html.erbindex 2879754474..7a6de98b0d 100644--- a/backend/app/views/spree/admin/cms_pages/_form.html.erb+++ b/backend/app/views/spree/admin/cms_pages/_form.html.erb@@ -2,25 +2,31 @@<div class="row sp-pb-0"><div class="col-12"><div class="card sp-card">+ <% unless %w[new create].include? controller.action_name %><div class="card-header col-12"><div class="row pb-0">- <div class="col d-flex justify-content-start">-- <%= f.field_container :visible, class: ['form-group pb-0 mb-0 mr-3'] do %>- <div class="custom-control custom-switch">+ <div class="col d-flex justify-content-start align-items-center">+ <%= f.field_container :visible, class: ['form-group pb-0 mb-0'] do %>+ <div class="custom-control custom-switch custom-switch-md"><%= f.check_box :visible, class: 'custom-control-input', data: {cms_page_id: @cms_page.id} %>- <%= f.label :visible, Spree.t('admin.cms.toggle_page_visibility'), class: 'custom-control-label' %>+ <label class="custom-control-label" for="cms_page_visible"></label><%= f.error_message_on :visible %></div><% end %>- </div>- <div class="d-flex mr-3">- <h5 id="visibilityStatus" class="pb-0 mb-0">- <span class="page_hidden text-danger <% if @cms_page.viewable? %>d-none<% end %>"><%= svg_icon name: "view.svg", width: '16', height: '16' %> Hidden</span>- </h5>++ <span id="visibilityStatus" class="d-flex align-items-center">+ <span class="page_hidden badge badge-secondary <% if @cms_page.viewable? %>d-none<% end %>">+ <%= svg_icon name: "eye-slash-fill.svg", width: '18', height: '18' %> <%= Spree.t('admin.cms.draft_mode') %>+ </span>++ <span class="page_visible badge badge-primary <% if @cms_page.draft_mode? %>d-none<% end %>">+ <%= svg_icon name: "view.svg", width: '18', height: '18' %> <%= Spree.t('admin.cms.visable') %>+ </span>+ </span></div></div></div>+ <% end %><div class="card-body"><div class="row pb-0">