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.

Open source admin layout

Damian Kaczmarczykb746bd917c2c
diff --git a/admin/app/assets/config/spree_admin_manifest.js b/admin/app/assets/config/spree_admin_manifest.js
index 1afc495584..f9f1b65221 100644
--- a/admin/app/assets/config/spree_admin_manifest.js
+++ b/admin/app/assets/config/spree_admin_manifest.js
@@ -1,3 +1,6 @@
+//= link spree/admin/actiontext.css
+//= link spree/admin/application.css
+
//= link_directory ../../javascript/spree/admin/controllers .js
//= link_directory ../../javascript/spree/admin/helpers .js
//= link_directory ../../javascript/spree/admin/helpers/flatfile .js
diff --git a/admin/app/assets/stylesheets/spree/admin/actiontext.css b/admin/app/assets/stylesheets/spree/admin/actiontext.css
new file mode 100644
index 0000000000..f00bf6ccd6
--- /dev/null
+++ b/admin/app/assets/stylesheets/spree/admin/actiontext.css
@@ -0,0 +1,36 @@
+/*
+ * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
+ * the trix-editor content (whether displayed or under editing). Feel free to incorporate this
+ * inclusion directly in any other asset bundle and remove this file.
+ *
+ *= require trix
+*/
+
+/*
+ * We need to override trix.css’s image gallery styles to accommodate the
+ * <action-text-attachment> element we wrap around attachments. Otherwise,
+ * images in galleries will be squished by the max-width: 33%; rule.
+*/
+.trix-content .attachment-gallery > action-text-attachment,
+.trix-content .attachment-gallery > .attachment {
+ flex: 1 0 33%;
+ padding: 0 0.5em;
+ max-width: 33%;
+}
+
+.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
+.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
+.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
+ flex-basis: 50%;
+ max-width: 50%;
+}
+
+.trix-content action-text-attachment .attachment {
+ padding: 0 !important;
+ max-width: 100% !important;
+}
+
+.trix-button--dialog {
+ width: auto !important;
+ height: auto !important;
+}
diff --git a/admin/app/javascript/spree/admin/controllers/filters_controller.js b/admin/app/javascript/spree/admin/controllers/filters_controller.js
index 023bd56ac2..b64ee79376 100644
--- a/admin/app/javascript/spree/admin/controllers/filters_controller.js
+++ b/admin/app/javascript/spree/admin/controllers/filters_controller.js
@@ -1,4 +1,5 @@
import { Controller } from "@hotwired/stimulus";
+import DOMPurify from "dompurify"
export default class extends Controller {
static targets = ["input", "badgesContainer", "badgeTemplate"];
diff --git a/admin/app/javascript/spree/admin/helpers/tinymce.js b/admin/app/javascript/spree/admin/helpers/tinymce.js
index 7d8e127395..4e5d5ef010 100644
--- a/admin/app/javascript/spree/admin/helpers/tinymce.js
+++ b/admin/app/javascript/spree/admin/helpers/tinymce.js
@@ -1,3 +1,5 @@
+import 'tinymce'
+
document.addEventListener('turbo:before-render', initializeTinmce)
document.addEventListener('turbo:load', initializeTinmce)
document.addEventListener('turbo:frame-render', initializeTinmce)
diff --git a/admin/app/views/layouts/spree/admin.html.erb b/admin/app/views/layouts/spree/admin.html.erb
index a6cca4256b..0fbc8b092e 100644
--- a/admin/app/views/layouts/spree/admin.html.erb
+++ b/admin/app/views/layouts/spree/admin.html.erb
@@ -1,29 +1,31 @@
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
<head>
- <!-- Trix does not work with importmaps in Rails 7 -->
- <!-- https://github.com/basecamp/trix/issues/1182 -->
- <%= javascript_include_tag 'trix' %>
- <%= javascript_importmap_tags 'application-spree-admin' %>
+ <%= render "spree/admin/shared/head" %>
+ <%= render "spree/admin/shared/custom_head" %>
</head>
+
<body class="admin min-vh-100 <%= controller_name %> <%= action_name %>">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-lg-3 col-xl-2 d-none d-lg-block position-relative px-2">
- <%#= render 'spree/admin/shared/sidebar' %>
+ <%= render "spree/admin/shared/sidebar" %>
</div>
- <div class="col-lg-9 col-xl-10 px-0 pb-5 mb-3 pt-lg-2">
- <main id="content" class="container">
- <% if content_for?(:table_filter) || content_for?(:table_filter_dropdown) %>
- <div class="card-lg p-0 mb-lg-3">
- <%= yield %>
- </div>
- <% else %>
- <%= yield %>
- <% end %>
+ <div class="col-lg-9 col-xl-10 px-0 pt-lg-2">
+ <%= render "spree/admin/shared/header" %>
+
+ <main id="content" class="container h-100 d-flex flex-column">
+ <%= render "spree/admin/shared/content_header" %>
+
+ <%= yield %>
+
+ <%= render "spree/admin/shared/footer" %>
</main>
</div>
</div>
</div>
+
+ <%= render "spree/admin/shared/modal" %>
+ <%= render "spree/admin/shared/alerts" %>
</body>
</html>
diff --git a/admin/app/views/spree/admin/shared/_content_header.html.erb b/admin/app/views/spree/admin/shared/_content_header.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/admin/app/views/spree/admin/shared/_footer.html.erb b/admin/app/views/spree/admin/shared/_footer.html.erb
new file mode 100644
index 0000000000..23a3c3d27d
--- /dev/null
+++ b/admin/app/views/spree/admin/shared/_footer.html.erb
@@ -0,0 +1,14 @@
+<div
+ class="
+ mt-auto font-size-sm text-muted pt-0 pb-3 pt-lg-5 d-none d-lg-flex
+ align-items-center justify-content-end w-100
+ "
+>
+ <div class="bg-light rounded-lg p-2 ml-3">
+ <%= Spree.t(:powered_by) %>
+ <%= link_to 'https://www.spreecommerce.org', target: '_blank', class: 'text-dark' do %>
+ Spree
+ <%= Spree.version %>
+ <% end %>
+ </div>
+</div>
diff --git a/admin/app/views/spree/admin/shared/_head.html.erb b/admin/app/views/spree/admin/shared/_head.html.erb
new file mode 100644
index 0000000000..141f05c54b
--- /dev/null
+++ b/admin/app/views/spree/admin/shared/_head.html.erb
@@ -0,0 +1,66 @@
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+
+<%= csrf_meta_tags %>
+
+<title>
+ <% if content_for? :title %>
+ <%= yield :title %>
+ <% else %>
+ <% if @object.present? %>
+ <%= @object.try(:name) || @object.try(:title) || Spree.t(controller_name.singularize, default: controller_name.singularize.titleize)%>
+ <% elsif @parent.present? %>
+ <%= @parent.try(:name) || @parent.try(:title) || Spree.t(controller_name.singularize, default: controller_name.singularize.titleize) %>
+ <% elsif @order.present? %>
+ <%= Spree.t('order') %> #<%= @order.number %>
+ <% elsif action_name == 'index' %>
+ <%= Spree.t(controller_name, default: controller_name.titleize) %>
+ <% else %>
+ <%= Spree.t(controller_name.singularize, default: controller_name.singularize.titleize) %>
+ <% end %>
+ <% end %>
+ -
+ <% if defined?(current_store) && current_store.present? %>
+ <%= current_store.name.capitalize %>
+ <% else %>
+ Spree
+ <% end %>
+</title>
+
+<link rel="preconnect" href="https://fonts.googleapis.com">
+<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+<link href="https://fonts.googleapis.com/css2?family=Castoro:ital@0;1&family=Inter:[email protected]&display=swap" rel="stylesheet">
+
+<%= stylesheet_link_tag 'spree/admin/application', media: :all, data: { turbo_track: "reload" } %>
+<%= stylesheet_link_tag 'spree/admin/actiontext', media: :all, data: { turbo_track: "reload" } %>
+<%= action_cable_meta_tag %>
+
+<%= favicon_link_tag asset_path('favicon.svg') %>
+
+<%= yield :head %>
+
+<% if Rails.env.test? %>
+ <style>
+ table tr td .btn {
+ visibility: visible !important;
+ }
+ </style>
+<% end %>
+
+<% if Rails.env.test? %>
+ <style>
+ .text-uppercase {
+ text-transform: none !important;
+ }
+ </style>
+<% end %>
+
+<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css">
+
+<%= tag.meta name: "direct-upload-url", content: main_app.rails_direct_uploads_path %>
+
+<!-- Trix does not work with importmaps in Rails 7 -->
+<!-- https://github.com/basecamp/trix/issues/1182 -->
+<%= javascript_include_tag 'trix' %>
+<%= javascript_importmap_tags 'application-spree-admin' %>
diff --git a/admin/app/views/spree/admin/shared/_header.html.erb b/admin/app/views/spree/admin/shared/_header.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/admin/app/views/spree/admin/shared/_sidebar.html.erb b/admin/app/views/spree/admin/shared/_sidebar.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/admin/config/importmap.rb b/admin/config/importmap.rb
index 83fb114a45..e17248820b 100644
--- a/admin/config/importmap.rb
+++ b/admin/config/importmap.rb
@@ -15,6 +15,8 @@ pin "mapkick/bundle", to: "mapkick.bundle.js", preload: ["application-spree-admi
pin 'jquery', to: 'jquery3.min.js', preload: ["application-spree-admin"]
# Bootstrap 4 does not want to work with importmaps, after long debugging I found this comment which helped https://github.com/twbs/bootstrap-rubygem/issues/257#issuecomment-1707196465. Bootstrap has to be imported from jsdelivr.
pin "bootstrap", to: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js', preload: ["application-spree-admin"]
+pin "tinymce", to: 'tinymce/tinymce.js', preload: ["application-spree-admin"]
+pin "dompurify", to: 'https://ga.jspm.io/npm:[email protected]/dist/purify.es.mjs', preload: ["application-spree-admin"]
# Stimulus components
pin "@stimulus-components/auto-submit", to: "https://ga.jspm.io/npm:@stimulus-components/[email protected]/dist/stimulus-auto-submit.mjs", preload: false