-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 12f3794
Showing
9 changed files
with
28,857 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Project | ||
lib/ | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# VSCode | ||
.vscode | ||
|
||
# NodeJS | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#Project | ||
src/ | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# VSCode | ||
.vscode | ||
|
||
# NodeJS | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-present, Johan Haneveld | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# react-native-media-query-hook | ||
|
||
A simplified version of media queries in the browser. Currently supports minWidth, maxWidth, minHeight, maxHeight, and orientation to detect landscape or portrait modus. The hook is typescript first. | ||
|
||
## Installation | ||
|
||
_npm_ | ||
|
||
```shell | ||
$ npm i react-native-media-query-hook | ||
``` | ||
|
||
_yarn_ | ||
|
||
```shell | ||
$ yarn add react-native-media-query-hook | ||
``` | ||
|
||
## How to use | ||
|
||
_import_ | ||
|
||
```typescript | ||
import useMediaQuery from 'react-native-media-query-hook'; | ||
``` | ||
|
||
_basic_ | ||
|
||
```typescript | ||
// The outcome results in a boolean statement. | ||
const isSmallScreen = useMediaQuery({ | ||
maxWidth: 480, | ||
}); | ||
``` | ||
|
||
_more sophisticated queries_ | ||
|
||
```typescript | ||
// Detect different screen sizes | ||
const isSmallScreen = useMediaQuery({ | ||
maxWidth: 480, | ||
}); | ||
const isMediumScreen = useMediaQuery({ | ||
minWidth: 481, | ||
maxWidth: 1024, | ||
}); | ||
const islargeScreen = useMediaQuery({ | ||
minWidth: 1025, | ||
}); | ||
|
||
// Detect portrait / landscape mode | ||
const isPortrait = useMediaQuery({ | ||
orientation: 'portrait', | ||
}); | ||
const isLandscape = useMediaQuery({ | ||
orientation: 'landscape', | ||
}); | ||
|
||
// Put it all together | ||
const isMediumPortraitScreen = useMediaQuery({ | ||
minWidth: 481, | ||
maxWidth: 1024, | ||
minHeight: 481, | ||
maxHeight: 1200, | ||
orientation: 'portrait', | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
[Issues reports](https://github.com/idlework/react-native-media-query-hook/issues) are more than welcome. The best way to report a problem is to add a reproduction of the error with a code example. | ||
|
||
[Pull requests](https://github.com/idlework/react-native-media-query-hook/pulls) are also very welcome. This way we can extend the library quicker with everybody's needs. If you have ideas about the interface, lets discuss it in an [issue ticket](https://github.com/idlework/react-native-media-query-hook/issues). | ||
|
||
## License | ||
|
||
react-native-media-query-hook is [MIT licensed](./LICENSE). |
Oops, something went wrong.