feat: add download and share buttons to list view and modal

- Add Download button to download file as .md file
- Add Share button to copy GitHub link to clipboard
- Both buttons appear in modal header and list view actions
- Use icon-only buttons in list view for cleaner UI
This commit is contained in:
Aaron Powell
2026-01-29 09:44:31 +11:00
parent 009c6c72f8
commit d450d7d3d5
7 changed files with 114 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
* Modal functionality for file viewing
*/
import { fetchFileContent, getVSCodeInstallUrl, copyToClipboard, showToast } from './utils';
import { fetchFileContent, getVSCodeInstallUrl, copyToClipboard, showToast, downloadFile, shareFile } from './utils';
// Modal state
let currentFilePath: string | null = null;
@@ -16,6 +16,8 @@ export function setupModal(): void {
const modal = document.getElementById('file-modal');
const closeBtn = document.getElementById('close-modal');
const copyBtn = document.getElementById('copy-btn');
const downloadBtn = document.getElementById('download-btn');
const shareBtn = document.getElementById('share-btn');
if (!modal) return;
@@ -38,6 +40,20 @@ export function setupModal(): void {
}
});
downloadBtn?.addEventListener('click', async () => {
if (currentFilePath) {
const success = await downloadFile(currentFilePath);
showToast(success ? 'Download started!' : 'Download failed', success ? 'success' : 'error');
}
});
shareBtn?.addEventListener('click', async () => {
if (currentFilePath) {
const success = await shareFile(currentFilePath);
showToast(success ? 'Link copied to clipboard!' : 'Failed to copy link', success ? 'success' : 'error');
}
});
// Setup install dropdown toggle
setupInstallDropdown('install-dropdown');
}