mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-05-07 01:02:36 +00:00
chore: update prettier tab width for consistency (#175)
This commit is contained in:
parent
a931f8c69c
commit
f24d2fcc99
247 changed files with 7224 additions and 7375 deletions
|
@ -1,37 +1,37 @@
|
|||
import * as React from 'react';
|
||||
|
||||
type TypistProps = {
|
||||
resetTimeout: number;
|
||||
charTimeout: number;
|
||||
lines: string[];
|
||||
resetTimeout: number;
|
||||
charTimeout: number;
|
||||
lines: string[];
|
||||
};
|
||||
|
||||
export const Typist = (props: TypistProps) => {
|
||||
const [outputText, setOutputText] = React.useState('');
|
||||
const [currentLine, setCurrentLine] = React.useState(0);
|
||||
const [outputText, setOutputText] = React.useState('');
|
||||
const [currentLine, setCurrentLine] = React.useState(0);
|
||||
|
||||
React.useEffect(() => {
|
||||
const fullLine = props.lines[currentLine];
|
||||
React.useEffect(() => {
|
||||
const fullLine = props.lines[currentLine];
|
||||
|
||||
if (outputText === fullLine) {
|
||||
const timeout = setTimeout(() => {
|
||||
setOutputText('');
|
||||
setCurrentLine((currentLine + 1) % props.lines.length);
|
||||
}, props.resetTimeout);
|
||||
if (outputText === fullLine) {
|
||||
const timeout = setTimeout(() => {
|
||||
setOutputText('');
|
||||
setCurrentLine((currentLine + 1) % props.lines.length);
|
||||
}, props.resetTimeout);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setOutputText(fullLine.slice(0, outputText.length + 1));
|
||||
}, props.charTimeout);
|
||||
const timeout = setTimeout(() => {
|
||||
setOutputText(fullLine.slice(0, outputText.length + 1));
|
||||
}, props.charTimeout);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [currentLine, outputText]);
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [currentLine, outputText]);
|
||||
|
||||
return <>{outputText}</>;
|
||||
return <>{outputText}</>;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue