DEV Community

Cover image for Component Libraries with Stencil.js - Decorators

Component Libraries with Stencil.js - Decorators

John Woodruff on November 18, 2018

This is the fifth in a series of posts about creating a web component library using Stencil.js - Check out the first post At this point we've buil...
Collapse
 
kusaljay profile image
kusaljay

Hi John,
Do you have a link to the github repo? Cheers,

Collapse
 
johnbwoodruff profile image
John Woodruff

My goodness I meant to put that up ages ago! I guess life happened. Let me try to track it down, and I'll toss it up on GitHub for you to see! 👍

Collapse
 
johnbwoodruff profile image
John Woodruff

Okay @kusaljay it took me a bit but I finally got it put up! Check it out: Mountain UI

Thread Thread
 
kusaljay profile image
kusaljay

Thanks John, your prompt response is much appreciated :)

Thread Thread
 
johnbwoodruff profile image
John Woodruff

Not nearly as prompt as I would've liked but at least it's finally done! 😅

Thread Thread
 
kusaljay profile image
kusaljay • Edited

@johnbwoodruff Can you please shed some light on how we can use Stencil components (like the ones you've created here) in React projects created using CRA?

Thread Thread
 
jdnichollsc profile image
J.D Nicholls

You can reuse web components from React components too, check this example: github.com/proyecto26/ion-phaser/b...

Collapse
 
citscibio1 profile image
CITSCIBIO

Great series. I wonder if you could help out continue working on your code. I tried to implement stitching the tabs and in the tabs.tsx file's render function I want to display the innerHTML of the tab tag. It displays text, but if I have something like


the other tag is not rendered. How can I get the inner contents of the in the and display it with proper rendering? I.e. I want to implement switching tabs and display all the content of the tab properly rendered. Thanks!

Collapse
 
johnbwoodruff profile image
John Woodruff

Thanks for the comment! Unfortunately at this time I'm not working on this content and don't have any plans to for the near future. That being said, if you're working with Stencil and have questions on how to do things, I HIGHLY recommend checking out the ionic-framework repository. They have a massive component library and it's all built with Stencil best practices. (they did create Stencil for their framework after all!) They've got their tabs component you can reference, and it'll be far better than what I could recommend. :)

Collapse
 
lalitkushwah profile image
LalitKushwah

Hey John,
Great article, Can you please share what are the usage of host, assetDir and assetDirs in component decorator

Collapse
 
johnbwoodruff profile image
John Woodruff

Sorry this is months late, life got crazy and now here we are haha. The host property is replaced with the <Host> virtual component. This allows you to specify attributes and classes on the host element itself rather than the containing elements. See the docs for details.

As for assetDirs, it allows you to specify directories from which assets your component uses such as images come from.