Giter Club home page Giter Club logo

resonatejs's Introduction

Resonate.js

A modern minimalist cursor-based animation library for the Javascript ecosystem.

Npm version Downloads Top Size
GitHub code size in bytes GitHub last commit Languages Issues LICENSE

demo.mp4

Table of Contents ๐Ÿ“–

Features ๐Ÿš€

  • ๐Ÿงฉ Ease of use : write less, do more.
  • โœจ Modern : get support for your modern frameworks.
  • ๐Ÿ’ผ Customisation : have complete control over the code.
  • ๐Ÿ›๏ธ Presets : use popular presets right out of the box.
  • ๐Ÿ’ป API : offering a comprehensive interface to work with the DOM.
  • ๐Ÿ’‰ Injectable : use Resonate without changing existing code.
  • ๐Ÿ›ก๏ธ Typescript : get full typescript support.
  • ๐Ÿชถ Zero Dependancies : don't waste a byte on some code you don't need.

Installation ๐Ÿ“ฆ

via NPM
npm install --save @resonate/react
via Yarn
yarn add @resonate/react
via PNPM
pnpm add @resonate/react
via Bun
bun add @resonate/react

Usage ๐Ÿ”Œ

Presets

import { tilt, glare, useResonate, ResonateContainer } from "@resonatejs/react";

export const Card: React.FC = () => {
  const trackers = useResonate({
    presets: [glare(), tilt(), ...] // all your presets go here
  });

  return (
    <ResonateContainer
      className="..."
      trackers={trackers}
    >
      Try it out!
    </ResonateContainer>
  );
}

Listeners

import { useResonate, ResonateContainer } from "@resonatejs/react";

export const Card: React.FC = () => {
  const trackers = useResonate({
    // access the rich API
    listeners: ({ getCenterPosition }) => {
      const { x, y } = getCenterPosition();
      // return all the event listeners
      return {
        mousemove({ clientX, clientY }) {
          console.log(clientX - x, clientY - y);
        },
      };
    },
  });

  return (
    <ResonateContainer
      className="h-full w-full py-24 text-zinc-300 ring-2 ring-zinc-600 text-center text-7xl text-wrap rounded-xl font-mono bg-zinc-900"
      trackers={trackers}
    >
      Try it out!
    </ResonateContainer>
  );
};

resonatejs's People

Contributors

atlas2002 avatar turbobot-temp avatar

Stargazers

 avatar

Watchers

 avatar

resonatejs's Issues

Add tailwind-config as a shared package

Note

  • Inside the base directory, create a new directory tailwind-config.
  • Create a tailwind.config.ts and postcss.config.ts file.
  • Configure all the base properties (set accurate paths in content).
  • Extend tailwind and postcss config files in other workspaces from the base tailwind-config package.

Tip

  • Use pnpm to install the packages: tailwindcss, postcss and autoprefixer.
  • Instead of creating the config files, run this command instead: pnpx tailwindcss init -p.
  • If the files are in .js, change them to .ts, and use proper types.

Implement a react parser to handle the presets

This is the current location of presets:

  • packages
    • react
      • src
        • presets

          glare.ts
          index.ts
          tilt.ts

Problem:

And each of these preset files have a default function, that handles all the logic for that preset. But these are tightly coupled with the react environment. If we implement these effects in other frameworks then we have to rewrite the implementation code again.

Solution:

Instead what we can do is, move the logic to a separate preset directory packages/react/src/preset >> packages/preset under the packages. And for each framework there will be a dedicated parser, which will take the output generated by the preset file. And do react specific things, like adding refs. Currently the preset file takes the user's configuration and returns a resonate function which handles the implementation, also the ref of the component that it is controlling along with a title, that we pass to the ResonateContainer.

Important points:

  • You can add the parser here: packages/react/src/core/parser.ts.
  • The preset folder needs to be shifted directly under the packages/.
  • Use typescript efficiently. Write readable and reusable types.
  • Avoid using document.querySelector() or useRef() inside the preset file. Add a method inside the useAPI hook react/src/hooks/api.ts, and use it to access the element in the resonate function.
  • Using best react practices will be highly appreciated (that includes not using querySelectors, that directly access the DOM elements).

Please add a comment under this issue, if there is anything that you think would be better to add or change. Also I will be more than happy to guide you through the details, but I encourage taking a look at the code first. If there are any doubts not related to this issue you can ask them in the discord channel of JWOC.

That's all for this issue, good luck everyone & Happy Coding! ๐Ÿ˜„

Write the docs for preset: glare

Frame 3

Inside the example/docs there is a empty nextjs app, that you have to change according to the wireframe that is provided in the picture above.

Important points:

  • Keep the UI for the sidebar in app/layout.tsx.
  • Routes need to be in this manner:
      - app/
        - layout.tsx
        - presets/
          - glare/
            - page.tsx
    
  • Keep the code in a structured format (i.e: keep the UI components inside /components).
  • You can add some creativity in the design, no need to be strict about the provided design.

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.