diff --git a/dev/index.js b/dev/index.js index 87b8a31..27fb1ca 100644 --- a/dev/index.js +++ b/dev/index.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { useWindowSize, useFormField, useTitle, useHover } from '../src'; +import { useWindowSize, useFormField, useTitle, useHover, useMouseMove } from '../src'; const PADDING = 15; const MARGIN = 15; @@ -80,6 +80,12 @@ const myStyles = theme => { hoverSectionActive: { backgroundColor: selectedColor.hoverDark, }, + miniBox: { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + backgroundColor: selectedColor.hoverLight, + }, }; }; @@ -87,11 +93,13 @@ const App = () => { const size = useWindowSize(); const titleInput = useFormField('Melting Pot'); const hoverEl = useHover(); + const mouseCoords = useMouseMove(); + const yellowBoxCoords = useMouseMove(); useTitle(titleInput.value || 'Empty'); const styles = myStyles('superman'); return ( -
+ Did you know your mouse coordinates are w.r.t screen are x: {mouseCoords.x} and y:{' '} + {mouseCoords.y} +
++ mouse x,y with respect to blue box {yellowBoxCoords.x}, {yellowBoxCoords.y} +
+
Try changing the title of the input field below & watch as the title of the browser window
diff --git a/docs/hooks/useMouseMove.mdx b/docs/hooks/useMouseMove.mdx
new file mode 100644
index 0000000..87c5854
--- /dev/null
+++ b/docs/hooks/useMouseMove.mdx
@@ -0,0 +1,44 @@
+---
+name: useMouseMove
+menu: Hooks
+---
+
+import { Playground } from 'docz';
+import { useMouseMove } from '@withvoid/melting-pot';
+
+# useMouseMove
+
+## Purpose
+
+A hook utility to get current mouse pointer coordinates on screen.
+
+## Usage
+
+```
+import { useMouseMove } from '@withvoid/melting-pot';
+```
+
+## Syntax
+```
+const { mouseCoordinates, bind} = useMouseMove();
+
+x: {mouseCoordinates.x}
+y: {mouseCoordinates.y}
+```
+
+## Examples
+
+ Your mouse pointer coordinates are x: {mosueCoords.x} and y: {mosueCoords.y}Did you know?
+