-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from NicolasConstant/develop
Merge for 0.3
- Loading branch information
Showing
25 changed files
with
622 additions
and
105 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
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
12 changes: 12 additions & 0 deletions
12
src/app/components/media-viewer/media-viewer.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,12 @@ | ||
<div class="media-viewer-canvas" (click)="close()"> | ||
<button class="media-viewer-canvas__close" title="close"> | ||
<fa-icon [icon]="faTimes"></fa-icon> | ||
</button> | ||
<img class="media-viewer-canvas__image" *ngIf="imageUrl" src="{{imageUrl}}" (click)="blockClick($event)"/> | ||
<video class="media-viewer-canvas__image" *ngIf="gifvUrl" role="application" loop autoplay (click)="blockClick($event)"> | ||
<source src="{{ gifvUrl }}" type="video/mp4"> | ||
</video> | ||
<video class="media-viewer-canvas__image" *ngIf="videoUrl" role="application" loop controls="controls" (click)="blockClick($event)"> | ||
<source src="{{ videoUrl }}" type="video/mp4"> | ||
</video> | ||
</div> |
30 changes: 30 additions & 0 deletions
30
src/app/components/media-viewer/media-viewer.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,30 @@ | ||
@import "variables"; | ||
@import "mixins"; | ||
|
||
.media-viewer-canvas { | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.8); | ||
overflow: hidden; | ||
position: relative; | ||
|
||
&__close { | ||
@include clearButton; | ||
position: absolute; | ||
top: 15px; | ||
right: 20px; | ||
font-size: 24px; | ||
color: $font-link-primary; | ||
&:hover { | ||
color: $font-link-primary-hover; | ||
} | ||
} | ||
|
||
&__image { | ||
max-width: 95%; | ||
max-height: calc(100% - 120px); | ||
margin-top: 50vh; | ||
margin-left: 50vw; | ||
transform: translate(-50%, -50%); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/components/media-viewer/media-viewer.component.spec.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MediaViewerComponent } from './media-viewer.component'; | ||
|
||
xdescribe('MediaViewerComponent', () => { | ||
let component: MediaViewerComponent; | ||
let fixture: ComponentFixture<MediaViewerComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ MediaViewerComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MediaViewerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,61 @@ | ||
import { Component, OnInit, Input, Output } from '@angular/core'; | ||
import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons"; | ||
import { Subject } from 'rxjs'; | ||
|
||
import { OpenMediaEvent } from '../../models/common.model'; | ||
import { Attachment } from '../../services/models/mastodon.interfaces'; | ||
|
||
@Component({ | ||
selector: 'app-media-viewer', | ||
templateUrl: './media-viewer.component.html', | ||
styleUrls: ['./media-viewer.component.scss'] | ||
}) | ||
export class MediaViewerComponent implements OnInit { | ||
private _mediaEvent: OpenMediaEvent; | ||
|
||
faChevronLeft = faChevronLeft; | ||
faChevronRight = faChevronRight; | ||
faTimes = faTimes; | ||
|
||
imageUrl: string; | ||
gifvUrl: string; | ||
videoUrl: string; | ||
|
||
@Input('openedMediaEvent') | ||
set openedMediaEvent(value: OpenMediaEvent) { | ||
this._mediaEvent = value; | ||
|
||
const attachment = value.attachments[value.selectedIndex]; | ||
this.loadAttachment(attachment); | ||
} | ||
get openedMediaEvent(): OpenMediaEvent { | ||
return this._mediaEvent; | ||
} | ||
|
||
@Output() closeSubject = new Subject<boolean>(); | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
private loadAttachment(attachment: Attachment) { | ||
if (attachment.type === 'image') { | ||
this.imageUrl = attachment.url; | ||
} else if (attachment.type === 'gifv'){ | ||
this.gifvUrl = attachment.url; | ||
} else if (attachment.type === 'video'){ | ||
this.videoUrl = attachment.url; | ||
} | ||
} | ||
|
||
close(): boolean { | ||
this.closeSubject.next(true); | ||
return false; | ||
} | ||
|
||
blockClick(event: any): boolean{ | ||
event.stopPropagation(); | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.