-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FE): add output preview on top of Editor
- Loading branch information
Showing
30 changed files
with
303 additions
and
72 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
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
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/apps/client/src/components/RundownOutput/RundownOutput.module.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,3 @@ | ||
.RundownOutput { | ||
overflow: hidden; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/apps/client/src/components/RundownOutput/RundownOutput.tsx
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,18 @@ | ||
import React from 'react' | ||
import { observer } from 'mobx-react-lite' | ||
import { UIRundown } from 'src/model/UIRundown' | ||
import classes from './RundownOutput.module.scss' | ||
import { Segment } from './Segment' | ||
|
||
export const RundownOutput = observer(function RundownOutput({ rundown }: { rundown: UIRundown }): React.ReactNode { | ||
return ( | ||
<div className={classes.RundownOutput}> | ||
<h1>{rundown.name}</h1> | ||
{rundown.segmentsInOrder.map((segment) => ( | ||
<Segment key={segment.id} segment={segment} /> | ||
))} | ||
<div className="spacer" /> | ||
</div> | ||
) | ||
}) | ||
RundownOutput.displayName = 'RundownOutput' |
File renamed without changes.
9 changes: 8 additions & 1 deletion
9
packages/apps/client/src/components/ScriptEditor/ScriptEditor.module.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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
.ScriptEditor { | ||
container-type: inline-size; | ||
overflow: auto; | ||
scrollbar-width: none; | ||
min-height: 0; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useLayoutEffect, useState } from 'react' | ||
import useResizeObserver from '@react-hook/resize-observer' | ||
|
||
export function useSize(target: React.RefObject<HTMLElement>): DOMRect | undefined { | ||
const [size, setSize] = useState<DOMRect>() | ||
|
||
useLayoutEffect(() => { | ||
if (!target.current) return | ||
|
||
setSize(target.current.getBoundingClientRect()) | ||
}, [target]) | ||
|
||
// Where the magic happens | ||
useResizeObserver(target, (entry) => setSize(entry.contentRect)) | ||
return size | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { observable, action, flow, makeObservable, IReactionDisposer, reaction } from 'mobx' | ||
import { ViewPort } from '@sofie-prompter-editor/shared-model' | ||
import { APIConnection, RootAppStore } from './RootAppStore.ts' | ||
|
||
export class ViewPortStore { | ||
viewPort = observable.object<ViewPort>({ | ||
_id: '', | ||
aspectRatio: 1, | ||
lastKnownState: null, | ||
}) | ||
|
||
initialized = false | ||
private initializing = false | ||
|
||
reactions: IReactionDisposer[] = [] | ||
|
||
constructor(public appStore: typeof RootAppStore, public connection: APIConnection) { | ||
makeObservable(this, { | ||
viewPort: observable, | ||
initialized: observable, | ||
}) | ||
|
||
// Note: we DON'T initialize here, | ||
// instead, when anyone wants to use this store, they should call initialize() first. | ||
} | ||
|
||
public initialize() { | ||
if (this.initializing || this.initialized) return | ||
|
||
this.initializing = true | ||
|
||
this.setupSubscription() | ||
this.loadInitialData() | ||
} | ||
|
||
private setupSubscription = action(() => { | ||
this.reactions.push( | ||
reaction( | ||
() => this.appStore.connected, | ||
async (connected) => { | ||
if (!connected) return | ||
|
||
await this.connection.viewPort.subscribeToViewPort() | ||
}, | ||
{ | ||
fireImmediately: true, | ||
} | ||
) | ||
) | ||
|
||
this.connection.viewPort.on('updated', this.onUpdatedViewPort) | ||
}) | ||
private loadInitialData = flow(function* (this: ViewPortStore) { | ||
const outputSettings = yield this.connection.viewPort.get(null) | ||
this.onUpdatedViewPort(outputSettings) | ||
|
||
this.initialized = true | ||
}) | ||
|
||
private onUpdatedViewPort = action('onUpdatedViewPort', (newData: ViewPort) => { | ||
for (const [key, value] of Object.entries(newData)) { | ||
// @ts-expect-error hack | ||
this.viewPort[key] = value | ||
} | ||
}) | ||
|
||
destroy = () => { | ||
this.reactions.forEach((dispose) => dispose()) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
width: 100vw; | ||
height: 100vh; | ||
overflow: auto; | ||
scrollbar-width: none; | ||
} |
Oops, something went wrong.