From 19cf3a296741b92548849b1f40e0d3cc517f2fcc Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 20 Mar 2021 22:14:21 +0100 Subject: dimensions based on video --- cli/app/site/export.py | 4 +++ frontend/app/views/graph/graph.css | 10 ++++++- frontend/app/views/page/components/page.editor.js | 18 +++++++++++-- frontend/app/views/page/page.css | 3 +++ frontend/app/views/tile/components/tile.form.js | 32 ++++++++++++++--------- frontend/app/views/tile/handles/tile.image.js | 4 +-- frontend/app/views/tile/handles/tile.link.js | 8 +++--- frontend/app/views/tile/handles/tile.script.js | 4 +-- frontend/app/views/tile/handles/tile.text.js | 8 +++--- frontend/app/views/tile/handles/tile.video.js | 12 +++++++-- frontend/app/views/tile/tile.utils.js | 22 ++++++++++++---- frontend/site/viewer/viewer.container.js | 29 +++++++++++++++++--- 12 files changed, 117 insertions(+), 37 deletions(-) diff --git a/cli/app/site/export.py b/cli/app/site/export.py index c301a60..4ce8b64 100644 --- a/cli/app/site/export.py +++ b/cli/app/site/export.py @@ -93,6 +93,10 @@ def sanitize_graph(graph): if tile['target_page_id']: if tile['target_page_id'] == -1: tile['href'] = tile['settings']['external_link_url'] + elif tile['target_page_id'] == -2: + tile['href'] = '__open_popup' + elif tile['target_page_id'] == -3: + tile['href'] = '__close_popup' elif tile['target_page_id'] > 0: tile['href'] = page_path_lookup[tile['target_page_id']] if 'url' in tile['settings'] and tile['settings']['url'].startswith('/static'): diff --git a/frontend/app/views/graph/graph.css b/frontend/app/views/graph/graph.css index a557280..bfdbe5c 100644 --- a/frontend/app/views/graph/graph.css +++ b/frontend/app/views/graph/graph.css @@ -114,10 +114,17 @@ padding: 0.25rem; } +.box form .single label span, .box form .pair label span { min-width: 3rem; padding: 0.25rem 0; } +.box .single label { + flex-direction: row; + width: 100%; + margin-right: 0.5px; + min-width: auto; +} .box .pair label { flex-direction: row; width: 6.5rem; @@ -138,13 +145,14 @@ button.box_corner { background: transparent; border: 0; border-radius: 4px; + transform: scaleX(-1); } button.box_corner:hover { color: #fff; background: rgba(64,64,128,0.5); } .sidebar.left button.box_corner { - transform: scaleX(-1); + transform: scaleX(1); } .box .slider { diff --git a/frontend/app/views/page/components/page.editor.js b/frontend/app/views/page/components/page.editor.js index 03190e3..7e841ef 100644 --- a/frontend/app/views/page/components/page.editor.js +++ b/frontend/app/views/page/components/page.editor.js @@ -16,6 +16,7 @@ import TileHandle from 'app/views/tile/components/tile.handle' const defaultState = { dragging: false, bounds: null, + videoBounds: null, mouseX: 0, mouseY: 0, box: { @@ -37,6 +38,7 @@ class PageEditor extends Component { this.handleMouseMove = this.handleMouseMove.bind(this) this.handleMouseUp = this.handleMouseUp.bind(this) this.handleWindowResize = this.handleWindowResize.bind(this) + this.handlePlaybackEnded = this.handlePlaybackEnded.bind(this) this.pageRef = React.createRef() } @@ -59,7 +61,8 @@ class PageEditor extends Component { document.body.addEventListener('mousemove', this.handleMouseMove) document.body.addEventListener('mouseup', this.handleMouseUp) window.addEventListener('resize', this.handleWindowResize) - this.setState({ bounds: this.getBoundingClientRect() }) + const bounds = this.getBoundingClientRect() + this.setState({ bounds }) } componentDidUpdate(prevProps) { @@ -72,6 +75,10 @@ class PageEditor extends Component { this.setState({ bounds: this.getBoundingClientRect() }) } + handlePlaybackEnded() { + // + } + handleMouseDown(e, tile) { if (e.metaKey || e.ctrlKey || e.altKey || e.button !== 0) return const bounds = this.getBoundingClientRect() @@ -171,10 +178,13 @@ class PageEditor extends Component { const { res } = this.props.page.show const { settings } = res const pageStyle = { backgroundColor: settings ? settings.background_color : '#000000' } + const videoBounds = (res.tiles.length && res.tiles[0].type === 'video') ? { + width: res.tiles[0].settings.width, + height: res.tiles[0].settings.height, + } : this.state.bounds return (
{res.tiles && res.tiles.map(tile => { - console.log(tile.type, tile.settings.is_popup) if (!this.props.page.editor.showingPopups && tile.settings.is_popup) return if (temporaryTile && temporaryTile.id === tile.id) { tile = temporaryTile @@ -184,9 +194,11 @@ class PageEditor extends Component { key={tile.id} tile={tile} bounds={this.state.bounds} + videoBounds={videoBounds} box={currentTile && tile.id === currentTile.id && currentBox} onMouseDown={e => this.handleMouseDown(e, tile)} onDoubleClick={e => this.props.pageActions.showEditTileForm(tile.id)} + onPlaybackEnded={this.handlePlaybackEnded} /> ) })} @@ -195,8 +207,10 @@ class PageEditor extends Component { key={temporaryTile.id} tile={temporaryTile} bounds={this.state.bounds} + videoBounds={videoBounds} box={currentTile && temporaryTile.id === currentTile.id && currentBox} onMouseDown={e => this.handleMouseDown(e, temporaryTile)} + onPlaybackEnded={this.handlePlaybackEnded} /> )}
diff --git a/frontend/app/views/page/page.css b/frontend/app/views/page/page.css index 2014289..2998007 100644 --- a/frontend/app/views/page/page.css +++ b/frontend/app/views/page/page.css @@ -117,6 +117,9 @@ .box .row.pair { justify-content: space-between; } +.box .row.single { + justify-content: space-between; +} .box .pair label:last-child { margin-right: 0; } diff --git a/frontend/app/views/tile/components/tile.form.js b/frontend/app/views/tile/components/tile.form.js index b33f7b8..3066da3 100644 --- a/frontend/app/views/tile/components/tile.form.js +++ b/frontend/app/views/tile/components/tile.form.js @@ -64,6 +64,14 @@ const CURSORS = [ { name: 'unclickable', label: 'Unclickable', }, ] +const UNITS = [ + { name: 'px', label: 'pixels' }, + { name: '%', label: 'percent' }, + { name: 'video', label: 'video' }, + { name: 'vmin', label: 'screen min' }, + { name: 'vmax', label: 'screen max' }, +] + const NO_LINK = 0 const EXTERNAL_LINK = -1 const OPEN_POPUP_LINK = -2 @@ -95,7 +103,7 @@ const newImage = (data) => ({ cursor: 'hand_up', }, type: 'image', - target_page_id: null, + target_page_id: 0, ...data, }) @@ -114,7 +122,7 @@ const newVideo = (data) => ({ loop_end: 0, }, type: 'video', - target_page_id: null, + target_page_id: 0, ...data, }) @@ -134,7 +142,7 @@ const newText = (data) => ({ cursor: 'hand_up', }, type: 'text', - target_page_id: null, + target_page_id: 0, ...data, }) @@ -146,7 +154,7 @@ const newLink = (data) => ({ units: 'px', }, type: 'link', - target_page_id: null, + target_page_id: 0, ...data, }) @@ -395,6 +403,7 @@ class TileForm extends Component { } else { validData.id = temporaryTile.id } + validData.target_page_id = validData.target_page_id || 0 this.setState({ modified: false }) console.log('submit', validData) onSubmit(validData) @@ -734,14 +743,13 @@ class TileForm extends Component { autoComplete="off" /> -
- +