Skip to content
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

Embedding ReactPy via Template Tags #653

Open
Archmonger opened this issue Feb 7, 2022 · 2 comments · May be fixed by #1056
Open

Embedding ReactPy via Template Tags #653

Archmonger opened this issue Feb 7, 2022 · 2 comments · May be fixed by #1056
Labels
priority-3-low May be resolved one any timeline. type-docs About changes and updates to documentation type-feature About new capabilities

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Feb 7, 2022

Current Situation

Currently, users are expected to manually construct the component mount HTML needed to embed IDOM into their projects. This is results in poor usability, and even worse, it can very easily cause server/client version mismatches.

Proposed Actions

We need to increase the convenience embedding ReactPy into existing projects, and document this as the primary way of using IDOM

For any web framework that supports HTML templating, we really should use a system identical to that used on ReactPy-Django.

The template tag source code will look something like this

{% load static %}
<div id="{{ idom_mount_uuid }}" class="{{ class }}"></div>
<script type="module" crossorigin="anonymous">
  import { mountViewToElement } from "{% static 'django_idom/client.js' %}";
  const mountPoint = document.getElementById("{{ idom_mount_uuid }}");
  mountViewToElement(
    mountPoint,
    "{{ idom_websocket_url }}",
    "{{ idom_web_modules_url }}",
    "{{ idom_ws_max_reconnect_timeout }}",
    "{{ idom_component_id }}",
    "{{ idom_component_params }}"
  );
</script>

We will probably rely on the jinja2 simple tags library.

To be framework agnostic, the static URL will probably need to be set via ReactPy's python config.

@Archmonger Archmonger added the flag-triage Not prioritized. label Feb 7, 2022
@Archmonger Archmonger changed the title IDOM embed shortcuts for all supported frameworks Improve IDOM Embed ease of use Feb 8, 2022
@Archmonger Archmonger changed the title Improve IDOM Embed ease of use Make embedding IDOM easier Feb 8, 2022
@Archmonger
Copy link
Contributor Author

Not really sure if this belongs in v1 or v2. Could go either way.

IDOM is technically usable without this, but only Django-IDOM feels convenient to develop in.

We did say v2 is for "niceities" though, so based on that logic this is a v2 task.

@Archmonger Archmonger added priority-3-low May be resolved one any timeline. type-docs About changes and updates to documentation type-feature About new capabilities flag-good-first-issue A well defined and self-contained task. and removed flag-triage Not prioritized. labels Feb 10, 2022
@Archmonger Archmonger added this to the 2.0 milestone Feb 16, 2022
@rmorshea rmorshea removed the flag-good-first-issue A well defined and self-contained task. label Feb 16, 2022
@Archmonger Archmonger modified the milestones: 2.0, 1.0 Apr 8, 2022
@Archmonger Archmonger changed the title Make embedding IDOM easier Embedding IDOM via Template Tags Apr 8, 2022
@rmorshea
Copy link
Collaborator

rmorshea commented Nov 5, 2022

Let's move this to v2 for now.

@rmorshea rmorshea modified the milestones: 1.0, 2.0 Nov 5, 2022
@Archmonger Archmonger removed this from the Luxury Features milestone Jan 29, 2023
@Archmonger Archmonger changed the title Embedding IDOM via Template Tags Embedding ReactPy via Template Tags Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low May be resolved one any timeline. type-docs About changes and updates to documentation type-feature About new capabilities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants