1.0.5 • Published 5 years ago

ui-custom-hooks v1.0.5

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

License: MIT npm version

GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests

ui-custom-hooks

React Hook to open your modal on browser

React Hook to outside click for dropdown and tooltip

Installation

yarn

yarn add ui-custom-hooks

npm

npm i ui-custom-hooks

Modal Usage

import React from "react";
import { ModalTemplate, useModalHandler } from "ui-custom-hooks/blankModal";

const ModalParent = () => {
  const { isVisible, toggleModalStatus } = useModalHandler();
  return (
    <>
      <ModalTemplate
        isVisible={isVisible}
        toggleModalStatus={toggleModalStatus}
      >
        <div>HELLOW</div>
        <button onClick={toggleModalStatus}>Close</button>
      </ModalTemplate>
      <button onClick={toggleModalStatus}>Open</button>
    </>
  );
};

export default ModalParent;

Arguments

ArgumentTypeDescriptionRequired
childrenReactNodeComponents to be view in modalyes
isVisiblebooleanmodal visible state valueyes
handleModalInactive()=>voidmodal isVisible handlerno
handleModalActive()=>voidmodal isVisible handlerno
borderRadiusstringmodal border radius valueno
bgColorstringmodal background color valueno

outsideClick(Tooltop, Dropdown...) Usage

import React from "react";
import { render } from "react-dom";
import { ref, isComponentVisible } from "ui-custom-hooks/outsideClick";

const OutsideAlerter = (props) => {
  const wrapperRef = useRef(null);
  if(isComponentVisible) {
    alert("outside Click!!!")
  }

  return <div ref={wrapperRef}>{props.children}</div>;
}

const App = () => {
  <OutsideAlerter ref={ref}>
    <button>Click outside me!</button>
  </OutsideAlerter>
);

render(<App />, document.getElementById("root"));

useOutsideClickHandler Arguments

ArgumentTypeDescriptionRequired
refref of the standard component-
isComponentVisiblebooleanComponents visible state value-
setIsComponentVisible()=>voidComponents isVisible handler-
1.0.5

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago