@wissen-libs/wissen-ui-lib
v0.0.5
Published
Wissen web component library
Downloads
108
Readme
@wissen-libs/wissen-ui-lib (Wissen UI library)
Getting Started
To start building a new web component using Stencil, clone this repo to a new directory: and run:
npm installTo build the component for production, run:
npm run buildTo run the unit tests for the components, run:
npm testTo run the local build in watch mode, run:
npm startTo open storybook, run:
npm run storybookNaming Components
We recommend prefix the component name with ws- untill it is decided otherwise.
Publishing and consuming the components
Publish the package to @wissen-libs/wissen-ui-lib
Install the package
npm install @wissen-libs/wissen-ui-lib --saveConsuming in React
Add the changes in index.js
import { applyPolyfills, defineCustomElements } from "@wissen-libs/wissen-ui-lib/loader";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
applyPolyfills().then(() => {
defineCustomElements(window);
});use web component anywhere in JSX
<div>
<ws-input value ="wissen" />
</div>Consuming in Angular
Add the changes in main.ts of angular app
import { defineCustomElements } from '@wissen-libs/wissen-ui-lib/loader';
defineCustomElements();Add CUSTOM_ELEMENTS_SCHEMA to app.module.ts
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';Add CUSTOM_ELEMENTS_SCHEMA as schema in @NgModule
Then you can use the element anywhere in your template, JSX, html etc
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})