Skip to content

Commit f1826a9

Browse files
committed
(#73) Introduce TwitchPlayer into CurrentEvent
1 parent b99d701 commit f1826a9

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

scss/main.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ body {
7979
}
8080
}
8181
}
82+
83+
.player {
84+
padding-top: 20px;
85+
width: $page_width * 0.75;
86+
height: $page_width * 0.75 * (9 / 16);
87+
}
8288
}
8389

8490
.event.past {

ts/CurrentEvent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as moment from 'moment';
44
import ComponentsArray from './ComponentsArray';
55
import Countdown from './Countdown';
66
import UiComponent from './UiComponent';
7+
import TwitchPlayer from './TwitchPlayer';
78

89
export default class CurrentEvent implements UiComponent {
910
constructor(private _event: dto.Event) {
@@ -46,7 +47,10 @@ export default class CurrentEvent implements UiComponent {
4647
new html.Div(
4748
new html.Markdown(`${this._event.description}`),
4849
{"class": "description markdown"}
49-
)
50+
),
51+
// TODO: the preview twitch channel in CurrentEvent is hardcoded
52+
// It should be taken from this._event.channel
53+
new TwitchPlayer("tsoding")
5054
]),
5155
{
5256
"id": `_${this._event.datetime.utc().unix()}`,

ts/TwitchPlayer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import UiComponent from './UiComponent';
2+
import * as html from './html';
3+
4+
export default class TwitchPlayer implements UiComponent {
5+
constructor(private _userName: string) {
6+
}
7+
8+
appendTo(entry: HTMLElement | null): void {
9+
new html.Tag(
10+
"iframe",
11+
new html.Empty(),
12+
{"src": `https://player.twitch.tv/?channel=${this._userName}&muted=true`,
13+
"allowfullscreen": "true",
14+
"class": "player"}
15+
).appendTo(entry);
16+
}
17+
}

0 commit comments

Comments
 (0)