Skip to content

Commit 93942bd

Browse files
authored
Merge pull request #11 from jason89521/website
2 parents 3507dcc + 62984ae commit 93942bd

11 files changed

Lines changed: 300 additions & 118 deletions

File tree

dev/App.css

Lines changed: 0 additions & 66 deletions
This file was deleted.

dev/App.tsx

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
1-
import React, { useState } from 'react';
2-
import './App.css';
1+
import React from 'react';
32
import Typist from '../src';
3+
import Header from './components/Header';
4+
import Section from './components/Section';
5+
import PauseExample from './components/PauseExample';
46

57
function App() {
6-
const [count, setCount] = useState(0);
7-
const [key, setKey] = useState(1);
8-
98
return (
10-
<div className="App">
11-
<button onClick={() => setKey(key + 1)}>key</button>
12-
<button onClick={() => setCount(count + 1)}>{count}</button>
13-
<br />
14-
<Typist
15-
typingDelay={100}
16-
disabled={count % 2 === 0}
17-
cursor={<span className="cursor">|</span>}
18-
restartKey={key}
19-
>
20-
This is a typo
21-
<br />
22-
<Typist.Backspace count={5} />
23-
<Typist.Delay ms={1500} />
24-
react component
25-
<Typist.Paste>
26-
<div>
27-
use
28-
<div>deeper div</div>
29-
</div>
30-
</Typist.Paste>
31-
<Typist.Delay ms={1500} />
32-
</Typist>
9+
<div className='min-h-screen bg-slate-600 px-12 py-10 text-white'>
10+
<Header />
11+
<Section title='Support Looping'>
12+
<Typist loop>
13+
The typing animation will be restarted automatically...
14+
</Typist>
15+
</Section>
16+
<PauseExample />
17+
<Section title='Support Delay, Backspacing and Pasting'>
18+
<Typist>
19+
The typing animation can be delayed adn bac
20+
<Typist.Delay ms={1000} />
21+
<Typist.Backspace count={6} />
22+
nd backspaced
23+
<br />
24+
Furthermore,
25+
<Typist.Paste> the text can be pasted directly!</Typist.Paste>
26+
</Typist>
27+
</Section>
3328
</div>
3429
);
3530
}

dev/components/Header.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
import Typist from '../../src';
4+
import randomDelayGenerator from '../utils/randomDelayGenerator';
5+
6+
export default function Header() {
7+
return (
8+
<div>
9+
<header className='text-xl text-cyan-400'>
10+
<h1 className='mb-4 text-4xl font-bold'>React Typist Component</h1>
11+
<Typist typingDelay={randomDelayGenerator}>
12+
Use this component to create{' '}
13+
<span className='text-red-500'>typewriter effect</span> easily!
14+
</Typist>
15+
</header>
16+
</div>
17+
);
18+
}

dev/components/PauseExample.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

dev/components/Section.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

dev/index.css

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
body {
2-
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
4-
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
5-
-webkit-font-smoothing: antialiased;
6-
-moz-osx-font-smoothing: grayscale;
7-
}
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
84

9-
code {
10-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
11-
}

dev/utils/randomDelayGenerator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function randomDelayGenerator(base = 75, bias = 20) {
2+
return base + (Math.random() - 0.5) * bias;
3+
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@typescript-eslint/eslint-plugin": "^5.25.0",
6060
"@typescript-eslint/parser": "^5.25.0",
6161
"@vitejs/plugin-react": "^2.0.0",
62+
"autoprefixer": "^10.4.8",
6263
"babel-loader": "^8.2.5",
6364
"commitizen": "^4.2.4",
6465
"cz-conventional-changelog": "3.3.0",
@@ -69,9 +70,13 @@
6970
"grapheme-splitter": "^1.0.4",
7071
"jest": "^28.1.3",
7172
"jest-environment-jsdom": "^28.1.3",
73+
"postcss": "^8.4.16",
74+
"prettier": "^2.7.1",
75+
"prettier-plugin-tailwindcss": "^0.1.13",
7276
"react": "^18.2.0",
7377
"react-dom": "^18.2.0",
7478
"rimraf": "^3.0.2",
79+
"tailwindcss": "^3.1.8",
7580
"ts-jest": "^28.0.7",
7681
"typescript": "^4.7.4",
7782
"vite": "^3.0.2"

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

tailwind.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./dev/**/*.{js,ts,jsx,tsx}'],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

0 commit comments

Comments
 (0)