1.44.7 • Published 4 years ago

@silver-labs/webex-components v1.44.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Webex Components is a set of React components following Webex standard styling, aimed at react developers that want to embed the components into their applications.

Table of Contents

Demo

We use Storybook to showcase all supported components. Our Storybook can be found at https://webex.github.io/components/storybook.

Install

npx install-peerdeps @webex/components

Usage

Styles

In order to properly style Webex Components, we need to import all the fonts, icons, images and core CSS manually. You will need to add Momentum UI's styles in addition to the components' styles. Momentum UI is Webex design system.

There are two ways to do this:

JavaScript

In your index.js, add the following imports:

import '@momentum-ui/core/css/momentum-ui.min.css';
import '@webex/components/dist/css/webex-components.css';

...

HTML

In the <head> of your index.html, add the following imports:

<head>
  ...

  <link rel="stylesheet" type="text/css" href="node_modules/@momentum-ui/core/css/momentum-ui.min.css" />
  <link rel="stylesheet" type="text/css" href="node_modules/@webex/components/dist/css/webex-components.css" />
</head>

Adapters

Webex Components are self-updating, meaning, they know how to fetch the data they need. Data is passed to components via adapter classes (see adapters). Adapters are an uniform interface for the Webex Components to consume. They also know how to map the data from their data source to the data the components need.

To use a Webex Component, start by creating a Webex Adapter:

import {WebexJSONAdapter} from '@webex/components';

const adapter = new WebexJSONAdapter(jsonData);

Adapters may interact with different data source types. For instance, as part of the Webex Component repository we distribute a JSON adapter that reads data from JSON files. We also are working on offering an adapter for the Webex browser SDK.

Components

Putting everything together - styles, adapters and components - this is a simple example of how using a component would look like:

import '@momentum-ui/core/css/momentum-ui.min.css';
import '@webex/components/dist/webex-components.css';

import React from 'react';
import ReactDOM from 'react-dom';
import {WebexAvatar, WebexDataProvider, WebexJSONAdapter} from '@webex/components';

const adapter = new WebexJSONAdapter(jsonData); // jsonData represents an opened file

ReactDOM.render(
  <WebexDataProvider adapter={adapter}>
    <WebexAvatar personID="XYZ" />,
  </WebexDataProvider>
  document.getElementById('root')
);

Happy Coding!

Contributing

We'd love for you to contribute to our source code and to make Webex Components even better than it is today! Here are some guidelines that we'd like you to follow.

Issues

Please open an issue and we will get to it in an orderly manner. Please leave as much as information as possible for a better understanding.

License

MIT License

Support

For more developer resources, tutorials and support, visit the Webex developer portal, https://developer.webex.com.