From d307a2bedf0ceaec1117572e16c71dc92e72c539 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Fri, 23 Oct 2020 16:49:58 +1100 Subject: [PATCH] additional menu option descriptions on hover --- repo/core/client.js | 2 + repo/core/css/menu.css | 23 +++++++++ repo/core/enhancerMenu.js | 51 ++++++++++++++++--- .../{word-counter => core/icons}/question.svg | 0 repo/core/menu.html | 1 + repo/core/mod.js | 22 +++++++- repo/word-counter/mod.js | 2 +- repo/word-counter/styles.css | 3 +- 8 files changed, 92 insertions(+), 12 deletions(-) rename repo/{word-counter => core/icons}/question.svg (100%) diff --git a/repo/core/client.js b/repo/core/client.js index 2d8d458..d094fea 100644 --- a/repo/core/client.js +++ b/repo/core/client.js @@ -156,8 +156,10 @@ module.exports = (store, __exports) => { '--theme--sidebar', '--theme--overlay', '--theme--dragarea', + '--theme--box-shadow_strong', '--theme--font_sans', '--theme--font_code', + '--theme--font_label-size', '--theme--scrollbar', '--theme--scrollbar-border', '--theme--scrollbar_hover', diff --git a/repo/core/css/menu.css b/repo/core/css/menu.css index 4e05425..d9a6b4a 100644 --- a/repo/core/css/menu.css +++ b/repo/core/css/menu.css @@ -342,6 +342,29 @@ s { margin-bottom: 0.5em; } +svg[data-tooltip] { + height: 1em; + width: 1em; + margin: 0 0 -2px 1px; + color: var(--theme--text_ui_info); +} +#tooltip { + pointer-events: none; + position: absolute; + padding: 0.25em 0.5em 0.5em 0.5em; + margin: 0 1em; + border-radius: 3px; + box-shadow: var(--theme--box-shadow_strong); + border-right-width: 1px; + font-size: calc(var(--theme--font_label-size) * 0.8); + background: var(--theme--interactive_hover); + opacity: 0; + transition: opacity 120ms ease-in; +} +#tooltip.active { + opacity: 1; +} + .toggle *, .input *, .select *, diff --git a/repo/core/enhancerMenu.js b/repo/core/enhancerMenu.js index aacb52e..28750ce 100644 --- a/repo/core/enhancerMenu.js +++ b/repo/core/enhancerMenu.js @@ -271,10 +271,13 @@ window['__start'] = async () => { let text = ''; for (let $node of elem.childNodes) { if ($node.nodeType === 3) text += $node.textContent; - if ($node.nodeType === 1) + if ($node.nodeType === 1) { + if ($node.getAttribute('data-tooltip')) + text += $node.getAttribute('data-tooltip'); text += ['text', 'number'].includes($node.type) ? $node.value : innerText($node); + } } return text; } @@ -387,24 +390,35 @@ window['__start'] = async () => { } const file_icon = await fs.readFile( - path.resolve(`${__dirname}/icons/file.svg`) - ); + path.resolve(`${__dirname}/icons/file.svg`) + ), + question_icon = ( + await fs.readFile(path.resolve(`${__dirname}/icons/question.svg`)) + ).toString(); function createOption(opt, id) { let $opt; + const description = opt.description + ? question_icon.replace( + ' `; break; case 'select': $opt = ` - + @@ -422,7 +438,7 @@ window['__start'] = async () => { break; case 'color': $opt = ` - + `; break; @@ -438,7 +454,7 @@ window['__start'] = async () => { }>