2.0.11 • Published 3 years ago

@k3imagine/web-components v2.0.11

Weekly downloads
294
License
ISC
Repository
github
Last release
3 years ago

Web Components for Imagine

Build

Here's where we'll have all of the components for Imagine, they're to be written in Stencil and deployed to it's own npm module to be used on our projects

Running the project

To run project first clone it to your local hard drive. Then run the following commands:

npm install
npm start

You can now access it on http://localhost:9009

Versioning

  • The patch version of the web components is incremented automatically when a PR is merged.
  • If a breaking change is being introduced in the project, adding the 'major' label to the PR will increment the major version.
  • If a new feature is being introduced in the project, adding the 'minor' label to the PR will increment the minor version.

Creating a new component

Step 1

First find the component in the Zeplin project (request access in the closed #newux channel on Slack). The component will be in a screen named either:

  • Complex Components
  • Simple Components
  • Structure Components

Locate which screen the component is on.

Step 2

In the folder src/components/{screen-name} create a new folder: im-{component-name}.

Step 3

Create 3 new files inside this folder:

{tag}.stories.js

import { storiesOf } from "@storybook/polymer";
const stories = storiesOf("{section}|{component-name}", module);

{tag}.tsx

import { Component } from "@stencil/core";

@Component({
   tag: "{tag}",
   styleUrl: "{tag}.scss"
})
export class {tag | pascal-cased} {

   render() {
      return (<div></div>);
   }
}

{tag}.scss

Step 4

Start developing!

Using the components in our projects

This needs to be done on every project where the components are to be used, regardless of library.

Step 1

Get access to our organisation on https://npmjs.com, create a token for you profile and set it as an environment variable on you machine, with the name NPM_TOKEN.

Step 2

Create a file in the root of your project: .npmrc

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Step 3

Install the dependency: npm install --save @k3imagine/web-components.

Step 4

Update the Dockerfile so that the NPM_TOKEN variable is exposed and the .npmrc file is copied over.

FROM node:latest as builder

ARG NPM_TOKEN

WORKDIR app

COPY .npmrc ./

Using the components in an Angular project

For projects that use Angular 2+ follow these steps:

Step 1

In your angular.json file, in the array projects.architect.build.options.assets add the following entry:

{
  "glob": "**/*",
  "input": "./node_modules/@k3imagine/web-components/dist/collection/assets",
  "output": "./assets/"
}

Step 2

In your src/main.ts file add the following import:

import { defineCustomElements } from "@k3imagine/web-components/dist/loader";

At the bottom of the file, add the following line:

defineCustomElements(window);

Step 3

In the module you want to use the Stencil components add the CUSTOM_ELEMENTS_SCHEMA import from @angular/core. Then add the following property to the options inside the NgModule decorator:

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  ...
})

Step 4

Start developing with the components!

Using the components in an AngularJS project

For projects that use Angular 1.x follow these steps:

Step 1

Update the package.json file to only have the new components under dependencies, with the rest being on devDependencies:

{
  "dependencies": {
    "@k3imagine/web-components": "^0.4.5"
  },
  "devDependencies": {
    "...the rest of the libraries": "Go here"
  }
}

Step 2

Install the library used to copy the files npm install --save-dev gulp-npm-dist

Step 3

Add a new command into gulp to copy the component library into the public folder:

gulp.task("copy:libs", function () {
  return gulp
    .src(npmDist(), { base: "./node_modules" })
    .pipe(gulp.dest("./public/libs"));
});

Then you can add it into the build flow like so:

gulp.series(
  "clean:public",
  "sass",
  gulp.parallel("copy:html", "copy:assets", "copy:libs")
);

Step 4

Add a reference the component library on the project's index.html headers

<script src="/libs/@k3imagine/web-components/dist/components.js"></script>

Steps 5

Start developing with the components!

Examples

Here are some examples on how to use the components on both Angular and angularJS

Angular (2+)

<im-data-table
  [model]="model"
  [data]="data"
  (action)="action($event)"
></im-data-table>

AngularJS (1.x)

<im-data-table
  ng-prop-model="$ctrl.model"
  ng-prop-data="$ctrl.data"
  ng-prop-options="$ctrl.options"
  ng-on-action="$ctrl.action($event)"
></im-data-table>

Upgrade to v1.0+

As part of the update to v1.0 of the web components was the addition of a new top and sidebar, as well rectifying some issues and warnings that were showing up in the build logs around the use of reserved and conflicting properties. When upgrading in a ui project that was using the web components prior to v1.0 the following properties would need to be changed in the UI project if they have been binded.

im-picklist

  1. The event "error" has been renamed "componentError"

im-sidebar-old

  1. The event "error" has been renamed "componentError"

im-sidebar

  1. The event "error" has been renamed "componentError"

im-button

  1. The event "onClick" has been renamed "buttonClick"

im-icon

  1. The event "onClick" has been renamed "iconClick"

im-number-picker

  1. The event "error" has been renamed "componentError"

im-input

  1. The event "error" has been renamed "componentError"

im-title

  1. The property "id" has been renamed "tileId"

The implementation of the sidebar and topbar can be found in the readme files found in each of the new component directories "src/components/complex/im-sidebar" and "src/components/complex/im-top-menu"

2.0.11

3 years ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.8

3 years ago

1.0.32

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.31

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.17

3 years ago

1.0.15

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.9.138

3 years ago

0.9.137

4 years ago

0.9.136

4 years ago

0.9.135

4 years ago

0.9.134

4 years ago

0.9.132

4 years ago

0.9.131

4 years ago

0.9.130

4 years ago

0.9.129

4 years ago

0.9.128

4 years ago

0.9.127

4 years ago

0.9.126

4 years ago

0.9.125

4 years ago

0.9.124

4 years ago

0.9.123

4 years ago

0.9.122

4 years ago

0.9.121

4 years ago

0.9.120

4 years ago

0.9.119

4 years ago

0.9.118

4 years ago

0.9.117

4 years ago

0.9.116

4 years ago

0.9.115

4 years ago

0.9.114

4 years ago

0.9.113

4 years ago

0.9.112

4 years ago

0.9.111

4 years ago

0.9.110

4 years ago

0.9.109

4 years ago

0.9.108

4 years ago

0.9.107

4 years ago

0.9.106

4 years ago

0.9.105

4 years ago

0.9.104

4 years ago

0.9.103

4 years ago

0.9.102

4 years ago

0.9.101

4 years ago

0.9.100

4 years ago

0.9.99

4 years ago

0.9.98

4 years ago

0.9.97

4 years ago

0.9.96

4 years ago

0.9.95

4 years ago

0.9.94

4 years ago

0.9.93

4 years ago

0.9.92

4 years ago

0.9.91

4 years ago

0.9.89

4 years ago

0.9.88

4 years ago

0.9.86

4 years ago

0.9.85

4 years ago

0.9.84

5 years ago

0.9.83

5 years ago

0.9.82

5 years ago

0.9.81

5 years ago

0.9.80

5 years ago

0.9.79

5 years ago

0.9.78

5 years ago

0.9.77

5 years ago

0.9.76

5 years ago

0.9.75

5 years ago

0.9.74

5 years ago

0.9.73

5 years ago

0.9.72

5 years ago

0.9.71

5 years ago

0.9.70

5 years ago

0.9.69

5 years ago

0.9.68

5 years ago

0.9.67

5 years ago

0.9.66

5 years ago

0.9.65

5 years ago

0.9.64

5 years ago

0.9.63

5 years ago

0.9.62

5 years ago

0.9.61

5 years ago

0.9.60

5 years ago

0.9.59

5 years ago

0.9.58

5 years ago

0.9.57

5 years ago

0.9.56

5 years ago

0.9.55

5 years ago

0.9.54

5 years ago

0.9.53

5 years ago

0.9.52

5 years ago

0.9.51

5 years ago

0.9.50

5 years ago

0.9.49

5 years ago

0.9.48

5 years ago

0.9.47

5 years ago

0.9.46

5 years ago

0.9.45

5 years ago

0.9.44

5 years ago

0.9.43

5 years ago

0.9.42

5 years ago

0.9.41

5 years ago

0.9.40

5 years ago

0.9.39

5 years ago

0.9.38

5 years ago

0.9.37

5 years ago

0.9.36

5 years ago

0.9.35

5 years ago

0.9.34

5 years ago

0.9.33

5 years ago

0.9.32

5 years ago

0.9.31

5 years ago

0.9.30

5 years ago

0.9.29

5 years ago

0.9.28

5 years ago

0.9.27

5 years ago

0.9.26

5 years ago

0.9.25

5 years ago

0.9.24

5 years ago

0.9.23

5 years ago

0.9.22

5 years ago

0.9.21

5 years ago

0.9.20

5 years ago

0.9.19

5 years ago

0.9.18

5 years ago

0.9.17

5 years ago

0.9.16

5 years ago

0.9.15

5 years ago

0.9.14

5 years ago

0.9.13

5 years ago

0.9.12

5 years ago

0.9.11

5 years ago

0.9.10

5 years ago

0.9.9

5 years ago

0.9.8

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.8.114

5 years ago

0.8.113

5 years ago

0.8.112

5 years ago

0.8.111

5 years ago

0.8.110

5 years ago

0.8.109

5 years ago

0.8.108

5 years ago

0.8.107

5 years ago

0.8.106

5 years ago

0.8.105

5 years ago

0.8.104

5 years ago

0.8.103

5 years ago

0.8.102

5 years ago

0.8.101

5 years ago

0.8.100

5 years ago

0.8.98

5 years ago

0.8.97

5 years ago

0.8.96

5 years ago

0.8.95

5 years ago

0.8.94

5 years ago

0.8.93

5 years ago

0.8.92

5 years ago

0.8.91

5 years ago

0.8.90

5 years ago

0.8.89

5 years ago

0.8.88

5 years ago

0.8.87

5 years ago

0.8.86

5 years ago

0.8.85

5 years ago

0.8.84

5 years ago

0.8.83

5 years ago

0.8.82

5 years ago

0.8.81

5 years ago

0.8.80

5 years ago

0.8.79

5 years ago

0.8.78

5 years ago

0.8.77

5 years ago

0.8.76

5 years ago

0.8.75

5 years ago

0.8.74

5 years ago

0.8.73

5 years ago

0.8.72

5 years ago

0.8.71

5 years ago

0.8.70

5 years ago

0.8.69

5 years ago

0.8.68

5 years ago

0.8.67

5 years ago

0.8.66

5 years ago

0.8.65

5 years ago

0.8.64

5 years ago

0.8.63

5 years ago

0.8.62

5 years ago

0.8.61

5 years ago

0.8.60

5 years ago

0.8.59

5 years ago

0.8.58

5 years ago

0.8.56

5 years ago

0.8.55

5 years ago

0.8.54

5 years ago

0.8.53

5 years ago

0.8.52

5 years ago

0.8.51

5 years ago

0.8.50

5 years ago

0.8.49

5 years ago

0.8.48

5 years ago

0.8.47

5 years ago

0.8.46

5 years ago

0.8.45

5 years ago

0.8.44

5 years ago

0.8.43

5 years ago

0.8.42

5 years ago

0.8.41

5 years ago

0.8.40

5 years ago

0.8.39

5 years ago

0.8.38

5 years ago

0.8.37

5 years ago

0.8.36

5 years ago

0.8.35

5 years ago

0.8.34

5 years ago

0.8.33

5 years ago

0.8.32

5 years ago

0.8.31

5 years ago

0.8.30

5 years ago

0.8.29

5 years ago

0.8.28

5 years ago

0.8.27

5 years ago

0.8.26

5 years ago

0.8.25

5 years ago

0.8.24

5 years ago

0.8.23

5 years ago

0.8.22

5 years ago

0.8.21

5 years ago

0.8.20

5 years ago

0.8.19

5 years ago

0.8.18

5 years ago

0.8.17

5 years ago

0.8.16

5 years ago

0.8.15

5 years ago

0.8.14

5 years ago

0.8.13

5 years ago

0.8.12

5 years ago

0.8.11

5 years ago

0.8.10

5 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.6.15

5 years ago

0.7.0

5 years ago

0.6.13

5 years ago

0.6.12

5 years ago

0.6.11

5 years ago

0.6.10

5 years ago

0.6.9

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.13

5 years ago

0.5.12

5 years ago

0.5.11

5 years ago

0.5.10

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.3.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago