Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/components/dependency-list/row.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
cursor: help;
}

.tooltip {
word-break: break-all;
}

@media only screen and (max-width: 550px) {
display: block
}
}

.tooltip {
word-break: break-all;
}

.range-lg, .range-sm {
margin-right: var(--space-s);
min-width: 100px;
Expand Down
22 changes: 13 additions & 9 deletions app/components/tooltip.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<div ...attributes local-class="tooltip" {{attach-tooltip hide=this.hide show=this.show side=@side}}>
{{#unless this.hidden}}
{{#if (has-block)}}
{{yield}}
{{else}}
{{@text}}
{{/if}}
{{/unless}}
</div>
<span local-class="anchor" {{this.onInsertAnchor this}} />

{{#if this.visible}}
{{#in-element this.containerElement}}
<div ...attributes local-class="tooltip" {{this.attachTooltip this side=@side}}>
{{#if (has-block)}}
{{yield}}
{{else}}
{{@text}}
{{/if}}
</div>
{{/in-element}}
{{/if}}
59 changes: 55 additions & 4 deletions app/components/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,65 @@ import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';
import { modifier } from 'ember-modifier';

export default class Tooltip extends Component {
@tracked hidden = true;
@tracked anchorElement = null;
@tracked visible = false;

@action hide() {
this.hidden = true;
get containerElement() {
return document.querySelector('#tooltip-container');
}

@action show() {
this.hidden = false;
this.visible = true;
}

@action hide() {
this.visible = false;
}

onInsertAnchor = modifier((anchor, [component]) => {
component.anchorElement = anchor.parentElement;

let events = [
['mouseenter', component.show],
['mouseleave', component.hide],
['focus', component.show],
['blur', component.hide],
];

for (let [event, listener] of events) {
component.anchorElement.addEventListener(event, listener);
}

return () => {
for (let [event, listener] of events) {
component.anchorElement?.removeEventListener(event, listener);
}
};
});

attachTooltip = modifier((floatingElement, [component], { side = 'top' } = {}) => {
let referenceElement = component.anchorElement;

async function update() {
let middleware = [offset(5), flip(), shift({ padding: 5 })];

let { x, y } = await computePosition(referenceElement, floatingElement, {
placement: side,
middleware,
});

Object.assign(floatingElement.style, {
left: `${x}px`,
top: `${y}px`,
});
}

let cleanup = autoUpdate(referenceElement, floatingElement, update);

return () => cleanup();
});
}
5 changes: 4 additions & 1 deletion app/components/tooltip.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.tooltip {
display: none;
width: max-content;
max-width: 300px;
position: absolute;
Expand All @@ -20,3 +19,7 @@
color: unset;
}
}

.anchor {
display: none;
}
2 changes: 1 addition & 1 deletion app/components/version-list/row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{@version.releaseTrack}}
{{/if}}

<Tooltip @side="right" local-class="tooltip" data-test-release-track-title>
<Tooltip @side="right" local-class="rt-tooltip" data-test-release-track-title>
{{this.releaseTrackTitle}}
</Tooltip>
</div>
Expand Down
20 changes: 11 additions & 9 deletions app/components/version-list/row.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
grid-template-columns: auto auto;
place-items: center;

.tooltip {
word-break: break-all;
}

@media only screen and (max-width: 550px) {
grid-template-columns: auto;
margin: 0 var(--space-s);
Expand Down Expand Up @@ -109,6 +105,10 @@
color: hsl(0, 87%, 58%);
}

.rt-tooltip {
word-break: break-all;
}

.num-link {
max-width: 200px;
text-overflow: ellipsis;
Expand Down Expand Up @@ -161,11 +161,6 @@
margin-bottom: -.1em;
}

.tooltip {
text-transform: none;
letter-spacing: normal;
}

> * + * {
margin-top: var(--space-2xs);

Expand Down Expand Up @@ -226,6 +221,13 @@
padding: 0;
margin: var(--space-2xs) var(--space-3xs);
list-style: none;

svg {
height: 1em;
width: auto;
margin-right: var(--space-4xs);
margin-bottom: -.1em;
}
}

.yank-button {
Expand Down
45 changes: 0 additions & 45 deletions app/modifiers/attach-tooltip.js

This file was deleted.

4 changes: 0 additions & 4 deletions app/styles/shared/typography.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
strong {
color: var(--main-color);
}

:global(.tooltip) strong {
color: inherit;
}
}

.small a, a.small {
Expand Down
1 change: 1 addition & 0 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<ProgressBar/>
<NotificationContainer @position="top-right"/>
<div id="tooltip-container"></div>

<Header @hero={{this.isIndex}} />

Expand Down
Loading