From 3a47bc69d97db558862fba7bf394888682ca987b Mon Sep 17 00:00:00 2001 From: jelveh Date: Thu, 2 Jan 2025 17:14:08 -0800 Subject: [PATCH] Add tooltips to vague icons in Dev Center --- src/dev-center/index.html | 4 ++++ src/dev-center/js/dev-center.js | 41 +++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/dev-center/index.html b/src/dev-center/index.html index a3087e969..df732a9ba 100644 --- a/src/dev-center/index.html +++ b/src/dev-center/index.html @@ -19,6 +19,10 @@ + + + + diff --git a/src/dev-center/js/dev-center.js b/src/dev-center/js/dev-center.js index 43c390039..441133795 100644 --- a/src/dev-center/js/dev-center.js +++ b/src/dev-center/js/dev-center.js @@ -53,7 +53,9 @@ const deploying_spinner = ``; const drop_area_placeholder = `

Drop your app folder and files here to deploy.

HTML, JS, CSS, ...

`; const index_missing_error = `Please upload an 'index.html' file or if you're uploading a directory, make sure it contains an 'index.html' file at its root.`; -const lock_svg = ''; +const lock_svg = ` `; +const lock_svg_tippy = ` `; + const copy_svg = ` `; // authUsername @@ -162,6 +164,7 @@ $(document).ready(function () { }); count_apps(); sort_apps(); + activate_tippy(); } else { $('#no-apps-notice').show(); } @@ -202,6 +205,7 @@ function refresh_app_list(show_loading = false) { $('#no-apps-notice').show(); $('#app-list').hide() } + activate_tippy(); }) }, show_loading ? 1000 : 0); } @@ -337,6 +341,7 @@ async function create_app(title, source_path = null, items = null) { } else if (items) { deploy(app, items); } + activate_tippy(); }, (Date.now() - start_ts) > 2000 ? 1 : 2000 - (Date.now() - start_ts)); }) }).catch(async (err) => { @@ -493,7 +498,7 @@ function generate_edit_app_section(app) {
-

${html_encode(app.title)}${app.metadata?.locked ? lock_svg : ''}

+

${html_encode(app.title)}${app.metadata?.locked ? lock_svg_tippy : ''}

Open @@ -609,8 +614,8 @@ function generate_edit_app_section(app) {

Misc

- -

When locked, the app cannot be deleted. This is useful to prevent accidental deletion of important apps.

+ +

When enabled, the app cannot be deleted. This is useful for preventing accidental deletion of important apps.

@@ -1066,6 +1071,8 @@ async function edit_app_section(cur_app_name, tab = 'deploy') { // Focus on the first input $('#edit-app-title').focus(); + + activate_tippy(); } $('.jip-submit-btn').on('click', async function (e) { @@ -1438,6 +1445,7 @@ $(document).on('click', '.back-to-main-btn', function (e) { }); count_apps(); sort_apps(); + activate_tippy(); } else $('#no-apps-notice').show(); }) @@ -1563,7 +1571,7 @@ function generate_app_card(app) { // Info h += `
`; // Title - h += `

${html_encode(app.title)}${app.metadata?.locked ? lock_svg : ''}

`; + h += `

${html_encode(app.title)}${app.metadata?.locked ? lock_svg_tippy : ''}

`; // // Category // if (app.metadata?.category) { // const category = APP_CATEGORIES.find(c => c.id === app.metadata.category); @@ -1615,13 +1623,13 @@ function generate_app_card(app) { h += ``; h += `
`; // "Approved for listing" - h += ``; + h += ``; // "Approved for opening items" - h += ``; + h += ``; // "Approved for incentive program" - h += ``; + h += ``; h += `
`; h += ``; h += ``; @@ -2428,6 +2436,7 @@ $('.refresh-app-list').on('click', function (e) { // preserve sort sort_apps(); + activate_tippy(); puter.ui.hideSpinner(); }, 1000); @@ -2939,4 +2948,18 @@ async function render_analytics(period){ $(document).on('click', '.stats-cell', function(e) { edit_app_section($(this).attr('data-app-name'), 'analytics'); -}) \ No newline at end of file +}) + +function activate_tippy(){ + tippy('.tippy', { + content(reference) { + return reference.getAttribute('title'); + }, + onMount(instance) { + // Remove the default title to prevent double tooltips + instance.reference.removeAttribute('title'); + }, + placement: 'top', + arrow: true, + }); +} \ No newline at end of file