File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,14 +2,22 @@ import React, { useState } from 'react';
22import './App.css' ;
33import Typist from '../src' ;
44import Header from './components/Header' ;
5+ import Section from './components/Section' ;
6+ import PauseExample from './components/PauseExample' ;
57
68function App ( ) {
79 const [ count , setCount ] = useState ( 0 ) ;
810 const [ key , setKey ] = useState ( 1 ) ;
911
1012 return (
11- < div className = 'bg-slate-600 px-12 py-10 text-white ' >
13+ < div className = 'min-h-screen bg-slate-600 px-12 py-10 text-white' >
1214 < Header />
15+ < Section title = 'Support Looping' >
16+ < Typist loop >
17+ The typing animation will be restarted automatically...
18+ </ Typist >
19+ </ Section >
20+ < PauseExample />
1321 < button onClick = { ( ) => setKey ( key + 1 ) } > key</ button >
1422 < button onClick = { ( ) => setCount ( count + 1 ) } > { count } </ button >
1523 < br />
Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react' ;
2+
3+ import Typist from '../../src' ;
4+ import Section from './Section' ;
5+
6+ export default function PauseExample ( ) {
7+ const [ isPause , setIsPause ] = useState ( false ) ;
8+
9+ console . log ( isPause ) ;
10+
11+ return (
12+ < Section title = 'Support Pausing' >
13+ < div className = 'mb-2 flex' >
14+ < label htmlFor = 'pause' className = 'mr-2' >
15+ pause
16+ </ label >
17+ < input
18+ id = 'pause'
19+ type = 'checkbox'
20+ checked = { isPause }
21+ onChange = { ( e ) => setIsPause ( e . currentTarget . checked ) }
22+ />
23+ </ div >
24+ < Typist loop pause = { isPause } >
25+ The typing animation will be paused if you check the input.
26+ </ Typist >
27+ </ Section >
28+ ) ;
29+ }
Original file line number Diff line number Diff line change 1+ import type { ReactNode } from 'react' ;
2+ import React from 'react' ;
3+
4+ interface Props {
5+ title : string ;
6+ children : ReactNode ;
7+ }
8+
9+ export default function Section ( { title, children } : Props ) {
10+ return (
11+ < section className = 'py-8 px-4' >
12+ < h1 className = 'mb-4 text-2xl text-rose-400' > { title } </ h1 >
13+ { children }
14+ </ section >
15+ ) ;
16+ }
You can’t perform that action at this time.
0 commit comments