-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Avoid copying zag hook #145
base: feature/accessibility-hook
Are you sure you want to change the base?
Avoid copying zag hook #145
Conversation
Reviewer's Guide by SourceryThis pull request refactors how Zag components are integrated into SaladUI. Instead of copying JS files to the user's project, the library now provides a Sequence diagram: New Zag hook initialization processsequenceDiagram
participant U as User App
participant S as SaladUI
participant Z as Zag Components
U->>S: Import createZagHook
U->>Z: Import Zag components
U->>S: createZagHook(components)
S-->>U: Return ZagHook
Note over U: Register ZagHook in LiveSocket
U->>U: new LiveSocket(..., {hooks: {ZagHook}})
Class diagram: Component class structureclassDiagram
class Component {
+el: Element
+context: Object
+componentsModules: Object
+cleanupFunctions: Map
+prevAttrsMap: WeakMap
+constructor(el, context, componentsModules)
+init()
+render()
+destroy()
-initComponent()
-initService()
-initApi()
}
note for Component "Modified to accept componentsModules parameter"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @selenil - I've reviewed your changes - here's some feedback:
Overall Comments:
- The install_zag_package/1 function is left unimplemented with just a TODO. Consider implementing this critical functionality before merging, or split this into two PRs - one for the architectural changes and another for the package installation feature.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Instead of copying a bunch of JS files to the user’s project in order to use
ZagHook
, we should keep all those files in the library and provide acreateZagHooks
function that returns the hook and users can import it directly fromSaladUI
.The next steps are to figure out how to download the source code of Zag packages, as they depend on other core packages, and how to support the
--as-lib
option because, in that case, users won't usesalad.add
and will need to manually install Zag packages.One solution to both problems is to bundle
SaladUI
with all Zag packages pre-installed to avoid downloads, but that would require users to include code they aren’t using. We need another solution here.Summary by Sourcery
Introduce the
createZagHook
function to provide the hook directly fromSaladUI
. Update the component initialization to use the provided components modules. Install Zag packages as dependencies.New Features:
createZagHook
function inSaladUI
to access the hook directly.Tests:
createZagHook
function.