-
Notifications
You must be signed in to change notification settings - Fork 2
make it easier to set phoenix config #120
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
base: main
Are you sure you want to change the base?
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #120 +/- ##
==========================================
- Coverage 78.65% 78.64% -0.02%
==========================================
Files 92 92
Lines 7674 7675 +1
Branches 528 528
==========================================
Hits 6036 6036
- Misses 1541 1542 +1
Partials 97 97 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 862d9846f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a configurable window.LiveViewConfig hook for customizing the Phoenix LiveView JavaScript client from PyView, exposes a head_content slot in the root template to inject such configuration, and documents the JS interop patterns.
Changes:
- Extend
defaultRootTemplate/_defaultRootTemplateto accepthead_contentmarkup and render it into the<head>before the bundledapp.jsscript. - Update the JS entrypoint and bundled asset to read
window.LiveViewConfigand merge user-providedhooks,params,uploaders, anddomoptions into theLiveSocketconfiguration. - Add a “JavaScript Interop” documentation page that explains hooks, LiveSocket configuration via
LiveViewConfig, and an attribute-syncing pattern forphx-update="ignore".
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Bumps pyview-web from 0.8.1 to 0.8.2 to reflect the new configuration capability. |
| pyview/template/root_template.py | Adds a head_content parameter and threads it into the HTML <head>, enabling injection of JS configuration like LiveViewConfig. |
| pyview/static/assets/app.js | Updates the compiled asset to pull window.LiveViewConfig and merge its options into LiveSocket, matching the source JS changes. |
| pyview/assets/js/app.js | Reads window.LiveViewConfig and merges its hooks, params, uploaders, and dom into the LiveSocket options. |
| docs/features/js-interop.md | Introduces documentation on hooks and window.LiveViewConfig, including examples using head_content in defaultRootTemplate. |
Comments suppressed due to low confidence (1)
pyview/template/root_template.py:25
- Adding the new
head_contentparameter between the existingcssandcontent_wrapperparameters changes the positional argument order of this public function and will break any external callers that were using positional arguments. To avoid an accidental breaking change, consider either appending the new parameter at the end of the signature with a default, or makinghead_content(and perhaps the rest) keyword-only so existing positional usages stay valid while still enabling the new behavior.
def defaultRootTemplate(
css: Optional[Markup] = None,
head_content: Optional[Markup] = None,
content_wrapper: Optional[ContentWrapper] = None,
title: Optional[str] = None,
title_suffix: Optional[str] = " | LiveView",
) -> RootTemplate:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Make it easier to to customize the bundled Phoenix LiveView's LiveSocket options via a global
window.LiveViewConfigobject, following the existingwindow.Hookspattern.