coherence-beacon-modal.ts
1 import { App, Modal } from 'obsidian'; 2 import { CoherenceBeacon } from '../services/coherence-beacon-service'; 3 4 export class CoherenceBeaconModal extends Modal { 5 private beacon: CoherenceBeacon; 6 private onAccept: () => void; 7 private onReject: () => void; 8 9 constructor( 10 app: App, 11 beacon: CoherenceBeacon, 12 onAccept: () => void, 13 onReject: () => void 14 ) { 15 super(app); 16 this.beacon = beacon; 17 this.onAccept = onAccept; 18 this.onReject = onReject; 19 } 20 21 onOpen() { 22 const { contentEl } = this; 23 24 contentEl.empty(); 25 contentEl.addClass('coherence-beacon-modal'); 26 27 // Title 28 contentEl.createEl('h2', { text: '🌟 New Supermodule Detected' }); 29 30 // Description 31 const description = contentEl.createDiv({ cls: 'beacon-description' }); 32 description.createEl('p', { 33 text: `This DreamNode is now referenced by:` 34 }); 35 36 // Supermodule info 37 const infoBox = description.createDiv({ cls: 'beacon-info' }); 38 infoBox.createEl('div', { 39 text: `→ ${this.beacon.title}`, 40 cls: 'beacon-title' 41 }); 42 infoBox.createEl('div', { 43 text: this.beacon.radicleId, 44 cls: 'beacon-radicle-id' 45 }); 46 47 // Question 48 description.createEl('p', { 49 text: `Would you like to clone ${this.beacon.title} to your vault?`, 50 cls: 'beacon-question' 51 }); 52 53 // Explanation 54 const explanation = description.createDiv({ cls: 'beacon-explanation' }); 55 explanation.createEl('p', { 56 text: `Accepting will:`, 57 cls: 'explanation-header' 58 }); 59 const acceptList = explanation.createEl('ul'); 60 acceptList.createEl('li', { text: 'Clone the supermodule repository to your vault' }); 61 acceptList.createEl('li', { text: 'Update metadata to track the relationship' }); 62 acceptList.createEl('li', { text: 'Allow you to explore connected ideas' }); 63 64 explanation.createEl('p', { 65 text: `Rejecting will:`, 66 cls: 'explanation-header' 67 }); 68 const rejectList = explanation.createEl('ul'); 69 rejectList.createEl('li', { text: 'Keep your current perspective unchanged' }); 70 rejectList.createEl('li', { text: 'Ignore this supermodule connection' }); 71 72 // Buttons 73 const buttonContainer = contentEl.createDiv({ cls: 'beacon-buttons' }); 74 75 const acceptButton = buttonContainer.createEl('button', { 76 text: 'Clone', 77 cls: 'mod-cta' 78 }); 79 acceptButton.addEventListener('click', () => { 80 this.close(); 81 this.onAccept(); 82 }); 83 84 const rejectButton = buttonContainer.createEl('button', { 85 text: 'Not Now' 86 }); 87 rejectButton.addEventListener('click', () => { 88 this.close(); 89 this.onReject(); 90 }); 91 } 92 93 onClose() { 94 const { contentEl } = this; 95 contentEl.empty(); 96 } 97 }