0.0.24 • Published 6 months ago

@hhgtech/hooks v0.0.24

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

@hhgtech/hooks

Hello Health Group's Custom Hooks for React.

Installation

You can install this plugin using npm or yarn:

npm install @hhgtech/hooks

or

yarn add @hhgtech/hooks

Hooks

useAppHeight

This hook set app height to css variable --app-height

Usage:

import { useAppHeight } from '@hhgtech/hooks';

const App = () => {
  const appHeight = useAppHeight();

  return (
    <div style={{ height: 'var(--app-height, 100vh)' }}>
      {/* ... */}
    </div>
  );
};

useDragScroll

A hook that enables horizontal scrolling of a container element by dragging with the mouse.

Returns:

An object containing the following properties:

  • sliding: A boolean indicating whether the user is currently dragging the container.
  • mouseDownHandler: A function to be attached to the onMouseDown event of the container element.
  • sliderRef: A ref to the container element.
  • pos: A ref to an object containing the initial position of the mouse and the container when click on container.

Usage:

  const { sliding, mouseDownHandler, sliderRef } = useDragScroll();
  return (
    <div ref={sliderRef} onMouseDown={mouseDownHandler}>
      {sliding ? 'Dragging...' : 'Not dragging.'}
    </div>
  );

useIsMobile

A hook that returns a boolean indicating whether the current device is mobile or not.

Parameters:

isMobileSsr - A boolean indicating whether the device is mobile on server-side rendering.

Returns:

A boolean indicating whether the current device is mobile or not.

Usage:

const isMobile = useGetIsMobile(false);
console.log(isMobile); // false

License

This project is licensed under the MIT License - see the LICENSE file for details.

0.0.24

6 months ago

0.0.23

6 months ago

0.0.22

6 months ago

0.0.21

6 months ago

0.0.20

6 months ago

0.0.19

6 months ago

0.0.18

6 months ago

0.0.17

6 months ago

0.0.16

6 months ago

0.0.15

6 months ago

0.0.14

6 months ago

0.0.13

6 months ago

0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago