New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vonage/vivid-react

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/vivid-react

Vivid wrapped for easy React usage & IDE autocomplete support & typescript typings

  • 3.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
53
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

@vonage/vivid-react

Vivid-react is a script allowing you to generate Vivid-React components for the newest version of Vivid components stored as a package with all necessary dependencies and available through Artifactory npm registry.

The main goal of output package is to provide a better developer experience when using Vivid inside of React typescript applications. We still use regular Vivid web components, so be sure to target a recent browser.

Goals:

  • wrap adding handlers for events like change which natively doesn't work in the environment
  • mocks for Jest
  • typing support (prop-types or typescript)
  • a handy interface for initialisation (eg. fonts)
  • getting advantages of JSX/TSX (eg. composed components*)
  • all components within one package**
  • storybook acting as developer sandbox for presenting quick examples
  • one place for all future vivid-related code to use with React

*may provide a cut off at props inherited from MWC source.

**now also implemented in raw Vivid.

Similar strongly typed wrappers for other frameworks?

  • https://github.com/Vonage/vivid-vue

Why is this repository exists?

Using Web Components in React - Web Component Essentials

Supported components

Here's the list of all available wrappers, with the Vivid package name and version used to generate each one. If you need to use a different version of a Vivid component, simply add it to your application's package.json. Adding the resolutions field when using yarn might help get the correct version installed.

Component NamePackage NamePackage Version
VwcAccordion@vonage/vwc-accordion2.45.0
VwcActionGroup@vonage/vwc-action-group2.45.0
VwcBadge@vonage/vwc-badge2.45.0
VwcBanner@vonage/vwc-banner2.45.0
VwcButton@vonage/vwc-button2.45.0
VwcButtonToggleGroup@vonage/vwc-button-toggle-group2.45.0
VwcCalendar@vonage/vwc-calendar2.45.0
VwcCard@vonage/vwc-card2.45.0
VwcCarousel@vonage/vwc-carousel2.45.0
VwcCheckbox@vonage/vwc-checkbox2.45.0
VwcChips@vonage/vwc-chips2.45.0
VwcCircularProgress@vonage/vwc-circular-progress2.45.0
VwcDataGrid@vonage/vwc-data-grid2.45.0
VwcDatepicker@vonage/vwc-datepicker2.45.0
VwcDropdown@vonage/vwc-dropdown2.45.0
VwcElevation@vonage/vwc-elevation2.45.0
VwcEmptyState@vonage/vwc-empty-state2.45.0
VwcExpansionPanel@vonage/vwc-expansion-panel2.45.0
VwcFab@vonage/vwc-fab2.45.0
VwcFilePicker@vonage/vwc-file-picker2.45.0
VwcFormfield@vonage/vwc-formfield2.45.0
VwcHelperMessage@vonage/vwc-helper-message2.45.0
VwcIcon@vonage/vwc-icon2.45.0
VwcIconButton@vonage/vwc-icon-button2.45.0
VwcIconButtonToggle@vonage/vwc-icon-button-toggle2.45.0
VwcKeypad@vonage/vwc-keypad2.45.0
VwcLayout@vonage/vwc-layout2.45.0
VwcLinearProgress@vonage/vwc-linear-progress2.45.0
VwcList@vonage/vwc-list2.45.0
VwcMediaController@vonage/vwc-media-controller2.45.0
VwcMenu@vonage/vwc-menu2.45.0
VwcNotchedOutline@vonage/vwc-notched-outline2.45.0
VwcNote@vonage/vwc-note2.45.0
VwcPagination@vonage/vwc-pagination2.45.0
VwcPopup@vonage/vwc-popup2.45.0
VwcRadio@vonage/vwc-radio2.45.0
VwcSchemeSelect@vonage/vwc-scheme-select2.45.0
VwcSelect@vonage/vwc-select2.45.0
VwcSlider@vonage/vwc-slider2.45.0
VwcSnackbar@vonage/vwc-snackbar2.45.0
VwcSurface@vonage/vwc-surface2.45.0
VwcSwitch@vonage/vwc-switch2.45.0
VwcTabBar@vonage/vwc-tab-bar2.45.0
VwcTags@vonage/vwc-tags2.45.0
VwcText@vonage/vwc-text2.45.0
VwcTextarea@vonage/vwc-textarea2.45.0
VwcTextfield@vonage/vwc-textfield2.45.0
VwcThemeSwitch@vonage/vwc-theme-switch2.45.0
VwcTooltip@vonage/vwc-tooltip2.45.0
VwcTopAppBar@vonage/vwc-top-app-bar2.45.0
VwcTopAppBarFixed@vonage/vwc-top-app-bar-fixed2.45.0

If the one you're looking for is missing, just add a new one, so everyone can access them.

Installation

Just run:

$ yarn add @vonage/vivid-react

No need for importing vivid directly. The dependencies will be installed for you.

Initialization

import ReactDOM from 'react-dom'
import { initVivid } from '@vonage/vivid-react'
const rootElement = document.getElementById('react-root')
const renderApp = () => {
  // do some more initialization before rendering the main App
  ReactDOM.render(
    <App />,
    rootElement
  )
}

// for Vivid 2.x
initVivid(rootElement).then(renderApp)

// OR

// for Vivid 2.x + Vivid 3.x
initVivid(rootElement, () => {}, {
  font: 'oss',
  theme: 'light'
}).then(renderApp)

Importing

For vivid 2.x Instead of importing each vivid component from @vonage/vwc-*, import them from @vonage/vivid-react instead.

import VwcCheckbox from '@vonage/vivid-react/VwcCheckbox'
import VwcSlider from '@vonage/vivid-react/VwcSlider'

For vivid 3.x

import VwcCheckbox from '@vonage/vivid-react/v3/VwcCheckbox'
import VwcSlider from '@vonage/vivid-react/v3/VwcSlider'

Bundling

This package is an ES module, so you might need to add some configuration to your bundling process.

Testing

If you have problems rendering vivid when using Jest/Enzyme combo, you can add this to your package.json to replace all Vivid wrapped components with an empty React component. It'll work also for raw vivid components used in project, since js-dom doesn't support shadow DOM.

{
  "jest": {
    "moduleNameMapper": {
      "@vonage\/(vwc|vvd)": "@vonage/vivid-react/testing/component.mock.js"
    },
  "transformIgnorePatterns": [
      "node_modules/(?!(@cct|@vonage|@lit|lit-html|lit-element)/)"
    ]
  }
}

Development

Adding a component

Follow the steps:

  • clone this repo
  • create a branch
  • add the missing vivid component as a dependency in package.json
  • create a new PR and get it merged to master
  • publish new version
  • install the new package in your application

Publishing a new version

When you want to release the latest changes, checkout the latest master branch and run:

$ yarn version --new-version {minor/major/patch}

Selecting new version number:

  • patch - fixing some small issue, without new functionality
  • minor - after adding support for a new component, or adding a new awesome feature
  • major - after breaking or major package changes

Storybook

For test/development storybook is in game. Stories are generated automatically per component with no arguments/properties, fill them before using component.

Compound Components

In the scripts/generateWrappers/consts.js you can define sets of compound components. All they do is filling default props. They are accessible after a dot:

<VwcButton.Alert />

This is the end

Keywords

FAQs

Package last updated on 07 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc