added long post trucation

This commit is contained in:
Nicolas Constant 2020-04-18 00:45:27 -04:00
parent 646888d9f2
commit ed55aa8c75
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
6 changed files with 68 additions and 4 deletions

View File

@ -1 +1,6 @@
<div #content class="content" [class.selectable]="textIsSelectable" innerHTML="{{processedText}}" (click)="selectText($event)"></div> <div class="content-wrapper">
<div #content class="content" [class.selectable]="textIsSelectable" [class.collapsed]="isCollapsed" innerHTML="{{processedText}}" (click)="selectText($event)"></div>
<div class="content-wrapper__expand" [class.content-wrapper__expand--selected]="selected" *ngIf="isCollapsed" (click)="selectText($event)">
<a href (click)="expand()" class="content-wrapper__expand--link" title="expand status">read more <fa-icon class="content-wrapper__expand--link--icon" [icon]="faAngleDown"></fa-icon></a>
</div>
</div>

View File

@ -1,9 +1,52 @@
@import "variables"; @import "variables";
$expand-color: $column-color;
.selectable { .selectable {
cursor: pointer; cursor: pointer;
} }
.collapsed {
max-height: 290px;
overflow: hidden;
}
.content-wrapper {
position: relative;
cursor: pointer;
&__expand {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding-top: 60px;
padding-left: 15px;
background-image: linear-gradient(to bottom, rgba(0,0,0,0), rgba($expand-color ,0.25), rgba($expand-color,0.5), $expand-color, $expand-color);
&--link{
transition: all .2s;
color: #a9b5d8;
color: #c0c8e0;
// text-decoration: underline;
&:hover {
color: white;
}
&--icon {
position: relative;
top: 1px;
}
}
&--selected {
background-image: linear-gradient(to bottom, rgba(0,0,0,0), rgba($selected-status ,0.25), rgba($selected-status,0.5), $selected-status, $selected-status);
}
}
}
//Mastodon styling //Mastodon styling
:host ::ng-deep .content { :host ::ng-deep .content {
// font-size: 14px; // font-size: 14px;

View File

@ -1,16 +1,21 @@
import { Component, OnInit, Input, EventEmitter, Output, Renderer2, ViewChild, ElementRef } from '@angular/core'; import { Component, OnInit, Input, EventEmitter, Output, Renderer2, ViewChild, ElementRef } from '@angular/core';
import { faAngleDown } from "@fortawesome/free-solid-svg-icons";
@Component({ @Component({
selector: 'app-databinded-text', selector: 'app-databinded-text',
templateUrl: './databinded-text.component.html', templateUrl: './databinded-text.component.html',
styleUrls: ['./databinded-text.component.scss'] styleUrls: ['./databinded-text.component.scss']
}) })
export class DatabindedTextComponent implements OnInit { export class DatabindedTextComponent implements OnInit {
faAngleDown = faAngleDown;
private accounts: string[] = []; private accounts: string[] = [];
private hashtags: string[] = []; private hashtags: string[] = [];
private links: string[] = []; private links: string[] = [];
processedText: string; processedText: string;
isCollapsed: boolean = false;
@ViewChild('content') contentElement: ElementRef; @ViewChild('content') contentElement: ElementRef;
@ -19,11 +24,15 @@ export class DatabindedTextComponent implements OnInit {
@Output() textSelected = new EventEmitter(); @Output() textSelected = new EventEmitter();
@Input() textIsSelectable: boolean = true; @Input() textIsSelectable: boolean = true;
@Input() selected: boolean;
@Input('text') @Input('text')
set text(value: string) { set text(value: string) {
// console.warn('text');
// console.warn(value); let parser = new DOMParser();
var dom = parser.parseFromString(value, 'text/html')
this.isCollapsed = [...dom.body.textContent].length > 500;
//console.warn(this.isCollapsed);
this.processedText = ''; this.processedText = '';
@ -73,6 +82,11 @@ export class DatabindedTextComponent implements OnInit {
} }
} }
expand(): boolean {
this.isCollapsed = false;
return false;
}
private processHashtag(section: string) { private processHashtag(section: string) {
let extractedLinkAndNext = section.split('</a>'); let extractedLinkAndNext = section.split('</a>');
let extractedHashtag = extractedLinkAndNext[0].split('#')[1].replace('<span>', '').replace('</span>', ''); let extractedHashtag = extractedLinkAndNext[0].split('#')[1].replace('<span>', '').replace('</span>', '');

View File

@ -97,7 +97,7 @@
<span class="status__content-warning--title">sensitive content</span> <span class="status__content-warning--title">sensitive content</span>
<span innerHTML="{{ contentWarningText }}"></span> <span innerHTML="{{ contentWarningText }}"></span>
</a> </a>
<app-databinded-text class="status__content" *ngIf="!isContentWarned" [text]="statusContent" <app-databinded-text class="status__content" *ngIf="!isContentWarned" [text]="statusContent" [selected]="isSelected"
(accountSelected)="accountSelected($event)" (hashtagSelected)="hashtagSelected($event)" (accountSelected)="accountSelected($event)" (hashtagSelected)="hashtagSelected($event)"
(textSelected)="textSelected()"></app-databinded-text> (textSelected)="textSelected()"></app-databinded-text>

View File

@ -38,6 +38,7 @@
background-color: desaturate(lighten(#0f111a, 5%), 4%); background-color: desaturate(lighten(#0f111a, 5%), 4%);
background-color: #0a0a10; background-color: #0a0a10;
background-color: #1e2734; background-color: #1e2734;
background-color: $selected-status;
} }
.status { .status {

View File

@ -68,6 +68,7 @@ $status-editor-color: #14151a;
$status-editor-footer-background: #535c7e; $status-editor-footer-background: #535c7e;
$status-editor-footer-background: #3e455f; $status-editor-footer-background: #3e455f;
$status-editor-footer-link-color: #e2e2e2; $status-editor-footer-link-color: #e2e2e2;
$selected-status: #1e2734;
$autosuggest-background: #ffffff; $autosuggest-background: #ffffff;
$autosuggest-entry-background: #3e455f; $autosuggest-entry-background: #3e455f;