npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

game-webcomponents

v0.0.3

Published

game webcomponents

Downloads

1

Readme

WEM Web Components

Components that are specific to workforce engagement management (WEM) should live here.

Any common components that exist in the Genesys styleguide should go in the genesys-webcomponents repository instead.

Demo

A live demo of the latest package can be seen here.

TOC

Development

Please read the Contributing Guidelines before starting development work.

Before you start! Make sure that you have installed ESLint on VSCode.

We require Node and npm to run this project. At the time of writing the versions being used are:

Node: v10.15.3
Npm : v6.4.1

Once Npm is installed, run:

npm i -g eslint

Make sure your .npmrc file is set up correctly setting up this project!

Using this project

In order to import these components into other frontend projects you will need to add a devDependency to your package.json

"devDependencies": {
    "@genesys/wem-webcomponents": "x.xx.x",
    ...
}

To use this dependency please use the install command of your package manager.

To test local changes in PCBA, you can do this:

wem-webcomponents> npm run build
wem-webcomponents> npm link
pure-cloud-browser-app> npm link @genesys/wem-webcomponents
pure-cloud-browser-app> grunt local

Dependencies

Before running this project make sure you have pulled the required dependencies by running:

npm install

Run Storybook

To view the list of component stories run the following command:

npm run dev

this will begin a build task along with adding a watcher and serving you the storybook on this url: http://localhost:9002

The watcher will allow you to make changes on the fly without the need to restart the npm task, but you will still need to refresh the browser. You should use this command when developing.

You can test dark theme in storybook using the right hand side knobs menu.

Build

In order to build the dist output folder execute the command:

npm run build

Note: This is done at the start of the npm run dev task.

This task will compile a dist folder for you along with regenerating any readme documentation for the components and the i18n translations

Create a new component

You can get npm to automatically create a new component for you by running:

npm run create-component
  • Component - a generic reusable control
  • Feature Component - a feature specific control with business logic
  • Rich Component - ???

You can also do this manually by creating a folder in either src/components/feature/<componentName> or src/components/global/<componentName> and then creating the required folders / files within it.

Below is an example for the wem-annotations component structure:

src/components/feature/wem-annotations/wem-annotations.tsx
src/components/feature/wem-annotations/wem-annotations.less
src/components/feature/wem-annotations/wem-annotations.i18n.json
src/components/feature/wem-annotations/stories/story.tsx
src/components/feature/wem-annotations/tests/wem-annotations.e2e.ts
src/components/feature/wem-annotations/tests/wem-annotations.spec.ts
src/components/feature/wem-annotations/readme.md

You can create additional sub-folders as required. To capture child components or data types you could organise the directories as follows:

src/components/feature/wem-annotations/data-types/Annotations.ts
src/components/feature/wem-annotations/data-types/AnnotationStatus.ts
src/components/feature/wem-annotations/wem-annotation-item/...

New components will require the translations team to link it to transifex. Once a new component is in master create a ticket similar to this one https://inindca.atlassian.net/browse/LOCAL-7595

How to do the commit

To do the git commits you should use the command npm run commit. And then follow the instructions on the terminal. This helps to identify the version number for releasing this library. And also helps in keeping the changelog for the library.

Documentation

When creating a new component, all of your Prop's, Event's and Listener's should have a doc string above it to explain what it does along with the params. A readme is generated for each component on a npm run build and will contain your docstrings.

Localizing your component

Documentation about localizing components can be found in the wiki

Each component should includeone or more <componentName>.i18n.<langCode>.json file. these files store your translation key / value objects for each component to indicate the supported languages. The default supported language is English and the file should be named <componentName>.i18n.json. To provide additional localizations you need to provoide new files with the correct lang code and values: For example:

wem-annotations.i18n.fr.json
wem-annotations.i18n.de.json
...

To use the new translations include the following lines to your component.tsx::

import annotationResources from './wem-annotations.i18n.json';
...

private i18n: (resourceKey: string, context?: any) => string;
async componentWillLoad() {
    this.i18n = await buildI18nForComponent(this.root, annotationResources);
    ...
}

Then call the i18n method with your json key and pass in any variables through the context paramter as an object. For example:

// inside component
this.i18n('error.http.generic', { code: 'someCode', message: 'someMessage' });

// inside json
"error.http.generic": "code: {code} - message: {message}",

Deployment

JFrog

We upload our versions to the Genesys private JFrog repo. This allows other projects within Genesys to pull down our package and make use of it - without it being made public.

Jenkins

We use Jenkins to throw up our version to JFrog. To make sure you use the latest version inspect the package.json of Master.

Testing

There are two types of tests:

  • end to end tests (e2e tests)
  • spec tests (unit tests)

Spec tests do not render a DOM and are completely JS to JS relation. We use spec tests to prove the JS functionality of our components. Spec tests are mostly quicker than E2E as they do not require a full instance Puppeteer to be running.

E2e tests render a DOM and can interact with it. This is mainly used to check the rendering of components.

Running tests

To execute all e2e and spec tests for every component run:

npm run test

To just run one type of tests:

For running just spec tests:
npm run test.unit

For running just e2e tests:
npm run test.e2e

To run a single test suite:

npm run test.unit wem-annotations
npm run test.e2e wem-annotations

Creating new tests

The spec tests should use a beforeEach which instantiates the component you are testing. For example:

beforeEach(async () => {
    component = new WemCoachingWizard();
    component.agents = [{ name: 'Agent One', id: '1' }];
    component.coachingService = new MockCoachingService();
    await component.componentWillLoad();
});

Then you can start calling functions and props on the component. For example:

it('does not allow a length greater than 60', () => {
    component.lengthInMinutes = 61;  // lengthInMinutes is a prop on wem-annotaitons
    component.watchLengthHandler();
    expect(component.lengthValid).toBeFalsy();
});

For E2e tests you shouldn't use the default puppeteer page. you should instead use the wemE2EPage which creates the DOM and your component for you:

import { wemE2EPage } from '../../../../utils/E2EWrapper';
...

beforeEach(async () => {
page = await wemE2EPage(`<wem-coaching-wizard></wem-coaching-wizard>`);
    wizard = await page.find('wem-coaching-wizard');
    await page.waitForChanges();
});

The reason for using wemE2EPage and not the default puppeteer page is due to an import of the Genesys WebComponents being required. Instead of this being handle in every test's beforeEach, it is handled in the wemE2EPage instead.