diff --git a/alchemy_cms.gemspec b/alchemy_cms.gemspec index 1690e9b3a9..564989321d 100644 --- a/alchemy_cms.gemspec +++ b/alchemy_cms.gemspec @@ -56,6 +56,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency "capybara", ["~> 3.0"] gem.add_development_dependency "capybara-screenshot", ["~> 1.0"] + gem.add_development_dependency "capybara-shadowdom", ["~> 0.3"] gem.add_development_dependency "factory_bot_rails", ["~> 6.0"] gem.add_development_dependency "puma", ["~> 6.0"] gem.add_development_dependency "rails-controller-testing", ["~> 1.0"] diff --git a/app/assets/config/alchemy_manifest.js b/app/assets/config/alchemy_manifest.js index 6faec0f116..e7f0abeca5 100644 --- a/app/assets/config/alchemy_manifest.js +++ b/app/assets/config/alchemy_manifest.js @@ -2,7 +2,6 @@ //= link alchemy/admin/all.js //= link alchemy/preview.js //= link alchemy/menubar.css -//= link alchemy/menubar.js //= link alchemy/print.css //= link alchemy/welcome.css //= link tinymce/plugins/alchemy_link/plugin.min.js diff --git a/app/assets/javascripts/alchemy/menubar.js.coffee b/app/assets/javascripts/alchemy/menubar.js.coffee deleted file mode 100644 index 5b4694df91..0000000000 --- a/app/assets/javascripts/alchemy/menubar.js.coffee +++ /dev/null @@ -1,8 +0,0 @@ -window.Alchemy = {} if typeof(window.Alchemy) is 'undefined' - -Alchemy.showMenubar = -> - menubar = document.getElementById('alchemy_menubar') - if (typeof(menubar) != 'undefined' && menubar != null) - menubar.style.display = "block" - -Alchemy.showMenubar() diff --git a/app/assets/stylesheets/alchemy/menubar.scss b/app/assets/stylesheets/alchemy/menubar.scss index 85e43e7f7c..0684eefb5a 100644 --- a/app/assets/stylesheets/alchemy/menubar.scss +++ b/app/assets/stylesheets/alchemy/menubar.scss @@ -32,13 +32,13 @@ } &:after { - content: ''; + content: ""; width: 24px; height: 24px; position: absolute; right: 10px; top: 50%; - background: image-url('alchemy/icon-white.svg') 1px 1px no-repeat; + background: image-url("alchemy/icon-white.svg") 1px 1px no-repeat; background-size: 24px 24px; transform: translateY(-50%); } @@ -57,7 +57,8 @@ list-style-type: none; text-align: center; - a, button { + a, + button { @include button-defaults( $background-color: $main-menu-bg-color, $hover-color: $blue, @@ -70,10 +71,10 @@ ); width: 100%; text-decoration: none !important; - text-transform: none; - font-family: $default-font-family; - &:after { display: none } + &:after { + display: none; + } } } } diff --git a/app/javascript/menubar.js b/app/javascript/menubar.js new file mode 100644 index 0000000000..369ec38019 --- /dev/null +++ b/app/javascript/menubar.js @@ -0,0 +1,10 @@ +class Menubar extends HTMLElement { + constructor() { + super() + const template = this.querySelector("template") + const attachedShadowRoot = this.attachShadow({ mode: "open" }) + attachedShadowRoot.appendChild(template.content.cloneNode(true)) + } +} + +customElements.define("alchemy-menubar", Menubar) diff --git a/app/views/alchemy/_menubar.html.erb b/app/views/alchemy/_menubar.html.erb index 272c970730..ce296a2287 100644 --- a/app/views/alchemy/_menubar.html.erb +++ b/app/views/alchemy/_menubar.html.erb @@ -1,16 +1,20 @@ <% if !@preview_mode && @page && can?(:edit_content, @page) %> -
+