diff --git a/app/components/popup_menu_component.rb b/app/components/popup_menu_component.rb new file mode 100644 index 000000000..63463ad02 --- /dev/null +++ b/app/components/popup_menu_component.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class PopupMenuComponent < ApplicationComponent + include ViewComponent::SlotableV2 + + renders_many :items +end diff --git a/app/components/popup_menu_component/popup_menu_component.html.erb b/app/components/popup_menu_component/popup_menu_component.html.erb new file mode 100644 index 000000000..843bf628d --- /dev/null +++ b/app/components/popup_menu_component/popup_menu_component.html.erb @@ -0,0 +1,11 @@ + diff --git a/app/components/popup_menu_component/popup_menu_component.js b/app/components/popup_menu_component/popup_menu_component.js new file mode 100644 index 000000000..272e1ddc3 --- /dev/null +++ b/app/components/popup_menu_component/popup_menu_component.js @@ -0,0 +1,26 @@ +import { delegate } from 'tippy.js'; +import 'tippy.js/dist/tippy.css'; + +class PopupMenuComponent { + static initialize() { + delegate("body", { + allowHTML: true, + interactive: true, + theme: "common-tooltip", + target: "a.popup-menu-button", + placement: "bottom-start", + trigger: "click", + content: PopupMenuComponent.content, + }); + } + + static content(element) { + let $content = $(element).parents(".popup-menu").find(".popup-menu-content"); + $content.show(); + return $content.get(0); + } +} + +$(document).ready(PopupMenuComponent.initialize); + +export default PopupMenuComponent; diff --git a/app/components/popup_menu_component/popup_menu_component.scss b/app/components/popup_menu_component/popup_menu_component.scss new file mode 100644 index 000000000..684973d3c --- /dev/null +++ b/app/components/popup_menu_component/popup_menu_component.scss @@ -0,0 +1,23 @@ +div.popup-menu { + a.popup-menu-button { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + border-radius: 50%; + color: var(--muted-text-color); + + &:hover { + background-color: var(--subnav-menu-background-color); + } + } + + ul.popup-menu-content { + display: none; + + .icon { + width: 1.5em; + } + } +} diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index bab66e46c..ed816dae2 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -39,6 +39,7 @@ export { default as CurrentUser } from '../src/javascripts/current_user.js'; export { default as Dtext } from '../src/javascripts/dtext.js'; export { default as IqdbQuery } from '../src/javascripts/iqdb_queries.js'; export { default as Note } from '../src/javascripts/notes.js'; +export { default as PopupMenuComponent } from "../../components/popup_menu_component/popup_menu_component.js"; export { default as Post } from '../src/javascripts/posts.js.erb'; export { default as PostModeMenu } from '../src/javascripts/post_mode_menu.js'; export { default as PostTooltip } from '../src/javascripts/post_tooltips.js'; diff --git a/app/javascript/src/javascripts/user_tooltips.js b/app/javascript/src/javascripts/user_tooltips.js index eff985a8c..9d939b9c5 100644 --- a/app/javascript/src/javascripts/user_tooltips.js +++ b/app/javascript/src/javascripts/user_tooltips.js @@ -25,19 +25,6 @@ UserTooltip.initialize = function () { onShow: UserTooltip.on_show, onHide: UserTooltip.on_hide, }); - - delegate("#user-tooltips", { - allowHTML: true, - interactive: true, - theme: "common-tooltip", - target: ".user-tooltip-menu-button", - placement: "bottom", - touch: false, - trigger: "click", - content: (element) => { - return $(element).parents(".user-tooltip").find(".user-tooltip-menu").get(0); - } - }); }; UserTooltip.on_show = async function (instance) { diff --git a/app/javascript/src/styles/specific/user_tooltips.scss b/app/javascript/src/styles/specific/user_tooltips.scss index 8b0fc6be9..b07cd6abc 100644 --- a/app/javascript/src/styles/specific/user_tooltips.scss +++ b/app/javascript/src/styles/specific/user_tooltips.scss @@ -57,29 +57,11 @@ font-size: 0.75em; } - a.user-tooltip-menu-button { - color: var(--muted-text-color); + div.popup-menu { grid-area: menu; align-self: center; - text-align: center; width: 28px; height: 28px; - line-height: 28px; - border-radius: 50%; - - &:hover { - background-color: var(--subnav-menu-background-color); - } - } - - > ul.user-tooltip-menu { - display: none; - } - - ul.user-tooltip-menu { - .icon { - width: 1.5em; - } } } diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index c79fa8acb..7e8e6d87d 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -93,6 +93,7 @@
+