From 5482f4a8e2fb726e8a97a6f8d3690fb9d280c45f Mon Sep 17 00:00:00 2001 From: SandObserver <260779319+SandObserver@users.noreply.github.com> Date: Sat, 3 Oct 2026 16:10:00 -0400 Subject: [PATCH] Docs: show the template's Show total switch reaching data.js --- public/widgets/mywidget/data.js | 4 +-- public/widgets/mywidget/demo.js | 2 +- public/widgets/mywidget/index.html | 25 +++++++++++++------ .../docs/docs/create-a-widget/checklist.md | 2 ++ .../docs/docs/create-a-widget/index.mdx | 13 ++++++---- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/public/widgets/mywidget/data.js b/public/widgets/mywidget/data.js index 8fea622..d52c208 100644 --- a/public/widgets/mywidget/data.js +++ b/public/widgets/mywidget/data.js @@ -1,5 +1,5 @@ module.exports = async function (ctx) { - const { url, apiKey } = ctx.config; + const { url, apiKey, showTotal } = ctx.config; if (!url) ctx.fail('Not configured', { kind: ctx.KIND.INVALID }); const base = ctx.normalizeBase(url); @@ -13,6 +13,6 @@ module.exports = async function (ctx) { return { items: r.data.items.slice(0, 10).map(i => ({ name: i.name })), - total: r.data.total ?? r.data.items.length, + total: showTotal === false ? null : (r.data.total ?? r.data.items.length), }; }; diff --git a/public/widgets/mywidget/demo.js b/public/widgets/mywidget/demo.js index d3d4fdc..d349b0f 100644 --- a/public/widgets/mywidget/demo.js +++ b/public/widgets/mywidget/demo.js @@ -10,7 +10,7 @@ module.exports = function (ctx) { const { wave, round } = ctx.demo; return { items: [{ name: 'First item' }, { name: 'Second item' }], - total: Math.round(wave(600, 8, 20)), + total: ctx.config.showTotal === false ? null : Math.round(wave(600, 8, 20)), ratio: round(wave(300, 0, 1), 2), }; }; diff --git a/public/widgets/mywidget/index.html b/public/widgets/mywidget/index.html index 024a561..d82f8c1 100644 --- a/public/widgets/mywidget/index.html +++ b/public/widgets/mywidget/index.html @@ -13,6 +13,7 @@ align-items:center; justify-content:center; gap:4px } .n { font-size:34px; font-weight:600; letter-spacing:-0.5px } .l { font-size:12px; color:#8e8e93 } + .i { max-width:100%; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis } html[data-theme="light"] body { color:#1c1c1e } html[data-theme="light"] .l { color:#6c6c70 } @@ -20,20 +21,28 @@