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

Add proposed ADR for Lit framework #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

heymatthenry
Copy link
Contributor

No description provided.

@heymatthenry heymatthenry requested a review from a team as a code owner May 16, 2024 21:46
Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasoning is solid. I've added additional notes for StencilJS/Lit on framework integration.

I do believe the styling approach on Lit can be less flexible than StencilJS, but overall they are similar in that they're a light layer on top of the native APIs.


There are several frameworks on offer that leverage the browser custom element APIs, any of which would be a strong choice as a basis for the next version of the design system, but there are two primary choices the team has been evaluating for this purpose:

1. Stencil - Stencil is an all-in-one web framework that supports React-like component authoring. Stencil components are written using JSX and transpiled to native JavaScript web components. Further, Stencil provides custom tooling such as a [test runner](https://stenciljs.com/docs/testing/stencil-testrunner/overview), as well as tools for static site generation and server-side rendering functionality among others. Because it has its own integrated build system, it also makes it easy to incorporate other tools, like Sass/SCSS, with little or no additional configuration. Additionally, some agencies are already using Stencil to build web component implementations of and extensions to the Design System.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StencilJS can also target specific frameworks for compatibility.

See Angular output target example.

There are several frameworks on offer that leverage the browser custom element APIs, any of which would be a strong choice as a basis for the next version of the design system, but there are two primary choices the team has been evaluating for this purpose:

1. Stencil - Stencil is an all-in-one web framework that supports React-like component authoring. Stencil components are written using JSX and transpiled to native JavaScript web components. Further, Stencil provides custom tooling such as a [test runner](https://stenciljs.com/docs/testing/stencil-testrunner/overview), as well as tools for static site generation and server-side rendering functionality among others. Because it has its own integrated build system, it also makes it easy to incorporate other tools, like Sass/SCSS, with little or no additional configuration. Additionally, some agencies are already using Stencil to build web component implementations of and extensions to the Design System.
2. Lit - As with Stencil, there are existing USWDS-based federal website projects that leverage Lit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lit announced additional wrappers last year in this YouTube video - Lit Labs: Framework wrapper generators. You can see some listed here too under lit/labs https://github.com/lit/lit.

It looks like this work is still experimental though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully over time this is less of a thing. Even React is going to support Custom Elements soon!

Whatever the answer ends up being to framework compat, it'll definitely need a lot of testing.

@heymatthenry
Copy link
Contributor Author

I do believe the styling approach on Lit can be less flexible than StencilJS, but overall they are similar in that they're a light layer on top of the native APIs.

I think that's right about the light layer on top of native APIs. I think under the hood what's happening here:

https://github.com/uswds/uswds-next/blob/ff9102731831c554b95e5c06e917596e57523c3b/web-components/src/components/usa-banner/index.js#L23-L34

…is a mix of the adopted stylesheet (for the imported sass) and constructed stylesheet (for the CSS-in-looking stuff) APIs

Whichever way we end up going, we'll need to have a story about how styles are packaged and how we're going to use custom properties, but that's a separate issue.

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The performance and being so similar to the native API is really nice.

Also enjoying writing vanilla JS and the ability to choose between that and typescript is another win.

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

2 participants