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

docs(adr): add Developing and Publishing ClientSide Behaviours #250

Merged

Conversation

keithamus
Copy link
Member

This records some architectural decisions on how we will add client side (JS) behaviours to PVC.

@vercel
Copy link

vercel bot commented Feb 18, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/view-components/GZnYiw8XR5RoqcsPkT9unHwnh8CK
✅ Preview: https://view-component-git-docs-adr-add-developing-and-publishin-d4892d.vercel.app

@vercel vercel bot temporarily deployed to Preview February 19, 2021 11:28 Inactive
@vercel vercel bot temporarily deployed to Preview February 19, 2021 15:30 Inactive
@vercel vercel bot temporarily deployed to Preview February 19, 2021 15:32 Inactive
Copy link
Contributor

@joelhawksley joelhawksley left a 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
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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)

Copy link
Member Author

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>
@vercel vercel bot temporarily deployed to Preview February 23, 2021 17:39 Inactive
@vercel vercel bot temporarily deployed to Preview February 23, 2021 17:44 Inactive
Copy link
Member Author

@keithamus keithamus left a 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.

@vercel vercel bot temporarily deployed to Preview March 2, 2021 17:10 Inactive
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
@vercel vercel bot temporarily deployed to Preview March 2, 2021 18:06 Inactive
@keithamus keithamus enabled auto-merge March 2, 2021 18:09
@keithamus keithamus merged commit 8210375 into main Mar 2, 2021
@keithamus keithamus deleted the docs-adr-add-developing-and-publishing-clientside-behaviours branch March 2, 2021 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants