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

Calcite Components React should auto import web component #6601

Closed
am-maneaters opened this issue Mar 14, 2023 · 3 comments
Closed

Calcite Components React should auto import web component #6601

am-maneaters opened this issue Mar 14, 2023 · 3 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. calcite-components-react Issues specific to the @esri/calcite-components-react package. tooling Issues relating to build system fixes or improvements.

Comments

@am-maneaters
Copy link

am-maneaters commented Mar 14, 2023

Summary

Having to import components twice in the React wrapper adds extra complexity to using the package.
i.e.

import '@esri/calcite-components/dist/components/calcite-notice';
import { CalciteNotice } from "calcite-components-react";

Intellisense in VSCode knows to auto import the CalciteNotice when I use it in JSX, but then I have to manually include web-component import as well. I've resorted to having a single file where I import every calcite component import that I just include in my index file.

Desired Outcome

Since the react wrappers are already generated using a set of scripts, we could extend those scripts or write a secondary script that auto attaches calcite-component imports to the respective calcite-components-react component.

import { CalciteNotice } from "calcite-components-react";

I have a local version of this working using dynamic imports in the createComponent.js file that is included in the stencil-react-output-target.

Resources

the way i implemented this was at this line, i added

import(`../../../calcite-components/dist/components/${tagName}`)

oh, or probably could just use this? https://stenciljs.com/docs/react#includeimportcustomelements

@am-maneaters am-maneaters added 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. tooling Issues relating to build system fixes or improvements. labels Mar 14, 2023
@jcfranco
Copy link
Member

oh, or probably could just use this? https://stenciljs.com/docs/react#includeimportcustomelements

Great suggestion. Enabling this will make the wrappers behave closer to the custom-elements output target. cc @benelan

@benelan benelan added framework-react Issues with React framework 1 - assigned Issues that are assigned to a sprint and a team member. and removed 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels May 24, 2023
@benelan benelan self-assigned this May 24, 2023
@benelan benelan added this to the 2023 June patch priorities milestone May 24, 2023
@benelan benelan added 2 - in development Issues that are actively being worked on. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels Jun 7, 2023
benelan added a commit that referenced this issue Jun 29, 2023
…ng their React wrapper (#7185)

**Related Issue:** #6601

## Summary

Automatically imports and defines Calcite Components when importing the
React wrappers. For example, here is a snippet from our React sample:

```jsx
import '@esri/calcite-components/dist/components/calcite-button';
import '@esri/calcite-components/dist/components/calcite-icon';
import '@esri/calcite-components/dist/components/calcite-slider';
import { CalciteButton, CalciteIcon, CalciteSlider } from '@esri/calcite-components-react';
```

The above snippet can now be simplified to the following:

```jsx
import { CalciteButton, CalciteIcon, CalciteSlider } from '@esri/calcite-components-react';
```

### Note

I had to patch the build because Stencil was generating an incorrect
import path to the JSX type. I tested in our old output targets repo and
it reproduced there as well, so this isn't related to the monorepo
change.
@benelan benelan added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 2 - in development Issues that are actively being worked on. labels Jun 29, 2023
@github-actions github-actions bot assigned geospatialem and unassigned benelan Jun 29, 2023
@github-actions
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Jul 3, 2023
@geospatialem
Copy link
Member

Verified in the example repo's App.js with 1.5.0-next.11 with the following imports:

import React, { useState } from 'react';
import { CalciteButton, CalciteIcon, CalciteSlider } from '@esri/calcite-components-react';
import '@esri/calcite-components/dist/calcite/calcite.css';

@geospatialem geospatialem added calcite-components-react Issues specific to the @esri/calcite-components-react package. and removed framework-react Issues with React framework labels Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. calcite-components-react Issues specific to the @esri/calcite-components-react package. tooling Issues relating to build system fixes or improvements.
Projects
None yet
Development

No branches or pull requests

4 participants