1.0.11 • Published 1 year ago

smooth-transition v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

<SmoothTransition />

npm version GitHub checks

<SmoothTransition /> is a React component for elegantly transitioning between components. Its smooth fading effect and gliding height transition provides a seamless experience for your users as they switch between components.

Demo Video (Demo Video)

Installation

Use your favourite manager to install the package:

yarn add smooth-transition
npm install smooth-transition --save

Example

import { TextField, Typography } from "@mui/material";
import React, { ChangeEventHandler, forwardRef } from "react";
import { SmoothTransition } from "smooth-transition";

type Props = {
    editMode: boolean;
    value: string;
    onChange: ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
};

export const Example = forwardRef<HTMLDivElement, Props>(function Example(
    { editMode, value, onChange },
    ref
) {
    return (
        <SmoothTransition
            render={[
                (state) => (
                    <Typography ref={state != "leave" ? ref : undefined}>
                        {value}
                    </Typography>
                ),
                (state) => (
                    <TextField
                        ref={state != "leave" ? ref : undefined}
                        fullWidth
                        multiline
                        value={value}
                        onChange={onChange}
                    />
                ),
            ]}
            active={!editMode ? 0 : 1}
            duration={500}
        />
    );
});

Properties

The component accepts the following properties:

  • render: ((state: "enter" | "active" | "leave") => ReactNode)[]: An array of render functions that return a ReactNode, representing the components that you want to transition between.
  • active: number: An integer specifying which component should be displayed.
  • duration: number: A number representing the duration of the transition in milliseconds.

License

This library is licensed under the MIT license.

Contributing

We welcome contributions to the smooth-transition library. To contribute, simply open a pull request with your changes.

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago