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
docs(adr): add Developing and Publishing ClientSide Behaviours #250
docs(adr): add Developing and Publishing ClientSide Behaviours #250
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/primer/view-components/GZnYiw8XR5RoqcsPkT9unHwnh8CK |
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.
👏🏻
@@ -0,0 +1,48 @@ | |||
# 0250. Developing and Publishing ClientSide Behaviours |
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.
👋🏻 one other thought here: have we considered if we might want to provide some sort of encapsulation of the Javascript we write for ViewComponents? I could see us coupling the two together in similar fashion to our explorations of CSS modules, generating a selector specifically for a component and using it in the JS.
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.
Our current architecture is leveraging Web Components, which are encapsulated by tag name. Attempting to define an already defined web component causes an exception on the front-end.
Web Components are encapsulated in that they are only activated for/on the pre-defined tags. In other words behaviour is not executed globally, only when an element enters the dom.
Not in the scope of this ADR but something I want to explore further is adding a suite of meta-tests which assert that the JS follows good conventions, such as:
- The naming of JS files matches the naming of components.
- The JS avoids global behaviours where applicable.
- Any component with a JS file must have an integration test.
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.
Attempting to define an already defined web component causes an exception on the front-end.
This is the aspect I'm curious about. Can we provide an architecture where this exception is raised at compile time or as part of a test suite?
(This isn't a blocker at all)
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.
This is already implicitly part of our test suite as we include the compiled bundle in the system tests!
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
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.
I think this is ready to go. This mostly now reflects reality, as we've implemented most of what this ADR documents.
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
This records some architectural decisions on how we will add client side (JS) behaviours to PVC.