@s-ui/react-primitive-injector

1.2.0 • Public • Published

PrimitiveInjector

Description

Installation

$ npm install @s-ui/react-primitive-injector

Usage

Basic usage

Import package and use the component

import Injector from '@s-ui/react-primitive-injector'
import {Fragment} from 'react'

const Component = ({
  children,
  className = 'injectorClassName',
  injectedProp = 'injectedProp',
  ignoredProp = false
}) => {
  return (
    <Injector
      className={className}
      injectedProp={injectedProp}
      ignoredProp={ignoredProp}
    >
      <Children className="childrenClassName" ignoredProp keptProp />
      <Fragment>
        <Children className="fragmentChildrenClassName" ignoredProp keptProp />
      </Fragment>
      {children}
    </Injector>
  )
}

The package also provides the default injector behavior as an equivalent function using:

import {inject} from '@s-ui/react-primitive-injector'

// inject(children<React.Node/>, settings<Array>{props, combine, proviso}</Array)

const Component = ({
  children,
  className = 'injectorClassName',
  injectedProp = 'injectedProp',
  ignoredProp = false
}) => {
  return inject(
    <>
      <Children className="childrenClassName" ignoredProp keptProp />
      <>
        <Children className="fragmentChildrenClassName" ignoredProp keptProp />
      </>
      {children}
    </>,
    [{props: {className, injectedProp, ignoredProp}}]
  )
}

Find full description and more examples in the demo page.

Readme

Keywords

none

Package Sidebar

Install

npm i @s-ui/react-primitive-injector

Weekly Downloads

2,496

Version

1.2.0

License

MIT

Unpacked Size

8.45 kB

Total Files

5

Last publish

Collaborators

  • thomas.page.ext
  • victoria.pasichnyk.ext
  • daniel.perez.ext
  • albert.peiro
  • frandelacasa-adevinta
  • mariapaula.forero.ext
  • hpintos_adevinta
  • sziauberyte
  • victor.perez.adevinta
  • oscar-raig-adevinta
  • carlos.gonzalezl
  • carolina.mallo.ext
  • david.nieto
  • ferran.simon
  • xavi_conejo
  • sergi.quintela
  • jamile.radloff
  • xavi_ballestar
  • luz_adv
  • ignacio.rodriguez
  • carlosvillu-adevinta
  • diegomr
  • arturo.vicente
  • adria.velardos
  • emiliovz
  • dann41
  • ruben-martin
  • pol.valls
  • cristina.rodriguez.duque
  • sergio.escano
  • marc.benito
  • azahara
  • patricio.sartore
  • giovanny.sayas.ext
  • david.cuadrado.ext
  • alex.castells
  • beatrizip
  • pablo.rey-adevinta
  • sergiocollado
  • mango.sanchezredondo
  • cristhianb
  • alisa_bayanova
  • davidmartin2108
  • ferrangbtw
  • estefania_garcia
  • belen.santos
  • alfredo.arronte
  • joanleon-adv
  • giodelabarrera.adevinta
  • luis-garrido
  • aitor.rodriguez
  • jordi.munoz
  • oscar_ramirez
  • ignacio_navarro
  • a.ferrer
  • gfabregoadv
  • izeller
  • salvador.juan
  • oriol.egea
  • ivanmlaborda
  • alejandro.ferrante
  • pa.chruscinski.ext
  • isabelgomez87
  • jenifer.lopez
  • daniela.aguilera
  • pablogs
  • javier.miguel
  • oscar.gomez
  • marian.lucaci
  • alverd004
  • oriol.puig
  • nacho_torrella
  • xavi.murcia
  • chloe.leteinturier
  • javiauso
  • alfredo.zimperz
  • francisco.ruiz.lloret
  • fermin.adevinta
  • andresadv
  • schibstedspain