mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-21 02:45:12 +00:00
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:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user