Giter Club home page Giter Club logo

react-magic-motion's Introduction

react-magic-motion

react-magic-motion is a react.js library that ✨ magically animates your components.

⭐️ Getting Started

📦 Install

npm i react-magic-motion

🔎 Simple Example

🎥 Demo

react-magic-motion-full-demo.mp4

🧑‍💻 Code

import { useState } from "react";
import { MagicMotion } from "react-magic-motion";

function ListItem({ children }: { children: string }) {
  return (
    <li
      style={{
        backgroundColor: "#4d4d4dff",
        width: "20rem",
        padding: "0.5rem",
      }}
    >
      {children}
    </li>
  );
}

export default function App() {
  const [areGoalsShowing, setAreGoalsShowing] = useState(true);
  return (
    <MagicMotion>
      <div
        style={{
          margin: "0.75rem auto 0",
          width: "20rem",
          display: "flex",
          flexDirection: "column",
          gap: "1rem",
          overflow: "hidden",
        }}
      >
        <h1
          style={{
            fontWeight: "bold",
            margin: "0.25rem",
          }}
        >
          My Goals
        </h1>
        {areGoalsShowing && (
          <ul
            style={{
              display: "flex",
              flexDirection: "column",
              gap: "0.75rem",
              listStyle: "none",
              paddingLeft: "0.5rem",
              margin: 0,
            }}
          >
            <ListItem>🏀 Make 10 three pointers in a row</ListItem>
            <ListItem>🏋️‍♂️ Bench press 225 lbs</ListItem>
            <ListItem>🏃‍♂️ Run a 5k in under 20 minutes</ListItem>
          </ul>
        )}
        <button
          style={{
            width: "fit-content",
            whiteSpace: "nowrap",
            padding: "0.5rem 1rem",
            backgroundColor: "#5a70ed",
            color: "#ffffff",
            border: 0,
            cursor: "pointer",
            fontFamily: "inherit",
          }}
          onClick={() => setAreGoalsShowing(!areGoalsShowing)}
        >
          {areGoalsShowing ? "Hide" : "Show"} my goals
        </button>
      </div>
    </MagicMotion>
  );
}

💫 Examples

📓 Docs

  • For a full understanding of react-magic-motion visit the docs here

❓ Want to Contribute

react-magic-motion's People

Contributors

arnabsen avatar etesam913 avatar nish-nair avatar turbobot-temp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.