-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
projects/customizations-example/src/app/message-text/message-text.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<ng-container *ngIf="isQuoted; else regularMessageText"> | ||
<!-- Quoted message are clamped by default, so need there --> | ||
<stream-message-text | ||
[message]="message" | ||
[shouldTranslate]="shouldTranslate" | ||
[isQuoted]="isQuoted" | ||
></stream-message-text> | ||
</ng-container> | ||
<ng-template #regularMessageText> | ||
<div class="message-text" [class.message-text-expanded]="isExpanded" #text> | ||
<stream-message-text | ||
[message]="message" | ||
[shouldTranslate]="shouldTranslate" | ||
[isQuoted]="isQuoted" | ||
></stream-message-text> | ||
</div> | ||
<!-- 5px diff is due to Firefox issue --> | ||
<button | ||
[class.visible]="text.scrollHeight - text.clientHeight > 5 || isExpanded" | ||
(click)="isExpanded = !isExpanded" | ||
> | ||
{{ "Show" + (isExpanded ? " less" : " more") }} | ||
</button> | ||
</ng-template> |
19 changes: 19 additions & 0 deletions
19
projects/customizations-example/src/app/message-text/message-text.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.message-text { | ||
overflow: hidden; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 5; | ||
line-clamp: 5; | ||
-webkit-box-orient: vertical; | ||
} | ||
|
||
.message-text.message-text-expanded { | ||
display: block; | ||
} | ||
|
||
button { | ||
display: none; | ||
|
||
&.visible { | ||
display: block; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
projects/customizations-example/src/app/message-text/message-text.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { MessageResponseBase } from 'stream-chat'; | ||
import { DefaultStreamChatGenerics, StreamMessage } from 'stream-chat-angular'; | ||
|
||
@Component({ | ||
selector: 'app-message-text', | ||
templateUrl: './message-text.component.html', | ||
styleUrls: ['./message-text.component.scss'], | ||
}) | ||
export class MessageTextComponent { | ||
@Input() message: | ||
| StreamMessage<DefaultStreamChatGenerics> | ||
| undefined | ||
| MessageResponseBase<DefaultStreamChatGenerics>; | ||
@Input() isQuoted: boolean = false; | ||
@Input() shouldTranslate: boolean = false; | ||
isExpanded = false; | ||
} |