Skip to content

Commit 200ac66

Browse files
authored
docs: slightly restructure section on JSX (#30)
1 parent 0ce9895 commit 200ac66

1 file changed

Lines changed: 32 additions & 29 deletions

File tree

README.md

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,38 @@ Benefits of using JSX:
441441

442442
`Text.tgx` function accepts a JSX element and returns an instance of `Text.Tgx`, which can then be used as a content of a message.
443443

444+
<details>
445+
<summary>How to enable?</summary>
446+
447+
1. Install `@grom.js/tgx` package:
448+
449+
```sh
450+
npm install @grom.js/tgx
451+
```
452+
453+
2. Update your `tsconfig.json`:
454+
455+
```json
456+
{
457+
"compilerOptions": {
458+
"jsx": "react-jsx",
459+
"jsxImportSource": "@grom.js/tgx"
460+
}
461+
}
462+
```
463+
464+
</details>
465+
466+
<details>
467+
<summary>How it works?</summary>
468+
469+
JSX is just syntactic sugar transformed by the compiler.
470+
Result of transformation depends on the JSX runtime.
471+
`effect-tg` relies on JSX runtime from [`@grom.js/tgx`](https://github.com/grom-dev/tgx), which transforms JSX elements to `TgxElement` instances.
472+
When `Send.sendMessage` encounters an instance of `Text.Tgx`, it converts inner `TgxElement`s to the parameters for a `send*` method.
473+
474+
</details>
475+
444476
**Example:** Composing reusable messages with JSX.
445477

446478
```tsx
@@ -500,32 +532,3 @@ const publish = Send.message(Content.text(summary)).pipe(
500532
Send.to(Dialog.channel(3011378744)),
501533
)
502534
```
503-
504-
<details>
505-
<summary>How it works?</summary>
506-
507-
JSX is just syntactic sugar transformed by the compiler.
508-
Result of transformation depends on the JSX runtime.
509-
`effect-tg` relies on JSX runtime from [`@grom.js/tgx`](https://github.com/grom-dev/tgx), which transforms JSX elements to `TgxElement` instances.
510-
When `Send.sendMessage` encounters an instance of `Text.Tgx`, it converts inner `TgxElement`s to the parameters for a `send*` method.
511-
512-
</details>
513-
514-
To enable JSX support:
515-
516-
1. Install `@grom.js/tgx` package:
517-
518-
```sh
519-
npm install @grom.js/tgx
520-
```
521-
522-
2. Update your `tsconfig.json`:
523-
524-
```json
525-
{
526-
"compilerOptions": {
527-
"jsx": "react-jsx",
528-
"jsxImportSource": "@grom.js/tgx"
529-
}
530-
}
531-
```

0 commit comments

Comments
 (0)