0.1.1 • Published 4 years ago

@connect-dot/ui-hooks v0.1.1

Weekly downloads
22
License
MIT
Repository
github
Last release
4 years ago

npm version License: MIT GitHubstar GitHub watchers

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

This is react custom hook library for web action like scroll lock, to use media query.

The goal for this project is to make custom hook which is useful to deal with ui action. When I develop some web ui, there is some problem which to make some component. For example, The component which need to change based on media query have got on my nerves.

I hope this project is useful for solving that kind of problem.

API

APIResultParameterDescription
useMediaQuery(config, initial)mediaType, errorconfig : { key : string }, initial : stringget Media Query from config.
useScrollLock(on)voidon : booleanscrollLock when some component is visible

Example

There is some example code with Typescript. If you want to use Javascript, you can replace enum to object.

useMediaQuery

enum DEVICE {
  DESKTOP = "DESKTOP",
  TABLET = "TABLET",
  MOBILE = "MOBILE"
}
...
const Component : React.FC<IProps> => {
  const [currentDevice] = useMediaQuery({
    [DEVICE.DESKTOP] : "1240px",
    [DEVICE.TABLET] : "768px",
    [DEVICE.MOBILE] : "425px"
  },DEVICE.MOBILE)
  
  return(
    currentDevice === DEVICE.DESKTOP ? <DesktopComponent/> :
    currentDevice === DEVICE.TABLET ? <TabletComponent/> :
    currentDevice === DEVICE.MOBILE ? <MobileComponent/> :
    <DefaultComponent/>
  )
}
0.1.1

4 years ago

0.1.0

4 years ago

0.0.3-alpha

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.2-beta

4 years ago

0.0.2-alpha9

4 years ago

0.0.2-alpha8

4 years ago

0.0.2-alpha7

4 years ago

0.0.2-alpha6

4 years ago

0.0.2-alpha5

4 years ago

0.0.2-alpha4

4 years ago

0.0.2-alpha2

4 years ago

0.0.2-alpha

4 years ago

0.0.1-beta6

4 years ago

0.0.1-beta5

4 years ago

0.0.1-beta4

4 years ago

0.0.1-beta3

4 years ago

0.0.1-beta2

4 years ago

0.0.1-beta

4 years ago

0.0.1-alpha

4 years ago

0.0.1

4 years ago