-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: umd build. * refactor: remove comment from tsconfig json file.
- Loading branch information
Showing
11 changed files
with
3,766 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,54 @@ | ||
# Examples | ||
|
||
### UMD | ||
|
||
Using `tts-react` from a CDN: | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<title>tts-react UMD example</title> | ||
<script src="https://unpkg.com/react@18/umd/react.development.js"></script> | ||
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script> | ||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/umd/tts-react.min.js"></script> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="text/babel"> | ||
const root = ReactDOM.createRoot(document.getElementById('root')) | ||
const { TextToSpeech, useTts } = TTSReact | ||
const CustomTTS = ({ children }) => { | ||
const { play, ttsChildren } = useTts({ children }) | ||
return ( | ||
<> | ||
<button onClick={() => play()}>Play</button> | ||
<div>{ttsChildren}</div> | ||
</> | ||
) | ||
} | ||
root.render( | ||
<> | ||
<CustomTTS> | ||
<p><code>useTts</code> as a UMD module.</p> | ||
</CustomTTS> | ||
<TextToSpeech> | ||
<p><code>TextToSpeech</code> as a UMD module.</p> | ||
</TextToSpeech> | ||
</> | ||
) | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
### Hook | ||
|
||
Counting on command: | ||
|
||
```tsx | ||
import { useState, useCallback } from 'react' | ||
import { useTts } from 'tts-reat' | ||
|
Oops, something went wrong.