Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Popper.js re-implementation of asset tooltips #1009

Merged
merged 3 commits into from
May 28, 2019
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
7 changes: 6 additions & 1 deletion concordia/static/js/action-app/components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global jQuery, OpenSeadragon */
/* global jQuery, OpenSeadragon, Popper */

import {$, $$} from './utils/dom.js';

Expand Down Expand Up @@ -369,18 +369,23 @@ export class AssetList extends List {
setupTooltip(getAssetData) {
/* Tooltips */
let tooltip = new AssetTooltip();
let popper;

const handleTooltipShowEvent = event => {
let target = event.target;
if (target && target.classList.contains('asset')) {
const asset = getAssetData(target.dataset.id);
tooltip.update(asset);
mount(target, tooltip);
popper = new Popper(target, tooltip.el, {
placement: 'bottom'
});
}
};

const handleTooltipHideEvent = () => {
if (tooltip.el.parentNode) {
popper.destroy();
unmount(tooltip.el.parentNode, tooltip);
}
};
Expand Down
23 changes: 18 additions & 5 deletions concordia/static/scss/action-app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ main {
transition-property: height, width;
transition-duration: 0.1s;

&:hover {
outline: 2px solid $blue;
outline-offset: -2px;
}

&.asset-active {
outline: 2px auto $orange;
outline: 2px solid $orange;
outline-offset: -2px;
}

Expand Down Expand Up @@ -181,15 +186,23 @@ main {
}

.asset-tooltip {
width: calc(100% + ($asset-thumbnail-gap * 2));
height: calc(100% + ($asset-thumbnail-gap * 2));

margin: $asset-thumbnail-gap * -1;
padding: 14px;

border: $border-width solid $gray-600;

overflow: hidden;

pointer-events: none;

background-color: $white;

font-size: $concordia-app-font-size-xs;
line-height: $concordia-app-line-height-xs;
pointer-events: none;
overflow: hidden;
width: calc(100% + ($asset-thumbnail-gap * 2));
height: calc(100% + ($asset-thumbnail-gap * 2));

.item-title {
font-weight: bold;
margin-bottom: 1rem;
Expand Down