Skip to content

Commit

Permalink
Merge pull request #1017 from OpenFn/972-fix-credential-tooltip
Browse files Browse the repository at this point in the history
Fix cutting-off tooltips
  • Loading branch information
stuartc authored Aug 14, 2023
2 parents 5bee89a + f1675e0 commit dc5a7df
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 17 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ and this project adheres to

### Fixed

- Tooltip for credential select in Job Edit form is cut off
[#972](https://github.com/OpenFn/Lightning/issues/972)

## [v0.7.2] - 2023-08-10

### Added

### Changed

### Fixed

- NodeJs security patch [1009](https://github.com/OpenFn/Lightning/pull/1009)

### Fixed

## [v0.7.1] - 2023-08-04

### Added
Expand Down
9 changes: 9 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@
animation: 0.2s ease-out 0s normal forwards 1 fade-out-keys;
}

div[id^='tippy-'] {
color: rgb(241 245 249);
background: rgb(15 23 42);
border-radius: 0.375rem;
padding: 0.5rem;
z-index: 9999;
margin: 2px;
}

@keyframes fade-in-scale-keys {
0% {
scale: 0.95;
Expand Down
3 changes: 2 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Socket } from 'phoenix';
import { LiveSocket } from 'phoenix_live_view';

import topbar from '../vendor/topbar';
import { AssocListChange, Copy, Flash, SubmitViaCtrlS } from './hooks';
import { AssocListChange, Copy, Flash, SubmitViaCtrlS, Tooltip } from './hooks';
import JobEditor from './job-editor';
import JobEditorResizer from './job-editor-resizer/mount';
import TabSelector from './tab-selector';
Expand All @@ -37,6 +37,7 @@ let Hooks = {
JobEditorResizer,
WorkflowEditor,
Flash,
Tooltip,
AssocListChange,
Copy,
SubmitViaCtrlS,
Expand Down
18 changes: 18 additions & 0 deletions assets/js/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import tippy, { Instance as TippyInstance } from 'tippy.js';
import { PhoenixHook } from './PhoenixHook';

export const Flash = {
Expand All @@ -16,6 +17,23 @@ export const Flash = {
},
} as PhoenixHook<{ timer: ReturnType<typeof setTimeout> }>;

export const Tooltip = {
mounted() {
if (!this.el.ariaLabel) {
console.warn('Tooltip element missing aria-label attribute', this.el);
return;
}

let content = this.el.ariaLabel;
this._tippyInstance = tippy(this.el, {
content: content,
});
},
destroyed() {
if (this._tippyInstance) this._tippyInstance.unmount();
},
} as PhoenixHook<{ _tippyInstance: TippyInstance | null }>;

export const AssocListChange = {
mounted() {
this.el.addEventListener('change', _event => {
Expand Down
31 changes: 31 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"react-dom": "^18.1.0",
"react-markdown": "^8.0.3",
"reactflow": "^11.7.0",
"tippy.js": "^6.3.7",
"zustand": "^4.3.7"
},
"devDependencies": {
Expand Down
16 changes: 2 additions & 14 deletions lib/lightning_web/live/components/common.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,13 @@ defmodule LightningWeb.Components.Common do

def tooltip(assigns) do
classes = ~w"
relative ml-1 cursor-pointer tooltip
hover:after:content-[attr(aria-label)]
hover:after:absolute
hover:after:top-3
hover:after:left-3
hover:after:min-w-[12rem]
hover:after:max-w-fit
hover:after:rounded-md
hover:after:px-3
hover:after:p-2
hover:after:z-10
hover:after:bg-slate-900
hover:after:text-slate-100
relative ml-1 cursor-pointer
"

assigns = assign(assigns, class: classes ++ List.wrap(assigns.class))

~H"""
<span class={@class} id={@id} aria-label={@title}>
<span class={@class} id={@id} aria-label={@title} phx-hook="Tooltip">
<Heroicons.information_circle
solid
class="w-4 h-4 text-primary-600 opacity-50"
Expand Down

0 comments on commit dc5a7df

Please sign in to comment.