Using Tippy.js for directive tooltips.

This commit is contained in:
DebaucheryLibrarian 2021-04-27 03:56:38 +02:00
parent 8bf9fff7dc
commit 3b91493995
7 changed files with 73 additions and 13 deletions

View File

@ -148,12 +148,14 @@
/>Notify me in traxxx />Notify me in traxxx
</label> </label>
<!--
<label class="alert-label"> <label class="alert-label">
<Checkbox <Checkbox
:checked="email" :checked="email"
@change="checked => email = checked" @change="checked => email = checked"
/>Send me an e-mail />Send me an e-mail
</label> </label>
-->
<div class="stashes-container"> <div class="stashes-container">
<ul class="stashes nolist"> <ul class="stashes nolist">

View File

@ -91,6 +91,13 @@
</div> </div>
</div> </div>
<Icon
v-if="notification.alert"
v-tooltip="`You set an alert for <strong>${notification.alert.tags.map(tag => tag.name).join(', ') || 'all'}</strong> scenes with <strong>${notification.alert.actors.map(actor => actor.name).join(', ') || 'any actor'}</strong> for <strong>${notification.alert.entity?.name || 'any channel'}</strong>`"
icon="question5"
@click.prevent
/>
<Icon <Icon
v-if="!notification.seen" v-if="!notification.seen"
v-tooltip="'Mark as seen'" v-tooltip="'Mark as seen'"
@ -193,9 +200,18 @@ export default {
border-right: solid .5rem var(--primary); border-right: solid .5rem var(--primary);
} }
.icon {
padding: 1rem;
fill: var(--shadow-weak);
&:hover {
fill: var(--primary);
}
}
&:not(:last-child) { &:not(:last-child) {
.notification-body, .notification-body,
.notification-check { .icon {
border-bottom: solid 1px var(--shadow-hint); border-bottom: solid 1px var(--shadow-hint);
} }
} }
@ -263,15 +279,6 @@ export default {
font-weight: bold; font-weight: bold;
} }
.notification-check {
padding: 1rem;
fill: var(--shadow-weak);
&:hover {
fill: var(--primary);
}
}
.poster { .poster {
width: 5rem; width: 5rem;
height: 3rem; height: 3rem;

View File

@ -2,6 +2,7 @@ import config from 'config';
import { createApp } from 'vue'; import { createApp } from 'vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import mitt from 'mitt'; import mitt from 'mitt';
import tippy from 'tippy.js';
import router from './router'; import router from './router';
import initStore from './store'; import initStore from './store';
@ -11,6 +12,7 @@ import initAuthObservers from './auth/observers';
import { formatDate, formatDuration } from './format'; import { formatDate, formatDuration } from './format';
import '../css/style.scss'; import '../css/style.scss';
import 'tippy.js/dist/tippy.css';
import Container from '../components/container/container.vue'; import Container from '../components/container/container.vue';
import Icon from '../components/icon/icon.vue'; import Icon from '../components/icon/icon.vue';
@ -123,8 +125,17 @@ async function init() {
app.directive('tooltip', { app.directive('tooltip', {
beforeMount(el, binding) { beforeMount(el, binding) {
// console.log(binding.modifiers); // don't include HTML in native title attribute
el.title = binding.value; // eslint-disable-line no-param-reassign const textEl = document.createElement('div');
textEl.innerHTML = binding.value;
el.title = textEl.textContent; // eslint-disable-line no-param-reassign
tippy(el, {
content: binding.value,
allowHTML: true,
duration: [0, 0],
});
}, },
}); });

View File

@ -66,6 +66,14 @@ function initUiActions(store, _router) {
slug slug
} }
} }
entity: alertsEntityByAlertId {
entity {
id
name
slug
independent
}
}
} }
} }
} }

31
package-lock.json generated
View File

@ -68,6 +68,7 @@
"showdown": "^1.9.1", "showdown": "^1.9.1",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",
"template-format": "^1.2.5", "template-format": "^1.2.5",
"tippy.js": "^6.3.1",
"tough-cookie": "^3.0.1", "tough-cookie": "^3.0.1",
"tty-table": "^2.8.12", "tty-table": "^2.8.12",
"tunnel": "0.0.6", "tunnel": "0.0.6",
@ -1398,6 +1399,15 @@
"upath": "^1.1.1" "upath": "^1.1.1"
} }
}, },
"node_modules/@popperjs/core": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@tokenizer/token": { "node_modules/@tokenizer/token": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz",
@ -13748,6 +13758,14 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/tippy.js": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.1.tgz",
"integrity": "sha512-JnFncCq+rF1dTURupoJ4yPie5Cof978inW6/4S6kmWV7LL9YOSEVMifED3KdrVPEG+Z/TFH2CDNJcQEfaeuQww==",
"dependencies": {
"@popperjs/core": "^2.8.3"
}
},
"node_modules/tmp": { "node_modules/tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@ -16755,6 +16773,11 @@
"upath": "^1.1.1" "upath": "^1.1.1"
} }
}, },
"@popperjs/core": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q=="
},
"@tokenizer/token": { "@tokenizer/token": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz",
@ -26804,6 +26827,14 @@
"resolved": "https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz", "resolved": "https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz",
"integrity": "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw==" "integrity": "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw=="
}, },
"tippy.js": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.1.tgz",
"integrity": "sha512-JnFncCq+rF1dTURupoJ4yPie5Cof978inW6/4S6kmWV7LL9YOSEVMifED3KdrVPEG+Z/TFH2CDNJcQEfaeuQww==",
"requires": {
"@popperjs/core": "^2.8.3"
}
},
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",

View File

@ -129,6 +129,7 @@
"showdown": "^1.9.1", "showdown": "^1.9.1",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",
"template-format": "^1.2.5", "template-format": "^1.2.5",
"tippy.js": "^6.3.1",
"tough-cookie": "^3.0.1", "tough-cookie": "^3.0.1",
"tty-table": "^2.8.12", "tty-table": "^2.8.12",
"tunnel": "0.0.6", "tunnel": "0.0.6",

View File

@ -39,7 +39,7 @@ module.exports = {
], ],
}, },
{ {
test: /\.scss$/, test: /\.s?css$/,
use: [ use: [
MiniCssExtractPlugin.loader, MiniCssExtractPlugin.loader,
{ {