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

@rndm/render-plugin-multivariant

v0.1.1

Published

RNDM Render Plugin: Multivariant. State-based variable changes for RNDM Render

Downloads

5

Readme

RNDM Render Plugin: Multivariant

About

This plugin provides functionality for RNDM Render package by allowing the user to define state based properties that can determine layout or functionality.

Installation

If you have not already done so, then please ensure you have installed the RNDM Render as well as the following RNDM packages:

From NPM

npm install --save @rndm/render-plugin-multivariant

Post Installation

In order to allow this plugin to work, it must first be included in your project. You can do this inside your main index file:

import '@rndm/render-plugin-multivariant';

Usage

Multivariant is a simple Redux wrapper plugin that takes the redux state and allows comparison of values to change the format of preferred RNDM JSON.

This type of construct allows for your application to start defining layouts, properties and user journeys based a variety of factors including User identifiers, signed-in states, A/B testing, screen dimensions, platform specific code or more.

Example

{
    "type": "multivariant.Multivariant",
    "props": {
        "rndm": {
            "type": "react-native.View",
            "props": {
                "children": {
                    "type": "react-native.Text",
                    "props": {
                        "children": "Desktop or Laptop"
                    }
                }
            }
        },
        "args": [{
            "variants": [{
                "getter": "application.window.width",
                "operator": "<=",
                "value": 800
            }],
            "setters": {
                "props.children.props.children": "Tablet"
            }
        }, {
            "variants": [{
                "getter": "application.window.width",
                "operator": "<=",
                "value": 400
            }],
            "setters": {
                "props.children.props.children": "Phone"
            }
        }]
    }
}

The above example uses an identifier that hooks into the application window width and provides a different user experience based on the width at that time.

Please Note: Variants are joined together using AND. This means that each variant added will add exclusivity.

Please Note: The ordering of the args and variants are important. The latter args and variants take precedence over the those that come before.

A/B Testing

This plugin includes a simple piece of middleware that will generate a unique user identifier for test purposes. When included as part of your redux middleware, it will attempt to fetch the ID from the local storage, and upon failure, generate a new one and persist this.

In order to include this, you can do the following inside your redux/middleware/index.js file:

import { multivariant } from '@rndm/render-plugin-multivariant';

const middleware = [
    // ... all other middlewares
    multivariant
]

Available Operators

  • '===': Used to define if two values equal each other

  • '>': Used to define if the getter item is greater than the input value

  • '>=': Used to define if the getter item is greater than or equal to the input value

  • '<': Used to define if the getter item is less than the input value

  • '<=': Used to define if the getter item is less than or equal to the input value

  • '!!': Used to define if the getter item exists

  • '!': Used to define if the getter item does not exist

  • 'includes': Used to define if the getter item includes the input value (Array or String)

  • 'startsWith': Used to define if a the getter item starts with the input value (String)

  • 'endsWith': Used to define if a the getter item ends with the input value (String)

  • 'typeOf': Used to define if a the getter item is a type of input value (String)

Check out the Playground page to see how these features work.