Skip to content

Commit

Permalink
feat(snippet) - add toggle fullscreen on snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
adixchen committed Nov 23, 2023
1 parent d0af1a9 commit 4f6cf70
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
.header-wrapper {
display: flex;
justify-content: space-between;

.clock-wrapper {
font-size: 1.4rem;
margin-left: 1rem;
cursor: pointer;
}

.pinned {
color: red;
}
}

.share-action {
cursor: pointer;
margin-top: 0.3rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div *ngIf="note$ | async as note" class="card" #noteEntry >
<div class="card-body show-hide note-bg note-container">
<div class="note-header">
<div class="header-wrapper">
<div class="title-and-subtitle">
<h5 class="card-title">
<i class="fa fa-sticky-note fa-xs mr-2 anthracite-gray"></i>
Expand Down Expand Up @@ -34,7 +34,7 @@ <h6 class="card-subtitle mb-2 text-muted url-under-title">
</span>
</h6>
</div>
<div>
<div class="cursor-pointer">
<span title="Toggle Fullscreen" (click)="toggleFullScreen(noteEntry)">
<i *ngIf="!isFullScreen" class="fas fa-expand fa-lg"></i>
<i *ngIf="isFullScreen" class="fas fa-compress fa-lg"></i>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.note-header {
display: flex;
justify-content: space-between;
}




Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div #snippetCardBody>
<div *ngIf="inList && viewHeight > 180; else wholeText">
<div *ngIf="inList && viewHeight > 180 && !isFullScreen; else wholeText">
<div [ngClass]="{ more_text: showMoreText, less_text_snippet: !showMoreText }">
<div *ngFor="let codeSnippet of snippet.codeSnippets; let isLast = last">
<p
Expand All @@ -14,7 +14,7 @@
<button
class="btn btn-sm btn-light float-right mr-1"
(click)="toggleFullScreen(codePart)"
placeholder="Click to copy code snippet"
placeholder="Toggle fullscreen"
>
Fullscreen <i class="fas fa-expand"></i>
</button>
Expand Down Expand Up @@ -52,7 +52,7 @@
<app-button-copy-snippet
[codeSnippet]="codeSnippet.code"
></app-button-copy-snippet>
<button
<button *ngIf="!isFullScreen"
class="btn btn-sm btn-light float-right mr-1"
(click)="toggleFullScreen(codePart)"
placeholder="Click to copy code snippet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class SnippetCardBodyComponent
@Input()
inList = false;

@Input()
isFullScreen = true;

show = false; // add one more property
public showMoreText = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div *ngIf="snippet" class="card">
<div *ngIf="snippet" class="card" #snippetEntry>
<div class="card-body show-hide">
<div class="header-wrapper">
<div class="titles">
Expand Down Expand Up @@ -78,15 +78,24 @@ <h6 class="card-subtitle mb-2 text-muted url-under-title">
</span>
</h6>
</div>
<div class="cursor-pointer">
<span title="Toggle Fullscreen" (click)="toggleFullScreen(snippetEntry)">
<i *ngIf="!isFullScreen" class="fas fa-expand fa-lg" title="Toggle fullscreen"></i>
<i *ngIf="isFullScreen" class="fas fa-compress fa-lg" title="Toggle fullscreen"></i>
</span>
</div>
</div>

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

<app-snippet-card-body
[snippet]="snippet"
[queryText]="queryText"
[inList]="inlist"
></app-snippet-card-body>
<div [ngClass]="{'scrollable-div-fullscreen': isFullScreen}">
<app-snippet-card-body
[snippet]="snippet"
[queryText]="queryText"
[inList]="inlist"
[isFullScreen]="isFullScreen"
></app-snippet-card-body>
</div>
</div>

<ng-container
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Component,
HostListener,
Input,
OnChanges,
OnInit,
Expand All @@ -18,6 +19,7 @@ import { environment } from '../../../environments/environment';
import { Observable } from 'rxjs';
import { ScrollStrategy, ScrollStrategyOptions } from '@angular/cdk/overlay';
import { SnippetSocialShareDialogComponent } from '../dialog/snippet-social-share-dialog/snippet-social-share-dialog.component';
import * as screenfull from 'screenfull';

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

scrollStrategy: ScrollStrategy;

isFullScreen = false;

constructor(
public loginDialog: MatDialog,
private snippetShareDialog: MatDialog,
Expand Down Expand Up @@ -148,4 +152,16 @@ export class SnippetDetailsComponent implements OnInit, OnChanges {
dialogConfig
);
}

toggleFullScreen(part: HTMLElement) {
if (screenfull.isEnabled) {
this.isFullScreen = !this.isFullScreen;
screenfull.toggle(part);
}
}

@HostListener('document:fullscreenchange', ['$event'])
fullscreenChangeHandler(event: Event) {
this.isFullScreen = !!document.fullscreenElement;
}
}
20 changes: 20 additions & 0 deletions apps/codever-ui/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,23 @@ label {
overflow-y: auto;
max-height: calc(100vh - 150px);
}

.cursor-pointer {
cursor: pointer;
}

//used to wrap titles and buttons in bookmarks, snippets and notes
.header-wrapper {
display: flex;
justify-content: space-between;

.clock-wrapper {
font-size: 1.4rem;
margin-left: 1rem;
cursor: pointer;
}

.pinned {
color: red;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Codever",
"version": "8.11.0",
"version": "8.12.0",
"description": "Codever - bookmarks, snippets and notes manager for developers & co",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down

0 comments on commit 4f6cf70

Please sign in to comment.