All Projects β†’ setsun β†’ react-transition-components

setsun / react-transition-components

Licence: MIT license
Easily configurable React components for animations / transitions πŸ’ƒ

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-transition-components

Css In Js 101
πŸ’ˆ CSS-in-JS 101: All you need to know
Stars: ✭ 252 (+1300%)
Mutual labels:  css-in-js
stitches-utils
Helpful stitches shorthand utilities combined in one package
Stars: ✭ 35 (+94.44%)
Mutual labels:  css-in-js
react-dsfr
Non-official React components of the official french Système de Design de l'État.
Stars: ✭ 48 (+166.67%)
Mutual labels:  component-library
Cssobj
Runtime CSS manager, Turn CSS into dynamic JS module, Stylesheet CRUD (Create, Read, Update, Delete) in CSSOM, name space (local) class names
Stars: ✭ 253 (+1305.56%)
Mutual labels:  css-in-js
bindable
A design system built in Aurelia JS that allows for faster and easier web development.
Stars: ✭ 20 (+11.11%)
Mutual labels:  component-library
styled-media-helper
πŸ’… Helps manage media queries with styled components
Stars: ✭ 76 (+322.22%)
Mutual labels:  css-in-js
Oceanwind
Compiles tailwind shorthand into css at runtime
Stars: ✭ 248 (+1277.78%)
Mutual labels:  css-in-js
spring-keyframes
✌️1.4kb library to generate css keyframes in css-in-js based on a spring algorithm, with emotion
Stars: ✭ 65 (+261.11%)
Mutual labels:  css-in-js
ui
The Blockstack design system implemented with react, styled-components, and styled-system.
Stars: ✭ 34 (+88.89%)
Mutual labels:  css-in-js
paragon
πŸ’Ž An accessible, theme-ready design system built for learning applications and Open edX.
Stars: ✭ 85 (+372.22%)
Mutual labels:  component-library
winampify
⚑ A Spotify web client with an OS-looking interface and a reimplementation of the classic audio player Winamp.
Stars: ✭ 180 (+900%)
Mutual labels:  css-in-js
postcss-jsx
PostCSS syntax for parsing CSS in JS literals
Stars: ✭ 73 (+305.56%)
Mutual labels:  css-in-js
vue-component-lib-starter
A bare-bones example of creating your own Vue component library.
Stars: ✭ 221 (+1127.78%)
Mutual labels:  component-library
Further
πŸ¦„πŸŒˆπŸ„ algebraic style composition for functional UIs
Stars: ✭ 254 (+1311.11%)
Mutual labels:  css-in-js
vue-component-template
Vue.js template to build standalone components
Stars: ✭ 21 (+16.67%)
Mutual labels:  component-library
Xwind
Tailwind CSS as a templating language in JS and CSS-in-JS
Stars: ✭ 249 (+1283.33%)
Mutual labels:  css-in-js
design-systems
A list of famous design systems, design languages and guidelines
Stars: ✭ 403 (+2138.89%)
Mutual labels:  component-library
vue-jss-plugin
JSS plugin implementation for Vue.js
Stars: ✭ 24 (+33.33%)
Mutual labels:  css-in-js
morfeo
Morfeo is a tool to build design systems based on a theme. It helps you to follow a design language and write consistent UIs, whatever it is the framework of your choice. It's easy to use and, with the browser extension, your theme and your components are automatically documented.
Stars: ✭ 30 (+66.67%)
Mutual labels:  css-in-js
miter-design
Miter Design component library made with β™‘ by Prefect
Stars: ✭ 14 (-22.22%)
Mutual labels:  component-library

React Transition Components

npm version npm-downloads

An animation component library & higher-order component for generating easily configurable <Transition> components from react-transition-group.

react-transition-components is 3 kB gzipped, has peer dependencies on react and react-transition-group, and supports webpack tree-shaking by default: https://bundlephobia.com/result?p=react-transition-components

yarn install react-transition-components

Motivation

react-transition-components has 2 goals:

  • Provide a component library of common lightweight UI transitions that are configurable on durations, delays, easings, and other animation values.
  • Make it easy to create configurable transition components by providing a createTransition higher-order component.

The aforementioned createTransition higher-order component wraps <Transition> from react-transition-group, maintains backwards compatibility with its props, and enhances it with configurable timings, delays, and easings. It provides a concise API, allowing you to express an enter/exit CSS transition in 6 lines of code in the simplest case:

import { createTransition } from 'react-transition-components';

const CustomTransition = createTransition({
  from: { transform: 'scale(0) skew(45deg)', opacity: 0 },
  enter: { transform: 'scale(1) skew(0deg)', opacity: 1 }
});

Component Library

react-transition-components comes with multiple components that work out of the box. A Storybook is live at: https://setsun.github.io/react-transition-components

The following components are included, and implement the most common CSS transitions:

  • FadeTransition for opacity animations
  • HeightTransition for height animations
  • TranslateTransition for translate3d animations
  • ScaleTransition for scale3d animations
  • RotateTransition for rotate3d animations
  • SkewTransition for skew animations
  • ClipTransition for clip-path animations

Higher-order component API

createTransition(config: TransitionConfig)

The createTransition higher-order component returns a pre-configured <Transition> component that allows you to create transition components that can be used immediately, and can be configured via props as your animation needs change.

All components created via createTransition support all props from the <Transition> component from react-transition-group (https://reactcommunity.org/react-transition-group/transition).

These generated components also have extended functionality and have the following base props for customizing transition properties and timings:

type Props = {
  // a custom duration for your transition, with the ability
  // to also have separate enter / exit durations
  duration?: number | {
    enter: number;
    exit: number;
  };

  // a custom delay for your transition, with the ability
  // to also have separate enter / exit delays
  delay?: number | {
    enter: number;
    exit: number;
  };

  // a CSS transition easing curve
  easing?: string;

  // React children can either be a ReactNode, or a function that takes
  // a style and status, and returns a ReactNode
  children: React.ReactNode | ((style: React.CSSProperties, status: TransitionStatus) => React.ReactNode);
}

createTransition has the following type signature:

type TransitionConfig = {
  from: React.CSSProperties | LazyCSSProperties;
  enter: React.CSSProperties | LazyCSSProperties;
  exit?: React.CSSProperties | LazyCSSProperties;
  transitionProperty?: string;
}

type createTransition = (config: TransitionConfig) => React.SFC<TransitionProps>

from: React.CSSProperties | LazyCSSProperties

The from property is the starting style of your transition component. This is the first state that your component animation will animate from. If the exit property is not specified, the from property is also used for the exit animation.

enter: React.CSSProperties | LazyCSSProperties

The enter property is the entering style of your transition component. This is the state where your component animation will animate to, and its final resting state.

exit?: React.CSSProperties | LazyCSSProperties

The exit property is the exiting style of your transition component. This is an optional property for explicitly specifying a state to animate to when exiting, especially if you want an exit animation that is asymmetric from your enter animation.

Example Recipes

Symmetric Enter/Exit Transition

const FadeTransition = createTransition({
  from: { opacity: 0 },
  enter: { opacity: 1 }
});

Asymmetric Enter/Exit Transition

const ScaleEnterClipExitTransition = createTransition({
  from: {
    transform: 'scale(0.5)',
    opacity: 0,
    clipPath: 'circle(100% at 50% 50%)'
  },
  enter: {
    transform: 'scale(1)',
    opacity: 1,
    clipPath: 'circle(100% at 50% 50%)'
  },
  exit: {
    transform: 'scale(1)',
    opacity: 0,
    clipPath: 'circle(0% at 50% 50%)'
  },
});

Configurable Transition

const ClipScaleFadeTransition = createTransition({
  from: (props) => {
    return {
      opacity: props.fade ? 0 : 1,
      transform: `scale(${props.scale.start})`,
      clipPath: 'circle(100% at 50% 50%)'
    }
  },
  enter: (props) => {
    return {
      opacity: 1,
      transform: `scale(${props.scale.end})`
      clipPath: 'circle(100% at 50% 50%)'
    }
  },
  exit: (props) => {
    return {
      opacity: props.fade ? 0 : 1,
      transform: `scale(${props.scale.start})`,
      clipPath: 'circle(0% at 50% 50%)'
    }
  },
});

ClipScaleFadeTransition.defaultProps = {
  fade: true,
  scale: {
    start: 0.5,
    end: 1,
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].