Skip to content

Commit 4f6cf70

Browse files
committed
feat(snippet) - add toggle fullscreen on snippets
1 parent d0af1a9 commit 4f6cf70

9 files changed

Lines changed: 61 additions & 31 deletions

File tree

apps/codever-ui/src/app/shared/bookmark-list-element/bookmark-list-element.component.scss

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
.header-wrapper {
2-
display: flex;
3-
justify-content: space-between;
4-
5-
.clock-wrapper {
6-
font-size: 1.4rem;
7-
margin-left: 1rem;
8-
cursor: pointer;
9-
}
10-
11-
.pinned {
12-
color: red;
13-
}
14-
}
15-
161
.share-action {
172
cursor: pointer;
183
margin-top: 0.3rem;

apps/codever-ui/src/app/shared/note-details/note-details.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div *ngIf="note$ | async as note" class="card" #noteEntry >
22
<div class="card-body show-hide note-bg note-container">
3-
<div class="note-header">
3+
<div class="header-wrapper">
44
<div class="title-and-subtitle">
55
<h5 class="card-title">
66
<i class="fa fa-sticky-note fa-xs mr-2 anthracite-gray"></i>
@@ -34,7 +34,7 @@ <h6 class="card-subtitle mb-2 text-muted url-under-title">
3434
</span>
3535
</h6>
3636
</div>
37-
<div>
37+
<div class="cursor-pointer">
3838
<span title="Toggle Fullscreen" (click)="toggleFullScreen(noteEntry)">
3939
<i *ngIf="!isFullScreen" class="fas fa-expand fa-lg"></i>
4040
<i *ngIf="isFullScreen" class="fas fa-compress fa-lg"></i>
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
.note-header {
2-
display: flex;
3-
justify-content: space-between;
4-
}
1+
52

63

74

apps/codever-ui/src/app/shared/snippet-details/snippet-card-body/snippet-card-body.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div #snippetCardBody>
2-
<div *ngIf="inList && viewHeight > 180; else wholeText">
2+
<div *ngIf="inList && viewHeight > 180 && !isFullScreen; else wholeText">
33
<div [ngClass]="{ more_text: showMoreText, less_text_snippet: !showMoreText }">
44
<div *ngFor="let codeSnippet of snippet.codeSnippets; let isLast = last">
55
<p
@@ -14,7 +14,7 @@
1414
<button
1515
class="btn btn-sm btn-light float-right mr-1"
1616
(click)="toggleFullScreen(codePart)"
17-
placeholder="Click to copy code snippet"
17+
placeholder="Toggle fullscreen"
1818
>
1919
Fullscreen <i class="fas fa-expand"></i>
2020
</button>
@@ -52,7 +52,7 @@
5252
<app-button-copy-snippet
5353
[codeSnippet]="codeSnippet.code"
5454
></app-button-copy-snippet>
55-
<button
55+
<button *ngIf="!isFullScreen"
5656
class="btn btn-sm btn-light float-right mr-1"
5757
(click)="toggleFullScreen(codePart)"
5858
placeholder="Click to copy code snippet"

apps/codever-ui/src/app/shared/snippet-details/snippet-card-body/snippet-card-body.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export class SnippetCardBodyComponent
2626
@Input()
2727
inList = false;
2828

29+
@Input()
30+
isFullScreen = true;
31+
2932
show = false; // add one more property
3033
public showMoreText = false;
3134

apps/codever-ui/src/app/shared/snippet-details/snippet-details.component.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div *ngIf="snippet" class="card">
1+
<div *ngIf="snippet" class="card" #snippetEntry>
22
<div class="card-body show-hide">
33
<div class="header-wrapper">
44
<div class="titles">
@@ -78,15 +78,24 @@ <h6 class="card-subtitle mb-2 text-muted url-under-title">
7878
</span>
7979
</h6>
8080
</div>
81+
<div class="cursor-pointer">
82+
<span title="Toggle Fullscreen" (click)="toggleFullScreen(snippetEntry)">
83+
<i *ngIf="!isFullScreen" class="fas fa-expand fa-lg" title="Toggle fullscreen"></i>
84+
<i *ngIf="isFullScreen" class="fas fa-compress fa-lg" title="Toggle fullscreen"></i>
85+
</span>
86+
</div>
8187
</div>
8288

8389
<hr class="title-content-separator"/>
8490

85-
<app-snippet-card-body
86-
[snippet]="snippet"
87-
[queryText]="queryText"
88-
[inList]="inlist"
89-
></app-snippet-card-body>
91+
<div [ngClass]="{'scrollable-div-fullscreen': isFullScreen}">
92+
<app-snippet-card-body
93+
[snippet]="snippet"
94+
[queryText]="queryText"
95+
[inList]="inlist"
96+
[isFullScreen]="isFullScreen"
97+
></app-snippet-card-body>
98+
</div>
9099
</div>
91100

92101
<ng-container

apps/codever-ui/src/app/shared/snippet-details/snippet-details.component.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Component,
3+
HostListener,
34
Input,
45
OnChanges,
56
OnInit,
@@ -18,6 +19,7 @@ import { environment } from '../../../environments/environment';
1819
import { Observable } from 'rxjs';
1920
import { ScrollStrategy, ScrollStrategyOptions } from '@angular/cdk/overlay';
2021
import { SnippetSocialShareDialogComponent } from '../dialog/snippet-social-share-dialog/snippet-social-share-dialog.component';
22+
import * as screenfull from 'screenfull';
2123

2224
@Component({
2325
selector: 'app-snippet-details',
@@ -41,6 +43,8 @@ export class SnippetDetailsComponent implements OnInit, OnChanges {
4143

4244
scrollStrategy: ScrollStrategy;
4345

46+
isFullScreen = false;
47+
4448
constructor(
4549
public loginDialog: MatDialog,
4650
private snippetShareDialog: MatDialog,
@@ -148,4 +152,16 @@ export class SnippetDetailsComponent implements OnInit, OnChanges {
148152
dialogConfig
149153
);
150154
}
155+
156+
toggleFullScreen(part: HTMLElement) {
157+
if (screenfull.isEnabled) {
158+
this.isFullScreen = !this.isFullScreen;
159+
screenfull.toggle(part);
160+
}
161+
}
162+
163+
@HostListener('document:fullscreenchange', ['$event'])
164+
fullscreenChangeHandler(event: Event) {
165+
this.isFullScreen = !!document.fullscreenElement;
166+
}
151167
}

apps/codever-ui/src/styles.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,23 @@ label {
291291
overflow-y: auto;
292292
max-height: calc(100vh - 150px);
293293
}
294+
295+
.cursor-pointer {
296+
cursor: pointer;
297+
}
298+
299+
//used to wrap titles and buttons in bookmarks, snippets and notes
300+
.header-wrapper {
301+
display: flex;
302+
justify-content: space-between;
303+
304+
.clock-wrapper {
305+
font-size: 1.4rem;
306+
margin-left: 1rem;
307+
cursor: pointer;
308+
}
309+
310+
.pinned {
311+
color: red;
312+
}
313+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Codever",
3-
"version": "8.11.0",
3+
"version": "8.12.0",
44
"description": "Codever - bookmarks, snippets and notes manager for developers & co",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1",

0 commit comments

Comments
 (0)