Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key-press overlay #79, PR #167 update tentative #230

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,16 @@ document.fonts.load("1em FiraCode Nerd Font").then(() => {
}
```

### `keystrokesTTL`

Type: number

How long should a keystroke be displayed?

For example, when set to `2` and a keystroke will disapper two seconds after it's been displayed.

Defaults to `3.0`

## Keyboard shortcuts

The following keyboard shortcuts are currently available (when the player
Expand Down
24 changes: 24 additions & 0 deletions src/components/Keystrokes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

export default props => {
const keystrokesWrapperStyle = () => {
return {
position: "absolute",
bottom: "3em",
"font-size": "18px",
"text-align": "center",
padding: "0.5em",
opacity: "0.8",
"background-color": "black",
width: "100%",
color: "white"
}
};

return (
<div style={keystrokesWrapperStyle()} ref={props.ref}>
<For each={props.keystrokes}>
{(key, i) => <span innerHTML={"&nbsp;" + key[1]} />}
</For>
</div>
);
}
8 changes: 7 additions & 1 deletion src/components/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ErrorOverlay from './ErrorOverlay';
import LoaderOverlay from './LoaderOverlay';
import OfflineOverlay from './OfflineOverlay';
import StartOverlay from './StartOverlay';
import Keystrokes from './Keystrokes';


export default props => {
Expand Down Expand Up @@ -36,9 +37,11 @@ export default props => {
remainingTime: null,
progress: null,
blink: true,
cursorHold: false
cursorHold: false,
keystrokes: []
});

const keystrokesTTL = props.keystrokesTTL/1000 || 3.0;
const terminalCols = () => state.cols || 80;
const terminalRows = () => state.rows || 24;

Expand Down Expand Up @@ -367,6 +370,9 @@ export default props => {
<div class={playerClass()} style={playerStyle()} onMouseLeave={playerOnMouseLeave} onMouseMove={() => showControls(true)} ref={playerRef}>
<Terminal cols={terminalCols()} rows={terminalRows()} scale={terminalScale()} blink={state.blink} lines={state.lines} cursor={state.cursor} cursorHold={state.cursorHold} fontFamily={props.terminalFontFamily} lineHeight={props.terminalLineHeight} ref={terminalRef} />
<ControlBar currentTime={state.currentTime} remainingTime={state.remainingTime} progress={state.progress} isPlaying={state.coreState == 'playing'} isPausable={state.isPausable} isSeekable={state.isSeekable} onPlayClick={() => core.togglePlay()} onFullscreenClick={toggleFullscreen} onSeekClick={pos => core.seek(pos)} ref={controlBarRef} />
<Show when={state.keystrokes.length > 0}>
<Keystrokes keystrokes={state.keystrokes} />
</Show>
<Switch>
<Match when={state.showStartOverlay}><StartOverlay onClick={() => core.play()} /></Match>
<Match when={state.coreState == 'loading'}><LoaderOverlay /></Match>
Expand Down