Skip to content

Commit

Permalink
chore: better typing delay for commands that aren't the first
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Oct 15, 2020
1 parent 0d248f9 commit 5d66db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Terminal/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const machine = Machine(
}
);

const Command = ({ animate, command, getTokenProps, onDone }) => {
const Command = ({ animate, command, getTokenProps, onDone, typingDelay }) => {
const [state, send] = useMachine(machine, {
context: { command },
actions: {
Expand All @@ -71,7 +71,7 @@ const Command = ({ animate, command, getTokenProps, onDone }) => {
prompt={idx > 0 ? '>' : '$'}
getTokenProps={getTokenProps}
onDoneTyping={() => send('PRESS_ENTER')}
typingDelay={idx === 0 ? 2000 : 0}
typingDelay={idx === 0 ? typingDelay : 0}
/>
))}

Expand Down Expand Up @@ -99,6 +99,11 @@ Command.propTypes = {
command: PropTypes.object.isRequired,
getTokenProps: PropTypes.func.isRequired,
onDone: PropTypes.func.isRequired,
typingDelay: PropTypes.number,
};

Command.defaultProps = {
typingDelay: 0,
};

export default Command;
1 change: 1 addition & 0 deletions src/components/Terminal/Shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const Shell = ({ animate, highlight, code }) => {
animate={animate}
command={command}
getTokenProps={getTokenProps}
typingDelay={idx === 0 ? 2000 : 500}
onDone={() => {
setStep((step) => step + 1);
}}
Expand Down

0 comments on commit 5d66db4

Please sign in to comment.