Comments (9)
@bjesuiter Please try to add import
to src/index.ts
:
export { Components } from './components';
import '@stencil/router';
import 'ionicons';
from stencil-site.
Noted that we should improve the documentation around where to import other stencil built web components - importing them from within the src/index.ts
is the correct way to do this.
import 'ionicons';
from stencil-site.
I've created a new stencil component and tried the following the steps:
-
Install ionicons:
npm i ionicons
:"@ionic/core": "^6.0.4", "@stencil/core": "^2.13.0", "ionicons": "^6.0.1",
-
Add
import 'ionicons';
insrc/index.ts
:import 'ionicons'; import '@ionic/core'; export { Components, JSX } from './components';
-
Use
ion-icon
in my-component:render() { return ( <ion-buttons> <ion-button> <ion-icon slot="icon-only" name="remove-outline" /> </ion-button> </ion-buttons> );
-
Build the component
npm run build
-
npm link
the component into another project with only anindex.html
webpage:<!DOCTYPE html> <html> <head> <script type="module" src="/node_modules/my-component/dist/my-component/my-component.esm.js"></script> </head> <body> <my-component /> </body> </html>
-
live-serve
the whole folder -
Access to
index.html
. The html seems to be rendered, but the icon itself is missing (no icon shown insideion-icon
):Empty icons:
EDIT
This is quite strange, the published npm version at pdf-component works fine, but I was affraid to publish something that was not working at all. I've tried the local files of published version in via linked node_modules
and it still does not work.
from stencil-site.
Ok, for some reason it does work now when adding import 'ionicons';
to my byc-region.tsx component file without having the script tag in index.html for the ionicons.js import from unpkg.
(this one: <!-- <script src="https://unpkg.com/[email protected]/dist/ionicons.js"></script>-->
)'
Note, that I did not have to add it to index.ts.
To avoid my test being flawed by the browser cache, instructed ion-icon to load the md-aperture and md-airplane icons which I did not load at all before.
I also did compile it and imported it as Webcomponent into another project and it works.
A little question for understanding:
Would the dependency to ionicons get distributed along with my component, when imported in my src/index.ts, as the import in my own component does ?
@donskov Thanks for your help anyway! :)
But anyway, this import 'some-other stencil-package';
Syntax should be described in the documentation.
Could you guys add a page with a name something like 'Using other Webcomponents for your stencil component' under the Components Part of the Documentation Website?
https://stenciljs.com/docs/decorators
from stencil-site.
I've tried all the above mentioned solutions using stencil and ionic to create a component and then exporting my component into a create-react-app and the icons will not show. I used a fresh stencil starter project and a fresh create-react-app project.
The script tag to add into the index.html is fickle (sometimes it works, and other times it doesn't.)
From my understanding, I shouldn't even need the script tag since ion icons should come included with ionic. Can someone please advise?
from stencil-site.
Is there any update on this issue? I am also facing the same issue. In development bundle the icon shows up, but not in the production bundle.
from stencil-site.
@avrghz
I know it's late, but better than nothing...
How do you serve your production bundle? In my case, I was using VSCode's Live Server extension, which for some reason injects script tag with svg tag. And ion-icon doesn't accept that as the docs says. https://ionicons.com/usage#custom_icons
from stencil-site.
Same thing happened here, I added import 'ionicons';
in src/index.ts
, but ion-icon doesn't render an icon, just a div
from stencil-site.
And here it is late 2024 and there are still some things to work out in the documentation. For example, if you are adding ionicons to a stencil component, do you need to run npm install --save @ionic/core
as well and import that into your index.ts file? Yes, yes you do. Luckily for me miqmago documented it here.
That should be documented somewhere. It probably is and I missed it. But if @ionic/core is required by ionicons, shouldn't that be listed in ionicons' package.json and automatically installed like other dependencies?
I installed both @ionic/core and ionicons, imported both in my index.ts, and imported both into my component's tsx file. Stopped the server and did npm run build
and npm run start
and the icon finally appeared.
Too bad you can't do something nice and simple like style="color: blue;" in an ion-icon element, because that would be easy.
from stencil-site.
Related Issues (20)
- Redux docs page should be updated to use Redux Toolkit examples HOT 2
- The document home page has a bug HOT 2
- forceUpdate in documentation HOT 1
- Dependency Dashboard
- bug: Issue consuming components in an Angular 16 Project HOT 5
- bug: Documentation for array loops is wrong HOT 1
- `@Watch()` could have an example using a `@State()` in the documentation HOT 3
- Missing content in styleUrls docs HOT 2
- Docs: stencil-library reference HOT 1
- missing documentation for Angular 17's standalone mode HOT 1
- test bug HOT 1
- NextJS Integration Example with app router HOT 1
- testing automation - needs doc
- testing automation
- React Integration - the build doesn't include web component files HOT 4
- Improve `componentOnReady` suggestion note for non-lazy builds HOT 2
- `getElement` doc type mismatch
- Docs: components/properties.md - inconsistencies in the opening and closing tags of examples. HOT 1
- Framework integration docs out of date HOT 1
- error on templating-jsx page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stencil-site.