From 960b069eb91dd122fcdb2e4898d041b068e8531b Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 2 May 2022 11:11:02 +0100 Subject: [PATCH] Add mobile/touch support (where hover doesn't exist) --- docs/diagram.md | 22 ++++++++++++++++++---- docs/extra.css | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/diagram.md b/docs/diagram.md index c7d0ecd3..53856cd1 100644 --- a/docs/diagram.md +++ b/docs/diagram.md @@ -37,7 +37,6 @@
@@ -260,7 +259,7 @@ const tooltip = action.tooltip if (tooltip) { - tippy(el, { + const tippyInstance = tippy(el, { content: `
${tooltip.title || ''} @@ -277,6 +276,21 @@ maxWidth: 'none', appendTo: document.getElementById('flow-diagram'), offset: [0, 10], + onShow() { + const stepEl = el.closest('.action') + stepEl.classList.add('tooltip-open') + }, + onHide() { + const stepEl = el.closest('.action') + stepEl.classList.remove('tooltip-open') + } + }) + + el.addEventListener('touchend', e => { + e.preventDefault() + e.stopPropagation() + tippy.hideAll() + tippyInstance.show() }) } } @@ -329,10 +343,10 @@ a.action { color: inherit; } - .action.hasHoverState:hover .dot-graphic { + .action.tooltip-open .dot-graphic { background-color: #416EDA; } - .action.hasHoverState:hover .block { + .action.tooltip-open .block { background-color: #416EDA; color: white; } diff --git a/docs/extra.css b/docs/extra.css index e3599627..a971d398 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -3,6 +3,7 @@ body { overflow-wrap: break-word; + overflow-x: hidden; } p {