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

react-components-transition

v4.0.13

Published

A very small but useful React component, which allows to smart transition between components without adding unnecessary state's hooks to render conditionally

Downloads

48

Readme

React components transition live example!

Scroll down to updates and issues

Use case

A very small but useful React component, which allows to smart transition between components without adding unnecessary state's hooks to render conditionally

Something like React router but simplified and without rendering based on URL. Just more static

Instaling

  npm i react-components-transition

Usage

Initializing

  import { ComponentsTransition } from "react-components-transition";

  const Component () => {


    const firstVisibleChildKey = "example2"

    return (
      <>
        <ComponentsTransition firstVisible={firstVisibleChildKey}>

          {/* At Least 2 components and first given is visible on first render if not specified in 'firstVisible' prop */}

          <Exmaple1 key="example1"></Example>
          <Exmaple2 key="example2"></Example>
        </ComponentsTransition>
      </>
    );
  }

Switching component

  import { TransitionButton } from "react-components-transitionn";

  const componentKey = "example2"

  const Example1 = () => {
    return <TransitionButton show={componentKey}>Show example 2 component</TransitionButton>
  }

Or with animations

  import { TransitionButton } from "react-components-transitionn";

  const componentKey = "example2"

  const Example1 = () => {
    return (
      <TransitionButton show={componentKey}
      animationIn={{ className: "animationIn", duration: 500 }}     // Animation in to new rendered child
      animationOut={{ className: "animationOut", duration: 500 }}>  // Animation out to already rendered child

        Show example 2 component
      </TransitionButton>
    );
  };

In css

/* CSS file of Exmaple1 component */

/* Remember to give unique animation name!!! */

@keyframes animationOut {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(0);
  }
}

.animationOut {
  transform: scale(1);
  animation: animationOut 500ms forwards;
}
/* CSS file of Exmaple2 component */

/* Remember to give unique animation name!!! */

@keyframes animationIn {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

.animationIn {
  transform: scale(0);
  animation: animationIn 500ms forwards;
}

Manipulate from outside

  import { ComponentsTransition, TransitionChild } from "react-components-transition";

  const Component () => {

    return (
      <>
        <ComponentsTransition>

          // Remember to give unique key

          <TransitionChild isStatic={true} key="OutsideComponentWrapper">
            <OutsideComponent key="OutsideComponent"></OutsideComponent>
          </TransitionChild>

          <Exmaple1 key="example1"></Example>
          <Exmaple2 key="example2"></Example>
        </ComponentsTransition>
      </>
    );
  }

Or

  import { ComponentsTransition, TransitionChild } from "react-components-transition";

  const Component () => {
    const divRef = useState(null)

    return (
      <>
        <div ref={divRef}></div>
        <ComponentsTransition>

          // Remember to give unique key

          <TransitionChild key="OutsideComponentWrapper" isStatic={true} renderTo={divRef}>
            <OutsideComponent key="OutsideComponent"></OutsideComponent>
          </TransitionChild>

          <Exmaple1 key="example1"></Example>
          <Exmaple2 key="example2"></Example>
        </ComponentsTransition>
      </>
    );
  }

Last update 3.1.0

  • Added possibility to choose context on button (f.e if u want to use other transition context in other ComponetsTransition)

Update 2.4.1 -> 2.4.7

  • Added possibility to choose render first child

Update 2.4.0

  • Fixed issues with styling (every given child in was wrapped into single div element what leads to styles problems)

Update 2.3.0

  • Changed animation. It is possbile now to give an "animationIn" and "animationOut"

Update 2.1.0 -> 2.2.1

  • Now is possible to manipulate children from outside element which is always visible
  • And move out from ComponentsTransition

Update 2.0.2 -> 2.0.3

  • Fixed bugs with rendering components when already is showing one (prohibiting rendering more then 2 components in time)

Update 2.0.1

  • Changed render method:
    • New showed child always display before (on html page) current hiding child. (There was bug with correct positioning elements)
    • Current showing child always is visible on the top of others (has the highest z-index)

Update 2.0.0

  • Added smooth transitions between rerenders based on CSS class

What's next?

Probably maybe any async/await rendering?

Any suggestions? Write to: [email protected]