Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jennasys/pyreact-tools

Miscellaneous tools for creating React applications with Python using the Transcrypt transpiler
https://github.com/jennasys/pyreact-tools

Last synced: about 2 months ago
JSON representation

Miscellaneous tools for creating React applications with Python using the Transcrypt transpiler

Awesome Lists containing this project

README

        

# PyReact Tools

## [jsxtopy](https://github.com/JennaSys/pyreact-tools/blob/main/jsxtopy.py)
### Converts a JSX fragment to a Python function equivalent
When copying JSX example code from somewhere to use in my React Python projects, I got tired of having to manually convert JSX code to Python functions with dictionary attributes and having to manually quote everything. So I created this function that will (mostly) do it for me.

For example, this JSX code:
```jsx

Settings

```
will get converted to this Python code:
```python
Div({'id': 'root'},
Button({'radius': 'md', 'size': 'lg', 'compact': True, 'uppercase': True}, "Settings")
)
```

## Installation:
```bash
pip install git+https://github.com/JennaSys/pyreact-tools
```

## Usage:
```text
usage: jsxtopy [-h] [-v] [-d] [--test] [--dev] [jsx]

Converts a JSX fragment to a Python function equivalent

positional arguments:
jsx JSX string to convert (If not supplied, will try to use what is in clipboard)

optional arguments:
-h, --help show this help message and exit
-v, --verbose Print original JSX and Python result to console
-d, --dict Create props as dict function instead of dict literal
--test Run JSX unit tests
--dev Run JSX development test
```

## Resources
- https://pyreact.com
- https://www.transcrypt.org