Polish download action buttons in Classic and Glass Stage

This commit is contained in:
Jonathan Sykes
2026-10-04 02:48:08 +08:00
parent 2042c9b6fc
commit 04b620e3c7
8 changed files with 89 additions and 17 deletions

View File

@@ -0,0 +1,24 @@
/* One action control for the Downloads page and Settings download manager. */
(function(root) {
'use strict';
const paths = {
retry: '<path d="M3 11a9 9 0 1 1 2.6 7M3 3v8h8"/>',
cancel: '<path d="m6 6 12 12M6 18 18 6"/>',
pause: '<path d="M8 5v14M16 5v14"/>',
resume: '<path d="m9 5 10 7-10 7z"/>',
};
function create(doc, action, title) {
if (!paths[action]) throw new Error('Unknown download action');
const label = action[0].toUpperCase() + action.slice(1);
const button = doc.createElement('button'); button.type = 'button';
button.className = `dl-act download-action${action === 'cancel' ? ' danger' : ''}`;
button.setAttribute('aria-label', `${label} ${title}`);
const icon = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
icon.setAttribute('viewBox', '0 0 24 24'); icon.setAttribute('aria-hidden', 'true'); icon.setAttribute('focusable', 'false');
icon.classList.add('download-action-icon'); icon.innerHTML = paths[action];
const text = doc.createElement('span'); text.textContent = label;
button.append(icon, text); return button;
}
const api = { create };
if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.DownloadActions = api;
})(globalThis);