From 6e400513cf03a7a32121a0133c7bdeedf09a8e7d Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 20 Aug 2017 09:02:05 -0500 Subject: [PATCH] relocate study static video --- public/stylesheets/study.css | 4 ++-- ui/analyse/src/study/studyView.ts | 16 ++-------------- ui/analyse/src/view.ts | 15 +++++++++++++-- ui/analyse/tsconfig.json | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/public/stylesheets/study.css b/public/stylesheets/study.css index 3c94189676..ec0dd57b18 100644 --- a/public/stylesheets/study.css +++ b/public/stylesheets/study.css @@ -725,7 +725,7 @@ div.undertable_inner { .board_left.no_chat .study_box .list { max-height: 500px; } -div.side_box.embed { +div.chapter_embed { line-height: 0; - border: 0; + margin-bottom: 5px; } diff --git a/ui/analyse/src/study/studyView.ts b/ui/analyse/src/study/studyView.ts index 22ed4c0fda..9af4d9e8ec 100644 --- a/ui/analyse/src/study/studyView.ts +++ b/ui/analyse/src/study/studyView.ts @@ -1,6 +1,6 @@ import { h } from 'snabbdom' import { VNode } from 'snabbdom/vnode' -import { bind, plural, dataIcon, toYouTubeEmbed, innerHTML } from '../util'; +import { bind, plural, dataIcon } from '../util'; import { view as memberView } from './studyMembers'; import { view as chapterView } from './studyChapters'; import { view as chapterNewFormView } from './chapterNewForm'; @@ -135,22 +135,10 @@ export function main(ctrl: StudyCtrl): VNode { if (activeTab === 'members') panel = memberView(ctrl); else if (activeTab === 'chapters') panel = chapterView(ctrl); - const embedUrl = ctrl.data.chapter.embed; - - const sideBox = h('div.side_box.study_box', [ + return h('div.side_box.study_box', [ tabs, panel ]); - - return embedUrl ? h('div', [ - sideBox, - h('div.side_box.embed', { - hook: innerHTML(embedUrl, t => { - const html = toYouTubeEmbed(t, 140); - return html || (ctrl.members.canContribute() ? 'Invalid YouTube URL' : '') - }) - }) - ]) : sideBox; } export function contextMenu(ctrl: StudyCtrl, path: Tree.Path, node: Tree.Node): VNode[] { diff --git a/ui/analyse/src/view.ts b/ui/analyse/src/view.ts index 29039e7e20..b5b363e78f 100644 --- a/ui/analyse/src/view.ts +++ b/ui/analyse/src/view.ts @@ -2,7 +2,7 @@ import { h } from 'snabbdom' import { VNode } from 'snabbdom/vnode' import * as chessground from './ground'; -import { synthetic, bind, dataIcon, iconTag, spinner } from './util'; +import { synthetic, bind, dataIcon, iconTag, spinner, toYouTubeEmbed, innerHTML } from './util'; import { game, router, view as gameView } from 'game'; import { path as treePath } from 'tree'; import treeView from './treeView'; @@ -239,6 +239,16 @@ function renderChapterName(ctrl: AnalyseCtrl) { if (ctrl.embed && ctrl.study) return h('div.chapter_name', ctrl.study.currentChapter().name); } +export function chapterEmbed(ctrl: AnalyseCtrl): VNode | undefined { + const embed = ctrl.study && ctrl.study.data.chapter.embed; + if (embed) return h('div.chapter_embed', { + hook: innerHTML(embed, t => { + const html = toYouTubeEmbed(t, 157); + return html || (ctrl.study!.members.canContribute() ? 'Invalid YouTube URL' : '') + }) + }); +} + let firstRender = true; export default function(ctrl: AnalyseCtrl): VNode { @@ -271,8 +281,9 @@ export default function(ctrl: AnalyseCtrl): VNode { } }, [ visualBoard(ctrl), - h('div.lichess_ground', gamebookPlayView || [ + h('div.lichess_ground', gamebookPlay ? [chapterEmbed(ctrl), gamebookPlayView] : [ menuIsOpen ? null : renderClocks(ctrl), + chapterEmbed(ctrl), menuIsOpen ? null : crazyView(ctrl, ctrl.topColor(), 'top'), ...(menuIsOpen ? [actionMenu(ctrl)] : [ cevalView.renderCeval(ctrl), diff --git a/ui/analyse/tsconfig.json b/ui/analyse/tsconfig.json index d9dca58d98..c2839431b2 100644 --- a/ui/analyse/tsconfig.json +++ b/ui/analyse/tsconfig.json @@ -4,7 +4,7 @@ "compilerOptions": { "allowJs": true, "strictNullChecks": true, - "noUnusedLocals": false, + "noUnusedLocals": true, "noEmitOnError": true, "noImplicitAny": false, "noImplicitReturns": false,