1.1.4 • Published 7 months ago

@phemium-costaisa/phemium-web-components-v2 v1.1.4

Weekly downloads
59
License
MIT
Repository
-
Last release
7 months ago

PhemiumWebComponentsV2

This is a collection of web components generated with Angular Elements (Angular CLI version 9.1.1).

Note: The output of each component is an ES2015 bundle, so supported browsers are the ones compatibles with this EcmaScript version.

Installation

The first step to use the Phemium Web Components v2 is to download the dependency. Using npm you must execute:

 npm i @phemium-costaisa/phemium-web-components-v2

Angular 2+

  • Add the javascript file of the web component you want to use in the scripts section of 'angular.json' file.

               "scripts": [
                "node_modules/@phemium-costaisa/phemium-web-components-v2/build/components/tuningApp/element/phemium-tuningApp-es2015.js"
              ],
  • In the same file and in the assets section, you must add these lines to use the assets.

     "assets": [
                {
                  "glob": "**/*",
                  "input": "node_modules/@phemium-costaisa/phemium-web-components-v2/build/components/tuningApp/assets",
                  "output": "assets"
                },
              ]
  • Same for styling in the styles section.

    "styles": [
                {
                  "input": "node_modules/@phemium-costaisa/phemium-web-components-v2/build/components/tuningApp/styles/styles.css"
                }
              ]
  • In your page modules definition you'll need to add CUSTOM_ELEMENTS_SCHEMA to your available schemas (e.g. app.module.ts):

    import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
    
    // Other imports and declarations
    
    @NgModule({
      declarations: [AppComponent],
      providers: [
        StatusBar,
        SplashScreen,
        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
        Push,
      ],
      bootstrap: [AppComponent],
      schemas: [CUSTOM_ELEMENTS_SCHEMA] // <-- Add Here!
    })

Environment installation

  • Install NodeJS (latest version)
  • Install NPM dependencies
npm install
  • Install Bower dependencies
npx bower -- install

Development server

Run ng serve [project] for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Local development for the videocall library:

npm run build:videocall
sudo npm link ./dist/videocall

// TODO Gulp task to copy index.js from the phemium softphone library to projects/videocall/assets/scripts, minify and rename it to softphone.js.

If you need to watch for the changes in a library first execute npm run build:watch:videocall followed by npm run build:scss in another terminal to copy the global styles and finally run ng serve videocallApp -o for the videocall App to see the changes.

Steps to create a new Custom Element into this library

  • Run ng generate application newApp (inside projects folder), where newApp is the name of the new application that will be used to create the new Custom Element/Web Component.
    • Remember to answer "NO" to the question: Would you like to add Angular routing?.
    • Use SCSS for your styles.
  • In package.json add script build:newApp:element (take tuningApp as reference), and add this new script into build:all:element.
  • Use the content of projects/tuningApp/src/app/app.module.ts again as reference for projects/newApp/src/app/app.module.ts:
constructor(private injector: Injector) {}

  ngDoBootstrap() {
    const customComponentElement = createCustomElement(CustomComponent, {
      injector: this.injector,
    });
    customElements.define('custom-element-tag', customComponentElement);
  }
}
  • Create file projects/newApp/src/package.json. Use some existing custom elements as reference.
  • Create file projects/newApp/src/README.md. Use some existing custom elements as reference.
  • Add projects/newApp/src/package.json and projects/newApp/src/README.md in section assets of angular.json.
  • Create file build/components/newApp/index.html. Use some existing custom elements as reference.

Build bundles for a specific project

Run npm run build:<componentNameApp>:element. So, for phemiumTuning run npm run build:tuningApp:element. The build artifacts will be stored in the dist/<componentNameApp> directory and merged into a ES6 bundle, located in directory build/components/<componentNameApp>:

  • build/components/componentNameApp/phemium-<componentNameApp>-es2015.js.

Folder assets will be also copied from dist/<componentNameApp>/assets to build/components/<componentNameApp>/assets.

To run the final build/components, run:

$ cd build/components/<componentNameApp>
$ http-server .

or, if having a ssl certificate:

$ http-server -S -C localhost.pem -K localhost-key.pem

And navigate to http://localhost:8080 (phemiumTuning needs to be run under a localhost or https)

Build bundles for all web components at once

Run npm run build:all:element. This will run the script described in the previous step for every single web component.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running unit tests for a specific project

Run ng test --project <componentNameApp>.

For example, run ng test --project tuningApp.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Publish to npm

There are two ways to publish the web components to npm. You can do it locally:

  • Run npm run build:all:element to build all bundles.
  • Run npm login using the phemium costaisa credentials.
  • Run npm publish --access public.

Or you can create a tag with the required version in 'package.json' file.

To publish the videocall library you need to change the version in 'package.json' file and then you must do it locally using the following commands:

npm run build:videocall
cd dist/videocall
npm publish --access public

To publish the card-viewer library you need to change the version in 'package.json' file and then you must do it locally using the following commands:

npm run build:card-viewer
cd dist/card-viewer
npm publish --access public

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

1.0.0-jenkins

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

8 months ago

1.0.0

10 months ago

0.9.0

11 months ago

0.8.0

12 months ago

0.7.0

12 months ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago