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

Allow reaction box widget in html templates and Wagtail html block #5492

Open
6 tasks
johnnyporkchops opened this issue Nov 18, 2022 · 0 comments · May be fixed by #5513
Open
6 tasks

Allow reaction box widget in html templates and Wagtail html block #5492

johnnyporkchops opened this issue Nov 18, 2022 · 0 comments · May be fixed by #5513

Comments

@johnnyporkchops
Copy link
Contributor

johnnyporkchops commented Nov 18, 2022

Summary

Currently the reaction-box widgets can only be placed in Jinja templates. To allow use in Django html templates and even in a Wagtail html block, we can reference the script in data-init.js and init.js the same way the feedback.js is referenced.

In addition to expanding the locations the widget can be added , it will also make adding/removing much simpler because now to implement a reactrion-box on a page, all one has to do is add the macro or html code to a page .It will be detected and the JS takes care of itself.

Exporting ReactionBox as a module will allow us to write tests for it as well

Current Situation

Currently the reaction-box widgets can only be placed in Jinja templates and requires adding a reference to the JS file on that page as well.

Use Case

UX or Content team want a reaction box on a non-Jinja template, or on a specific Wagtail page

Misc

This has been tested locally and seems to work as expected
If it has not been deleted yet, there is a WIP branch test/reaction-box

Tech steps:

  • Move the document ready function for reaction box from reaction-box.js to data-init.js and init.js
  • Move reaction-box.js from /pages to /modules and export it as a module module.exports = { ReactionBox: ReactionBox };
  • Require reaction-box module in data-init.js and init.js the same way the feedback.js is required
  • Optional: Consider making a templatetag for html(non-Jinja) implementations so one does not have to copy html from Macro. This can also be a block for Wagtail, like Careers block, but user would need access to some config fields there to add name/location attrs.
  • Update comments and docstrings for instructions on adding a reaction-box to templates and Wagtail
  • Test on both local host and dev, stage r feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🗄️ PI backlog
Development

Successfully merging a pull request may close this issue.

3 participants