Code Monkey home page Code Monkey logo

melting-pot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

melting-pot's Issues

[Feature] useMouseMove

We need to come up with an API design that uses the event listener mousemove

// usage
const { x, y } = useMouseMove();
const useMouseMove = () => {
    const [coords, setCoords] = React.useState({ 0, 0 });
    const onHandleMouseMove = event => {
         setCoords({ x, y }) 
    };
    React.useEffect(() => {
       window.addEventListener()
       return () => {
         window.removeEventListener()
       }
    });
    return coords;
}

[Docs] Add src/ alias as withvoid/melting-pot in demos

Currently in docs we have to access the core modules via relative paths e.g, import { useOnlineStatus } from '../../../src'; we need to replace it with import { useOnlineStatus } from @withvoid/melting-pot;

For this we need to add a plugin in the doczrc.js that handles an alias similar to what webpack does.

[Feature] Add a new hook called useToggle

Proposal for hook

const [on, set] = React.useState(initialState);
return { on, set, reset, toggle }; 

Where

  • on Boolean
  • set Function
  • reset Function (That resets to initial state)
  • toggle Functions (That toggles the current state on on)

[Feature] add new hook called useForm

Proposed API

const form = useForm({
   name: { value: '', isRequired: true },
   age: { value: '' }, // isRequired not given, consider false.
});

const onSubmit = e => {
   e.preventDefault();
   if (!form.isValid) {
      alert('Missing required fields*'); 
      return;
   }

   // after some operations
   // reset form.
   form.reset();
};

return (
   <form onSubmit={onSubmit}>
        <input type="text" {...form.name.bind} />
        {form.name.isDirty && form.name.isRequired && <p>Required field*</p>}
        <input type="text" {...form.age.bind} />
        {form.age.isDirty && form.age.isRequired && <p>Required field*</p>}
        <button type="submit">Send</button>
    </form>
)

This will be built on top of useFormField hook

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.