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

@depay/react-shadow-dom

v5.0.5

Published

A library to easily render react compatible shadow DOMs for web components with individual styling for inside and outside.

Downloads

1,041

Readme

Quick Start

yarn add @depay/react-shadow-dom
import { ReactShadowDOM } from '@depay/react-shadow-dom';
ReactShadowDOM({
  document,
  element,
  content,
  outsideStyle: outsideStyle,
  insideStyle: insideStyle
})

ReactShadowDOM

The function ReactShadowDOM renders a react compontent (content) into an insideContainer that lives inside a shadowRoot of the outsideContainer target element (element) within a given document (document) while also applying insideStyle to the insideContainer and outsideStyle to the outsideContainer.

content

You can either pas a ReactElement to content or a function. In case of a function that function will be call with the insideContainer as an argument and it's expected to return a ReactElement.

styles

While outsideStyle is applied to the outside container directly:

outsideStyle: `
  border: 1px solid red;
  color: black;
`
<div class="ReactShadowDOMOutsideContainer" style="border: 1px solid red;color: black;"></div>

insideStyle is wrapped in a style tag and prepend to the shadowRoot:

insideStyle: `
  .ReactShadowDOMInsideContainer {
    background: blue;
    color: white;
  }
`
#shadow-root
  <style type="text/css">.ReactShadowDOMInsideContainer {background: blue;color: white;}</style>
  <div class="ReactShadowDOMInsideContainer"><h1>I'm in a ShadowDOM</h1></div>

wich allows you to style all elements and classes within the shadowRoot.

classes

insideClasses sets classes on inside container:

insideClasses: ['contained', 'another-class']
#shadow-root
  <div class="ReactShadowDOMInsideContainer contained another-class"><h1>I'm in a ShadowDOM</h1></div>

unmount

In order to completly unmount everything (removing containers and unmounting React components), the ReactShadowDOM function returns an object containing an unmount function:


let { unmount } = ReactShadowDOM(...)

unmount()

Development

Get started

yarn install
yarn demo

Run tests

yarn test:integration

Debug tests

yarn test:cypress:debug 'cypress/integration/ReactShadowDOM.js'

Release

npm publish