Skip to content

Instantly share code, notes, and snippets.

View thisiszoaib's full-sized avatar

Zoaib thisiszoaib

View GitHub Profile
<p ellipsis [ngClass]="{ 'line-clamp': !showMore }">
This product was not very satisfactory. I was disappointed with a lot of things. But the biggest was its shoddy packaging. I received damaged goods. Please beware of sellers on this site, not all of them are trusted!
</p>
<p ellipsis [ngClass]="{ 'line-clamp': !showMore }">
This product was not very satisfactory. I was disappointed with a lot of things. But the biggest was its shoddy packaging. I received damaged goods. Please beware of sellers on this site, not all of them are trusted!
</p>
truncated(index: number) {
this.showMoreButton = index === null;
}
<p
#ellipsisRef
ellipsis
(ellipsis-change)="truncated($event)"
[ngClass]="{ 'line-clamp': !showMore }">
This product was not very satisfactory. I was disappointed with a lot of things. But the biggest was its shoddy packaging. I received damaged goods. Please beware of sellers on this site, not all of them are trusted!
</p>
<span class="more"
*ngIf="!showMoreButton"
(click)="showComplete()">
@ViewChild(EllipsisDirective) ellipsisRef: EllipsisDirective;
showComplete() {
if (this.ellipsisRef) {
this.showMore = true;
this.cd.detectChanges();
this.ellipsisRef.applyEllipsis();
}
@thisiszoaib
thisiszoaib / styles.scss
Created August 10, 2020 15:54
Dark mode 1
@import "~@angular/material/theming";
@include mat-core();
$angular-primary: mat-palette($mat-teal, 500, 100, 900);
$angular-accent: mat-palette($mat-pink, A200, A100, A400);
$angular-warn: mat-palette($mat-red);
$angular-default-theme: mat-light-theme(
(
color: (
primary: $angular-primary,
accent: $angular-accent,
@thisiszoaib
thisiszoaib / styles.scss
Created August 10, 2020 15:55
Dark mode 2
$angular-dark-theme: mat-dark-theme(
(
color: (
primary: $angular-primary,
accent: $angular-accent,
warn: $angular-warn,
),
)
);
@thisiszoaib
thisiszoaib / styles.scss
Created August 10, 2020 15:56
Dark mode 2
$angular-dark-theme: mat-dark-theme(
(
color: (
primary: $angular-primary,
accent: $angular-accent,
warn: $angular-warn,
),
)
);
<mat-toolbar color="primary">
Angular Dark Mode
<div class="flex-stretch"></div>
<mat-icon class="mr-8">brightness_5</mat-icon>
<mat-slide-toggle [formControl]="toggleControl" class="mr-8">
</mat-slide-toggle>
<mat-icon>bedtime</mat-icon>
</mat-toolbar>
ngOnInit(): void {
this.toggleControl.valueChanges.subscribe((darkMode) => {
const darkClassName = 'darkMode';
this.className = darkMode ? darkClassName : '';
});
}