diff --git a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.html b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.html index 75f5668bd4..178dbd06f9 100644 --- a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.html +++ b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.html @@ -50,7 +50,7 @@ [emojiSize]="20" [totalFrequentLines]="2" [darkMode]="false" - [style]="{ width: '506px' }" + [style]="{ width: emojiPickerWidth }" [showPreview]="false" *ngIf="isEmojiPickerOpen" (emojiClick)="onEmojiClick($event)" diff --git a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss index d6d272aecd..61b597a5ef 100644 --- a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss +++ b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss @@ -18,7 +18,7 @@ font-size: 18px; position: absolute; top: 0; - right: -15px; + right: -10px; cursor: pointer; color: var(--tertiary-dark-grey); } diff --git a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts index 7dfb0532c8..eb70b4868e 100644 --- a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts +++ b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts @@ -38,7 +38,13 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange isImageUploaderOpen = false; showImageControls = false; isEmojiPickerOpen = false; + emojiPickerWidth = '506px'; uploadedImage: { url: string; file: File }[] = []; + private widthMap = new Map([ + [0, '100%'], + [641, '475px'], + [1025, '506px'] + ]); content: FormControl = new FormControl('', [Validators.required, this.innerHtmlMaxLengthValidator(8000)]); suggestedUsers: TaggedUser[] = []; @@ -163,6 +169,23 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange toggleEmojiPickerVisibility(): void { this.isEmojiPickerOpen = !this.isEmojiPickerOpen; this.isImageUploaderOpen = false; + + if (this.isEmojiPickerOpen) { + this.updateEmojiPickerWidth(); + window.addEventListener('resize', this.updateEmojiPickerWidth.bind(this)); + } else { + window.removeEventListener('resize', this.updateEmojiPickerWidth.bind(this)); + } + } + + updateEmojiPickerWidth(): void { + const screenWidth = window.innerWidth; + + for (const [breakpoint, width] of this.widthMap) { + if (screenWidth >= breakpoint) { + this.emojiPickerWidth = width; + } + } } onEmojiClick(event: EmojiEvent): void { diff --git a/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts b/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts index 229b29fe83..28ea2963b4 100644 --- a/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts +++ b/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts @@ -42,10 +42,17 @@ describe('NotificContentReplaceDirective', () => { })); it('should display multiple user replacements', () => { - component.notification = { ...notification, ...{ bodyText: '{user1} and {user2} liked your post' } }; + component.notification = { + ...notification, + ...{ bodyText: '{user1} and {user2} liked your post' } + }; fixture.detectChanges(); expect(paragrEl.textContent).toBe('testUser1 and testUser2 liked your post'); - expect(paragrEl.innerHTML).toBe(`testUser1 and testUser2 liked your post`); + expect(paragrEl.innerHTML).toBe( + `testUser1` + + ` and testUser2` + + ` liked your post` + ); }); it('should leave placeholders as is if replacements are missing', () => { @@ -57,11 +64,19 @@ describe('NotificContentReplaceDirective', () => { it('should handle multiple users in a single string replacement', () => { component.notification = { ...notification, - ...{ bodyText: '{user1},{user2} interacted with your post', actionUserId: [2, 3], actionUserText: ['testUser1', 'testUser2'] } + ...{ + bodyText: '{user1},{user2} interacted with your post', + actionUserId: [2, 3], + actionUserText: ['testUser1', 'testUser2'] + } }; fixture.detectChanges(); expect(paragrEl.textContent).toBe('testUser1,testUser2 interacted with your post'); - expect(paragrEl.innerHTML).toBe('testUser1,testUser2 interacted with your post'); + expect(paragrEl.innerHTML).toBe( + `testUser1,` + + `testUser2` + + ` interacted with your post` + ); }); it('should use body text when there are no property to set', () => { @@ -74,16 +89,24 @@ describe('NotificContentReplaceDirective', () => { component.notification = { ...notification, ...{ bodyText: 'commented event {message}' } }; fixture.detectChanges(); expect(paragrEl.textContent).toBe('commented event test message'); - expect(paragrEl.innerHTML).toBe('commented event test message'); + expect(paragrEl.innerHTML).toBe('commented event test message'); }); it('should add property value to the content and anchor tag', () => { component.notification = { ...notification, - ...{ bodyText: '{user1},{user2} commented event {message}', actionUserId: [2, 3], actionUserText: ['testUser1', 'testUser2'] } + ...{ + bodyText: '{user1},{user2} commented event {message}', + actionUserId: [2, 3], + actionUserText: ['testUser1', 'testUser2'] + } }; fixture.detectChanges(); expect(paragrEl.textContent).toBe('testUser1,testUser2 commented event test message'); - expect(paragrEl.innerHTML).toBe('testUser1,testUser2 commented event test message'); + expect(paragrEl.innerHTML).toBe( + `testUser1,` + + `testUser2` + + ` commented event test message` + ); }); }); diff --git a/src/app/main/component/user/directives/notific-content-replace.directive.ts b/src/app/main/component/user/directives/notific-content-replace.directive.ts index a3c2e7e362..9deea6718c 100644 --- a/src/app/main/component/user/directives/notific-content-replace.directive.ts +++ b/src/app/main/component/user/directives/notific-content-replace.directive.ts @@ -60,14 +60,16 @@ export class NotificContentReplaceDirective implements OnChanges { text: string, attributes: Record | null ): string { + const style = 'style="font-family: var(--tertiary-font);"'; + if (!attributes) { - return content.replace(`{${placeholder}}`, text); + return content.replace(`{${placeholder}}`, `${text}`); } const attrString = Object.entries(attributes) .map(([key, value]) => `data-${key}="${value}"`) .join(' '); - return content.replace(`{${placeholder}}`, `${text}`); + return content.replace(`{${placeholder}}`, `${text}`); } }