reactpy-django icon indicating copy to clipboard operation
reactpy-django copied to clipboard

Client-side components

Open Archmonger opened this issue 1 year ago • 0 comments

Current Situation

While it's currently not possible to implement in core, we can use our template tag to render client-side components within this repo as a Django exclusive early release.

Proposed Actions

Develop client side components with multiple execution methods. The initial draft will be based on https://github.com/reactive-python/reactpy/discussions/1096

We need to make sure the interface makes the user understand that the whole file is going to be loaded into the browser.

Here's a quick draft of potential API designs:

{% component "example.hello_world" client_side_render="pyscript" %}
{% component "file:/example/components.py:hello_world" executor="pyscript" %}
{% client_component "/example/components.py:hello_world" executor="reactpy_django.client.pyscript" %}
{% pyscript_component "/example/components.py:hello_world" %}
{% pyscript_component "/example/components.py" root="hello_world" %}

We should also create a callable variant that can be used as a child within server side components.

@component
def parent_component():
    return html.div( pyscript_component("/example/components.py", root="hello_world") )

We may also want to minify the python code we generate. Minification should be toggleable through minify=False.

It seems logical that the root component should be def root(...) by default.

We might want to fetch dependencies from within the file itself, declared as such:

dependencies = ["jsonpatch", "aiohttp", "etc"]

Archmonger avatar Feb 19 '24 20:02 Archmonger