From b508862c9b54a4625422c965d2bc90eaaa51b7cc Mon Sep 17 00:00:00 2001 From: Maxime Moraine Date: Fri, 12 Mar 2021 19:28:30 +0100 Subject: [PATCH] =?UTF-8?q?tooltips=20pour=20les=20=C3=A9tats=20pr=C3=A9ju?= =?UTF-8?q?diciables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/data/ruleTooltips.js | 11 ++++ docs/.vuepress/theme/components/MagicItem.vue | 12 +++++ docs/.vuepress/theme/components/Monster.vue | 10 ++++ docs/.vuepress/theme/components/Page.vue | 13 ++++- docs/.vuepress/theme/components/Spell.vue | 9 ++++ docs/.vuepress/theme/layouts/GlobalLayout.vue | 14 +++-- docs/.vuepress/theme/styles/_tooltips.scss | 37 +++++++++++++ docs/.vuepress/theme/util/index.js | 54 +++++++++++++++++++ 8 files changed, 156 insertions(+), 4 deletions(-) diff --git a/docs/.vuepress/data/ruleTooltips.js b/docs/.vuepress/data/ruleTooltips.js index fbd2426..7ae690f 100644 --- a/docs/.vuepress/data/ruleTooltips.js +++ b/docs/.vuepress/data/ruleTooltips.js @@ -114,6 +114,17 @@ export const tooltips = { "Toute attaque qui touche la créature est obligatoirement un coup critique si l'assaillant se trouve dans un rayon de 1,50 mètre autour d'elle." ] }, + 'paralyse': { + id: 'paralyse', + basePath: '/gerer-la-sante-du-personnage/', + title: 'Paralysé', + description: [ + "Une créature paralysée est neutralisée (voir l'état) et ne peut ni parler ni se déplacer.", + "La créature rate automatiquement tous ses jets de sauvegarde de Force et de Dextérité.", + "Les attaques visant la créature bénéficient d'un avantage.", + "Toute attaque qui touche la créature est obligatoirement un coup critique si l'assaillant se trouve dans un rayon de 1,50 mètre autour d'elle." + ] + }, 'petrifie': { id: 'petrifie', basePath: '/gerer-la-sante-du-personnage/', diff --git a/docs/.vuepress/theme/components/MagicItem.vue b/docs/.vuepress/theme/components/MagicItem.vue index e6940b5..4ba3d1c 100644 --- a/docs/.vuepress/theme/components/MagicItem.vue +++ b/docs/.vuepress/theme/components/MagicItem.vue @@ -23,6 +23,7 @@ diff --git a/docs/.vuepress/theme/components/Monster.vue b/docs/.vuepress/theme/components/Monster.vue index 0c5cb22..3c78c03 100644 --- a/docs/.vuepress/theme/components/Monster.vue +++ b/docs/.vuepress/theme/components/Monster.vue @@ -168,6 +168,8 @@ import { displayMonsterTypeSizeAlignment } from '@theme/util/monsterHelpers' +import { handleTooltips } from '@theme/util' + import {stats} from '../../data/stats.js' import {armorTypes} from '../../data/armorTypes.js' import MarkdownIt from 'markdown-it' @@ -508,6 +510,14 @@ export default { mounted () { //console.log(this.$page) + setTimeout(function () { + handleTooltips() + }, 100); + this.$router.afterEach(() => { + setTimeout(function () { + handleTooltips() + }, 100) + }) } } diff --git a/docs/.vuepress/theme/components/Page.vue b/docs/.vuepress/theme/components/Page.vue index f9545a6..08a768f 100644 --- a/docs/.vuepress/theme/components/Page.vue +++ b/docs/.vuepress/theme/components/Page.vue @@ -7,9 +7,20 @@ diff --git a/docs/.vuepress/theme/components/Spell.vue b/docs/.vuepress/theme/components/Spell.vue index fa947a9..351701c 100644 --- a/docs/.vuepress/theme/components/Spell.vue +++ b/docs/.vuepress/theme/components/Spell.vue @@ -41,6 +41,7 @@ diff --git a/docs/.vuepress/theme/layouts/GlobalLayout.vue b/docs/.vuepress/theme/layouts/GlobalLayout.vue index fea9d88..fed422a 100644 --- a/docs/.vuepress/theme/layouts/GlobalLayout.vue +++ b/docs/.vuepress/theme/layouts/GlobalLayout.vue @@ -29,8 +29,8 @@ mdi-chevron-up - - + + @@ -64,6 +64,13 @@ +
+
+
+
+
+
+ @@ -74,6 +81,7 @@ import NavDrawer from '@theme/components/NavDrawer.vue' import RightDrawer from '@theme/components/RightDrawer.vue' import Vue from 'vue' import Cookies from 'js-cookie' +import { tooltips } from '../../data/ruleTooltips.js' export default { name: 'GlobalLayout', @@ -188,7 +196,7 @@ export default { setTimeout(function () { self.hintCopied = '' }, 2000) - } + }, } } diff --git a/docs/.vuepress/theme/styles/_tooltips.scss b/docs/.vuepress/theme/styles/_tooltips.scss index 6a1d03b..cfb5461 100644 --- a/docs/.vuepress/theme/styles/_tooltips.scss +++ b/docs/.vuepress/theme/styles/_tooltips.scss @@ -1,3 +1,40 @@ +#tooltip { + position: absolute; + display: none; + z-index: 1000; + + text-align: left; + width: 50vw; + max-width: 555px; + min-width: 350px; + background-color: #fff; + color: #555; + box-shadow: 0 0 12px #333; + border-radius: 5px; + + .tooltip-title { + background-color: $color-hero; + &.tooltip-spell { + background-color: $color-dragon; + } + // &.tooltip-condition { + // } + color: #fff; + font-family: 'Oswald', sans-serif; + font-weight: bold; + padding: 12px; + border-radius: 5px 5px 0 0; + } + + .tooltip-content { + padding: 12px; + ul { + margin: 0; + padding: 0 0 0 15px; + } + } +} + .v-tooltip__content { &.spell-tooltip-container, &.condition-tooltip-container { diff --git a/docs/.vuepress/theme/util/index.js b/docs/.vuepress/theme/util/index.js index 3d924fa..94b9692 100644 --- a/docs/.vuepress/theme/util/index.js +++ b/docs/.vuepress/theme/util/index.js @@ -262,3 +262,57 @@ export function isResourceInLibrary (resource, library) { } return false } + +/* +** Handles rule tooltips like conditions +*/ +import { tooltips } from '../../data/ruleTooltips.js' +export function handleTooltips (component) { + if (!component) { + component = document + } + // Gestion des tooltips + let tooltip = document.getElementById('tooltip') + let tooltipTitle = document.getElementById('tooltip-title') + let tooltipContent = document.getElementById('tooltip-content') + window.onmousemove = function (e) { + var x = e.pageX + 20, + y = e.pageY + 20; + + tooltip.style.top = y + 'px'; + tooltip.style.left = x + 'px'; + + // Get calculated tooltip coordinates and size + var tooltip_rect = tooltip.getBoundingClientRect(); + // Corrections if out of window + if ((tooltip_rect.x + tooltip_rect.width) > window.innerWidth) // Out on the right + x = x - tooltip_rect.width - 20; // Simulate a "right: tipX" position + if ((tooltip_rect.y + tooltip_rect.height) > window.innerHeight) // Out on the bottom + y = y - tooltip_rect.height - 20; // Align on the bottom + + // Apply corrected position + tooltip.style.top = y + 'px'; + tooltip.style.left = x + 'px'; + } + // Arborescence des liens + let links = component.querySelectorAll("a") + for (var l of links) { + let hash = l.hash.replace('#', '') + if (hash != "" && tooltips[hash]) { + l.addEventListener("mouseover", function( event ) { + tooltipTitle.innerHTML = tooltips[hash].title + let tcontent = '
    ' + for (var d of tooltips[hash].description) { + tcontent += '
  • ' + d + '
  • ' + } + tcontent += '
' + tooltipContent.innerHTML = tcontent + tooltip.style.display = 'block' + }, false); + + l.addEventListener("mouseout", function( event ) { + tooltip.style.display = 'none' + }, false); + } + } +}