-
Notifications
You must be signed in to change notification settings - Fork 89
chore(stencil): replacing stencil references #11372
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
Changes from 10 commits
a017a28
131eb1c
1c57792
d09bdf9
bfb5706
b23b710
322f2b4
86e5c91
d377978
a43d14c
418ec89
bc004fe
75bc742
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,6 +303,8 @@ my-component/ | |
| ... | ||
| ``` | ||
|
|
||
| <!-- TODO: Get suggestions for what this should be replaced with --> | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any info related to building a component with Lumina should be removed. We could add a link to the internal doc.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this referring to specifically? Should this whole "assets" section be removed?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, assets and anything that is covered by https://qawebgis.esri.com/components/lumina/introduction. We could just link to it. |
||
| The component's metadata should then include the following metadata prop [`assetsDirs: ["assets"]`](https://stenciljs.com/docs/assets#assetsdirs). | ||
|
|
||
| ```tsx | ||
|
|
@@ -326,16 +328,6 @@ const assetPath = getAssetPath(`./assets/my-component/asset.json`); | |
|
|
||
| This is required in order to have a unified assets folder in the distributable. | ||
|
|
||
| ## Bundling and Loading | ||
|
|
||
| Stencil has the capability to build and distribute a large variety of outputs based on our needs. You can read more about this in the [output targets](https://github.com/ionic-team/stencil/blob/cc55401555ff5c28757cf99edf372dcada2c0b25/src/compiler/output-targets/readme.md) documentation. | ||
|
|
||
| As a best practice we should follow [Ionic's configuration](https://github.com/ionic-team/ionic/blob/master/core/stencil.config.ts) and generate a `bundle` for each component. Stencil will then generate a loader that will dynamically load the components used on the page. | ||
|
|
||
| **Note:** This is highly likely to change as we move closer to our first release and as Stencil improves their documentation around their specific methods and build processes. | ||
|
|
||
| Each root component should have a corresponding bundle entry in `stencil.config.ts`. | ||
|
|
||
| ## Unique IDs for Components | ||
|
|
||
| Many times it is necessary for components to have a `id="something"` attribute for things like `<label>` and various `aria-*` properties. To safely generate a unique id for a component but to also allow a user supplied `id` attribute to work follow the following pattern: | ||
|
|
@@ -364,32 +356,6 @@ export class Example { | |
|
|
||
| This will create a unique id attribute like `id="calcite-example-51af-0941-54ae-22c14d441beb"` which should have a VERY low collision change since `guid()` generates IDs with `window.crypto.getRandomValues`. If a user supplies an `id` this will respect the users `id`. | ||
|
|
||
| ## Prerendering and SSR | ||
|
DitwanP marked this conversation as resolved.
|
||
|
|
||
| Stencil provide the capability to render web components on the server and seamlessly hydrate them on the client. This is handled by the `dist-hydrate-script` output target in `stencil.config.ts`. | ||
|
|
||
| This generates a `hydrate` directory which exposes `renderToString()` (for the server) and `hydrateDocument()` for the client. | ||
|
|
||
| Since many of the same lifecycle methods are called on the client and server you may need to differentiate any code that relies on browser APIs like so: | ||
|
|
||
| ```ts | ||
| import { isBrowser } from "../utils/browser"; | ||
|
|
||
| if (isBrowser()) { | ||
| // client side | ||
| } else { | ||
| // server side | ||
| } | ||
| ``` | ||
|
|
||
| Checking if the necessary APIs are present is also acceptable: | ||
|
|
||
| ```ts | ||
| const elements = this.el.shadowRoot ? this.el.shadowRoot.querySelector("slot").assignedElements() : []; | ||
| ``` | ||
|
|
||
| To ensure that all components are compatible for prerendering a prerender build is done as part of `npm test`. | ||
|
|
||
| ## Cleaning up resources | ||
|
|
||
| Ensure all components clean up their resources. | ||
|
|
@@ -417,10 +383,6 @@ Avoid setting z-index ad hoc and instead use a contextual z-index layer from the | |
|
|
||
| There are utilities for common workflows in [`src/utils`](../src/utils). | ||
|
|
||
| ### Global attributes | ||
|
|
||
| Watching global attributes on components is now possible with Stencil v4. Please refer to the [documentation page](https://stenciljs.com/docs/reactive-data#watching-native-html-attributes) for more information. | ||
|
|
||
| ### BigDecimal | ||
|
|
||
| `BigDecimal` is a [number util](https://github.com/Esri/calcite-design-system/blob/dev/packages/calcite-components/src/utils/number.ts) that helps with [arbitrary precision arithmetic](https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic). The util is adopted from a [Stack Overflow answer](https://stackoverflow.com/a/66939244) with some small changes. There are some usage examples in [`number.spec.ts`](../src/utils/number.spec.ts). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.