-
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.
refactor: remove jsx-runtime from hook and highlighter. (#81)
- Loading branch information
Showing
6 changed files
with
77 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,35 @@ | ||
# 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 markTextAsSpoken> | ||
<p><code>TextToSpeech</code> as a UMD module.</p> | ||
</TextToSpeech> | ||
</> | ||
) | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
### Import Map | ||
|
||
Uses [htm](https://github.com/developit/htm) and [import maps](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap): | ||
Using `tts-react` with ESM from a CDN and [import maps](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap): | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"react": "https://esm.sh/react", | ||
"react-dom/": "https://esm.sh/react-dom/", | ||
"tts-react": "https://esm.sh/tts-react", | ||
"htm/": "https://esm.sh/htm/" | ||
"react": "https://esm.sh/react@rc", | ||
"react-dom/": "https://esm.sh/react-dom@rc/", | ||
"react/jsx-runtime": "https://esm.sh/react@rc/jsx-runtime", | ||
"tts-react": "https://esm.sh/tts-react@next" | ||
} | ||
} | ||
</script> | ||
<title>Import Map (no build): tts-react</title> | ||
<title>ESM / CDN / Import Map</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module"> | ||
import { createElement } from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
import { TextToSpeech } from 'tts-react' | ||
import { html } from 'htm/react' | ||
createRoot(document.getElementById('root')).render( | ||
html` | ||
<${TextToSpeech} markTextAsSpoken> | ||
<p>Hello from tts-react.</p> | ||
</${TextToSpeech}> | ||
` | ||
createRoot(document.body).render( | ||
createElement(TextToSpeech, { markTextAsSpoken: true }, 'Hello from tts-react.') | ||
) | ||
</script> | ||
</body> | ||
|
@@ -90,7 +40,7 @@ Uses [htm](https://github.com/developit/htm) and [import maps](https://developer | |
|
||
Counting on command: | ||
|
||
```tsx | ||
```jsx | ||
import { useState, useCallback, useEffect } from 'react' | ||
import { useTts } from 'tts-react' | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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