All Projects → foxhound87 → mobx-react-matchmedia

foxhound87 / mobx-react-matchmedia

Licence: MIT License
A React HOC with mediaqueries for responsive layout

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mobx-react-matchmedia

breaking-point
BREAKING-POINT lets you quickly define and subscribe to screen (i.e. window) breakpoints in your re-frame application
Stars: ✭ 36 (+12.5%)
Mutual labels:  responsive, breakpoints
breakpoints-js
Awesome Breakpoints in JavaScript. (bootstrap supported)
Stars: ✭ 70 (+118.75%)
Mutual labels:  responsive, breakpoints
react-context-responsive
A package that provides a responsive context to your application, using React Context API.
Stars: ✭ 25 (-21.87%)
Mutual labels:  responsive, mediaqueries
Anzeixer
Toolkit to Streamline View Definitions for Responsive Web Design
Stars: ✭ 62 (+93.75%)
Mutual labels:  responsive, breakpoints
react-responsive-spritesheet
React component which helps you to easily apply responsive spritesheet animations on your project.
Stars: ✭ 82 (+156.25%)
Mutual labels:  responsive
react-gallery-carousel
Mobile-friendly gallery carousel 🎠 with server side rendering, lazy loading, fullscreen, thumbnails, touch, mouse emulation, RTL, keyboard navigation and customisations.
Stars: ✭ 178 (+456.25%)
Mutual labels:  responsive
fuse-core
The 'Fuse Core' Jekyll theme.
Stars: ✭ 29 (-9.37%)
Mutual labels:  responsive
caesura
📏 A reasonable breakpoint scale using @Custom-Media
Stars: ✭ 14 (-56.25%)
Mutual labels:  mediaqueries
hope-ui-design-system
Hope UI - Open Source Bootstrap 5 Design System
Stars: ✭ 37 (+15.63%)
Mutual labels:  responsive
react-quiz-app
A Simple React Quiz App 💎
Stars: ✭ 37 (+15.63%)
Mutual labels:  responsive
react-typescript
A Front-End Project with Typescript/Antd. webpack5+react-router4+antd+typescript4+grahql
Stars: ✭ 63 (+96.88%)
Mutual labels:  mobx
BXStage
基于mobx + react 构建一个60多个页面大型跨平台 react-naive 应用
Stars: ✭ 49 (+53.13%)
Mutual labels:  mobx
ml-stack-nav
Customizable, responsive, accessible, easy-to-use multi-level stack navigation menu with slide effect.
Stars: ✭ 20 (-37.5%)
Mutual labels:  responsive
frontend-handbook
Our handbook based on 10 years of experience in Frontend/JS development
Stars: ✭ 45 (+40.63%)
Mutual labels:  mobx
jekyll-grid
Jekyll theme (used on 25x52.com) displays posts in a grid. Ideal for projects
Stars: ✭ 63 (+96.88%)
Mutual labels:  responsive
motley
CSS Framework based on ITCSS
Stars: ✭ 24 (-25%)
Mutual labels:  responsive
myConsole
基于 TS + React + Mobx 实现的移动端浏览器控制台开发教程
Stars: ✭ 26 (-18.75%)
Mutual labels:  mobx
nglp-angular-material-landing-page
NGLP is an Angular Material Landing Page.
Stars: ✭ 32 (+0%)
Mutual labels:  responsive
plantapp
A React + MobX app for Plants data from USDA
Stars: ✭ 13 (-59.37%)
Mutual labels:  mobx
awrora-starter
Landing page template built with one of most popular javascript library Vue.JS, Vuetify (Material Design) and Nuxt.JS with SSR.
Stars: ✭ 38 (+18.75%)
Mutual labels:  responsive

MobX React MatchMedia

A React HOC with mediaqueries for responsive layout.

Travis Build Codecov Coverage Downloads npm node GitHub license

NPM


Install

npm i --save mobx-react-matchmedia

Usage

Define mobx observable breakpoints

import { observable } from 'mobx';

const breakpoints = observable({
  xs: '(max-width: 767px)',
  su: '(min-width: 768px)',
  sm: '(min-width: 768px) and (max-width: 991px)',
  md: '(min-width: 992px) and (max-width: 1199px)',
  mu: '(min-width: 992px)',
  lg: '(min-width: 1200px)',
});

Pass the breakpoints to the MatchMediaProvider

import { MatchMediaProvider } from 'mobx-react-matchmedia';

<MatchMediaProvider breakpoints={breakpoints}>
  <Test breakpoints={breakpoints} />
</MatchMediaProvider>

Pass the breakpoints as props to components and check if true/false

import { observer } from 'mobx-react';

const Test = observer(({ breakpoints }) => (
  <div>
    {breakpoints.sm ? 'YES' : 'NO'}
  </div>
));

Now resize the browser window to see the changes!

Contributing

If you want to contribute to the development, do not hesitate to fork the repo and send pull requests.

And don't forget to star the repo, I will ensure more frequent updates! Thanks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].