From 427ac5c84b0336e6231a05078cf4a794f0098cac Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 22 Sep 2025 15:52:30 -0500 Subject: [PATCH 1/6] Add tooltip controller --- app/assets/stylesheets/tooltips.css | 18 ++++++++++- .../controllers/tooltip_controller.js | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 app/javascript/controllers/tooltip_controller.js diff --git a/app/assets/stylesheets/tooltips.css b/app/assets/stylesheets/tooltips.css index c206e8954..9986bdfed 100644 --- a/app/assets/stylesheets/tooltips.css +++ b/app/assets/stylesheets/tooltips.css @@ -2,6 +2,7 @@ .tooltip { --tooltip-delay: 750ms; --tooltip-duration: 150ms; + --tooltip-offset: -85%; .for-screen-reader { background: var(--color-ink); @@ -15,8 +16,18 @@ padding: 0.25ch 1ch; transition: var(--tooltip-duration) ease-out allow-discrete; transition-property: opacity, translate; - translate: -50% -85%; + translate: -50% var(--tooltip-offset); text-overflow: ellipsis; + + &.orient-right { + inset-inline-start: 0; + translate: 0 var(--tooltip-offset); + } + + &.orient-left { + inset-inline-end: 0; + translate: 0 var(--tooltip-offset); + } } @media(any-hover: hover) { @@ -27,6 +38,11 @@ opacity: 1; transition-delay: var(--tooltip-delay); translate: -50% -100%; + + &.orient-left, + &.orient-right { + translate: 0 -100%; + } } } } diff --git a/app/javascript/controllers/tooltip_controller.js b/app/javascript/controllers/tooltip_controller.js new file mode 100644 index 000000000..0b242f157 --- /dev/null +++ b/app/javascript/controllers/tooltip_controller.js @@ -0,0 +1,32 @@ +import { Controller } from "@hotwired/stimulus" +import { orient } from "helpers/orientation_helpers" + +export default class extends Controller { + static targets = [ "tooltip" ] + + connect() { + this.element.addEventListener("mouseenter", this.mouseEnter.bind(this)) + this.element.addEventListener("mouseout", this.mouseOut.bind(this)) + } + + disconnect() { + this.element.removeEventListener("mouseenter", this.mouseEnter.bind(this)) + this.element.removeEventListener("mouseout", this.mouseOut.bind(this)) + } + + mouseEnter(event) { + orient(this.#tooltipElement) + } + + mouseOut(event) { + orient(this.#tooltipElement, false) + } + + get #tooltipElement() { + return this.element.querySelector(".for-screen-reader") + } + + get #tooltipText() { + return this.#tooltipElement.innerText + } +} From a1758112e937899b1b7552ce9a8f6001685c46cd Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 22 Sep 2025 16:02:49 -0500 Subject: [PATCH 2/6] Add z-index --- app/assets/stylesheets/_global.css | 1 + app/assets/stylesheets/tooltips.css | 1 + 2 files changed, 2 insertions(+) diff --git a/app/assets/stylesheets/_global.css b/app/assets/stylesheets/_global.css index c991bba2b..2f9511f90 100644 --- a/app/assets/stylesheets/_global.css +++ b/app/assets/stylesheets/_global.css @@ -74,6 +74,7 @@ --z-popup: 10; --z-terminal: 20; --z-tray: 21; + --z-tooltip: 30; /* OKLCH colors: Fixed */ --lch-black: 0% 0 0; diff --git a/app/assets/stylesheets/tooltips.css b/app/assets/stylesheets/tooltips.css index 9986bdfed..353599ab4 100644 --- a/app/assets/stylesheets/tooltips.css +++ b/app/assets/stylesheets/tooltips.css @@ -38,6 +38,7 @@ opacity: 1; transition-delay: var(--tooltip-delay); translate: -50% -100%; + z-index: var(--z-tooltip); &.orient-left, &.orient-right { From 402e8312cdaa99005865e28506b06362acfec867 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 22 Sep 2025 16:33:16 -0500 Subject: [PATCH 3/6] Only transition opacity --- app/assets/stylesheets/tooltips.css | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/tooltips.css b/app/assets/stylesheets/tooltips.css index 353599ab4..9df7b7067 100644 --- a/app/assets/stylesheets/tooltips.css +++ b/app/assets/stylesheets/tooltips.css @@ -2,7 +2,6 @@ .tooltip { --tooltip-delay: 750ms; --tooltip-duration: 150ms; - --tooltip-offset: -85%; .for-screen-reader { background: var(--color-ink); @@ -15,18 +14,18 @@ opacity: 0; padding: 0.25ch 1ch; transition: var(--tooltip-duration) ease-out allow-discrete; - transition-property: opacity, translate; - translate: -50% var(--tooltip-offset); + transition-property: opacity; + translate: -50% -100%; text-overflow: ellipsis; &.orient-right { inset-inline-start: 0; - translate: 0 var(--tooltip-offset); + translate: 0 -100%; } &.orient-left { inset-inline-end: 0; - translate: 0 var(--tooltip-offset); + translate: 0 -100%; } } From 3c3ae8563e6b637ead98fba6f7f4ba2828114b36 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 22 Sep 2025 16:45:24 -0500 Subject: [PATCH 4/6] Larger max-width --- app/assets/stylesheets/tooltips.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/tooltips.css b/app/assets/stylesheets/tooltips.css index 9df7b7067..80abc5cc3 100644 --- a/app/assets/stylesheets/tooltips.css +++ b/app/assets/stylesheets/tooltips.css @@ -10,7 +10,7 @@ font-size: var(--text-x-small); font-weight: normal; inset: -1ch auto auto 50%; - max-inline-size: 28ch; + max-inline-size: 50ch; opacity: 0; padding: 0.25ch 1ch; transition: var(--tooltip-duration) ease-out allow-discrete; From 3d5bdc64f4637c68a03889f228a44c2ee3d53f7e Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 22 Sep 2025 16:50:07 -0500 Subject: [PATCH 5/6] Add JS controller to existing tooltips --- app/views/cards/_collection_settings.html.erb | 2 +- app/views/cards/_webhooks.html.erb | 2 +- app/views/cards/container/_gild.html.erb | 4 ++-- app/views/cards/container/_image.html.erb | 4 ++-- app/views/cards/container/footer/_draft.html.erb | 2 +- app/views/cards/display/common/_assignees.html.erb | 2 +- app/views/cards/display/perma/_background.html.erb | 2 +- app/views/cards/display/perma/_tags.html.erb | 2 +- app/views/cards/pins/_pin_button.html.erb | 4 ++-- app/views/cards/show.html.erb | 2 +- app/views/cards/watches/show.html.erb | 4 ++-- app/views/layouts/_lightbox.html.erb | 2 +- app/views/workflows/stages/_color.html.erb | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/cards/_collection_settings.html.erb b/app/views/cards/_collection_settings.html.erb index 318eeb70c..a03b2e4bb 100644 --- a/app/views/cards/_collection_settings.html.erb +++ b/app/views/cards/_collection_settings.html.erb @@ -1,4 +1,4 @@ -<%= link_to edit_collection_path(collection), class: "btn tooltip" do %> +<%= link_to edit_collection_path(collection), class: "btn tooltip", data: { controller: "tooltip" } do %> <%= icon_tag "settings" %> Settings for <%= collection.name %> <% end %> diff --git a/app/views/cards/_webhooks.html.erb b/app/views/cards/_webhooks.html.erb index 2bdddaa3d..079308b29 100644 --- a/app/views/cards/_webhooks.html.erb +++ b/app/views/cards/_webhooks.html.erb @@ -1,4 +1,4 @@ -<%= link_to collection_webhooks_path(collection_id: collection), class: ["btn tooltip", {"btn--reversed": collection.webhooks.any?}] do %> +<%= link_to collection_webhooks_path(collection_id: collection), class: ["btn tooltip", {"btn--reversed": collection.webhooks.any?}], data: { controller: "tooltip" } do %> <%= icon_tag "world" %> Webhooks <% end %> diff --git a/app/views/cards/container/_gild.html.erb b/app/views/cards/container/_gild.html.erb index dc4298348..a489f08cd 100644 --- a/app/views/cards/container/_gild.html.erb +++ b/app/views/cards/container/_gild.html.erb @@ -1,10 +1,10 @@ <% if card.golden? %> - <%= button_to card_goldness_path(card), method: :delete, class: "btn btn--reversed tooltip" do %> + <%= button_to card_goldness_path(card), method: :delete, class: "btn btn--reversed tooltip", data: { controller: "tooltip" } do %> <%= icon_tag "golden-ticket" %> Demote to normal <% end %> <% else %> - <%= button_to card_goldness_path(card), class: "btn tooltip" do %> + <%= button_to card_goldness_path(card), class: "btn tooltip", data: { controller: "tooltip" } do %> <%= icon_tag "golden-ticket" %> Promote to golden <% end %> diff --git a/app/views/cards/container/_image.html.erb b/app/views/cards/container/_image.html.erb index de2341aa1..ed11fd5c8 100644 --- a/app/views/cards/container/_image.html.erb +++ b/app/views/cards/container/_image.html.erb @@ -1,11 +1,11 @@ <% if card.image.attached? %> - <%= button_to card_image_path(card), method: :delete, class: "btn tooltip" do %> + <%= button_to card_image_path(card), method: :delete, class: "btn tooltip", data: { controller: "tooltip" } do %> <%= icon_tag "picture-remove" %> Remove background image <% end %> <% elsif !card.closed? %> <%= form_with model: card, url: card_path(card), data: { controller: "form" } do |form| %> -