Skip to content

Client-side Python components #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Archmonger opened this issue Feb 19, 2024 · 0 comments · Fixed by #243
Closed

Client-side Python components #229

Archmonger opened this issue Feb 19, 2024 · 0 comments · Fixed by #243

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Feb 19, 2024

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 reactive-python/reactpy#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") )

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

We may also want to minify the python code we generate. Minification should be toggleable through minify=False
Not feasible since minification would rename the root component

@Archmonger Archmonger changed the title Client-side components Client-side Python components Jun 18, 2024
@Archmonger Archmonger linked a pull request Jun 21, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant