Coder Social home page Coder Social logo

check-size-change's Introduction

Check Size Change

React Parent Wrapper Component that checks if the Screen Size has change

Usage

Simply install the application

npm i @nicholasmole/checkSizeChange

Then add the wrapper to your Component

export default checkSizeChange(Home);

Now the Home Component will have a two new booleans isMobileLimit & isTabletLimit

Editing Default Sizes

Both of the default size checks follow bootstrap sizes

isMobileLimit: 576 isTabletLimit: 992

If you want to edit this sizes you can by sending and object to checkSizeChange using the key words mobile and tablet

export default checkSizeChange(Home, {mobile: 500, tablet: 769});

Adding Custom Sizes

But what if you want to check against other sizes?

If you want to make something like isTooSmallForMenu with the size of 632

Do this:

const extraSizes = [
	{
		prop: 'isTooSmallForMenu',
		limit: 632
	}
];

export default checkSizeChange(Home, {extraSizes});

Now the Home Component will get a new boolean prop called isTooSmallForMenu!

extraSizes can be an infinitly long array of objects

prop: is the name of the passed prop limit: is the limit size of the prop

check-size-change's People

Contributors

nicholasmole avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.