1.0.9 • Published 3 years ago

@conorroberts/responsive-event-handler v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

responsive-event-handler

Uses window.innerWidth to determine which event handler to run, based on TailwindCSS breakpoints.

import { responsiveEventHandler } from "@conorroberts/responsive-event-handler";

const ReactComponent = () => {
  return (
    <button onClick={responsiveEventHandler({
      default: () => console.log("No other breakpoints match!"),
      sm: () => console.log("sm"),
      lg: () => console.log("lg"),
      // Type of event is inferred!
      xl: (event) => console.log(event.target),
    })}>
      Click me!
    </button>
  );
}

Works with any frontend framework, or vanilla JS!

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago