Skip to content

Commit 3bb11e0

Browse files
author
atidele
committed
Screen resizing v1.0.0 🚀
1 parent d0486e8 commit 3bb11e0

21 files changed

+625
-345
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
.idea/
26+
dist

README.md

+86-70
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,86 @@
1-
# Getting Started with Create React App
2-
3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4-
5-
## Available Scripts
6-
7-
In the project directory, you can run:
8-
9-
### `npm start`
10-
11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13-
14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `npm test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `npm run build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `npm run eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
47-
48-
### Code Splitting
49-
50-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51-
52-
### Analyzing the Bundle Size
53-
54-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55-
56-
### Making a Progressive Web App
57-
58-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59-
60-
### Advanced Configuration
61-
62-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63-
64-
### Deployment
65-
66-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67-
68-
### `npm run build` fails to minify
69-
70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
1+
# screen-resizing
2+
> **use-screen-resizing** is a custom hook that provides information about the device viewport.
3+
4+
![React](https://img.shields.io/badge/-React-20232a?logo=react&style=for-the-badge)
5+
6+
## Installation 🖥
7+
8+
```bash
9+
npm i -S use-device-react
10+
```
11+
12+
## Usage 💻
13+
Example of simple usage
14+
15+
```jsx
16+
import { useScreenResizing } from "screen-resizing";
17+
18+
const Component = () => {
19+
const { isMiniMobile, isMobile, isTablet, isNotebook, isScreen } = useScreenResizing();
20+
21+
return (<div>
22+
{isMiniMobile && ...}
23+
{isMobile && ...}
24+
{isTablet && ...}
25+
{isNotebook && ...}
26+
{isScreen && ...}
27+
</div>);
28+
};
29+
```
30+
31+
## Breakpoints 🔮
32+
You can pass an object as parameter to override default values
33+
34+
```jsx
35+
import { useScreenResizing } from "screen-resizing";
36+
37+
const Component = () => {
38+
const { isMobile, isTablet, isScreen } = useScreenResizing({ mobile: 350 });
39+
40+
return (<div>
41+
{isMobile && ...}
42+
{isTablet && ...}
43+
{isScreen && ...}
44+
</div>);
45+
};
46+
```
47+
48+
The default values are:
49+
```bash
50+
{
51+
miniMobile: 320,
52+
mobile: 576,
53+
tablet: 960,
54+
screen: 1200,
55+
}
56+
```
57+
> **MiniMobile** -> width < 320
58+
>
59+
> **Mobile** -> width >= 320 && width < 576
60+
>
61+
> **Tablet** -> width >= 576 && width < 960
62+
>
63+
> **Notebook** -> width >= 960 && width < 1200
64+
>
65+
> **Screen** -> width >= 1200
66+
67+
## Features 🔥
68+
- Screen greater than: Function than receives a screen value parameter and compares if it's greater than the viewport width screen.
69+
- Screen greater or equal than: Function than receives a screen value parameter and compares if it's greater or equal than the viewport width screen.
70+
- Screen lesser than: Function than receives a screen value parameter and compares if it's lesser than the viewport width screen.
71+
- Screen lesser or equal than: Function than receives a screen value parameter and compares if it's lesser or equal than the viewport width screen.
72+
- Width: The viewport realtime width size.
73+
- Height: The viewport realtime height size.
74+
75+
```jsx
76+
import { useScreenResizing } from "screen-resizing";
77+
78+
const Component = () => {
79+
const { screenGT,screenGTE, screenLT, screenLTE, width, height } = useScreenResizing({ mobile: 350 });
80+
81+
return (<div>...</div>);
82+
};
83+
```
84+
85+
## License 🧙🏻‍♂️
86+
MIT © [AleTid5](https://github.com/AleTid5)

0 commit comments

Comments
 (0)