1.0.9 • Published 6 months ago

@conorroberts/responsive-event-handler v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months 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

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago