Coder Social home page Coder Social logo

react-queries's Introduction

react-queries

Реакт компонент для управления медиа запросами

Язык документации: Русский, English

npm bundle size license npm Codacy Badge

Как установить

Если используете npm: npm install react-queries

Если используете yarn: yarn add react-queries

Как использовать

Простой

import React from 'react';
import Query from 'react-queries';

const Example = () => (
  <Query
    match={{
      type: 'screen',
      minWidth: 600,
      maxWidth: 1200,
    }}
  >
    Какой-то контент
  </Query>
);

Отобразится как @media:

@media screen and (min-width: 600px) and (max-width: 1200px)

Расширенный

import React from 'react';
import Query from 'react-queries';

const Example = () => (
  <Query
    match={{
      minWidth: ['screen', 600],
      maxWidth: ['print', 1200],
    }}
  >
    Какой-то контент
  </Query>
);

Отобразится как @media:

@media screen and (min-width: 600px), print and (max-width: 1200px)

Пропсы

Поле Тип Обязательно
match Shape(Matches)¹ Да

¹Matches

Поле Тип Описание
type строка Один из поддерживаемых типов² (опционально)
[запрос из запросов]³ строка | число | [type²: строка, query³: строка | число] Один из поддерживаемых запросов³. В расширенном использовании - поле является обязательным вместе с типом и запросом, но нельзя использовать поле типа отдельно

Поддерживаемые match поля

Типы² Запросы³
all aspectRatio
print minAspectRatio
screen maxAspectRatio
speech minColor
maxColor
colorIndex
minColorIndex
maxColorIndex
deviceAspectRatio
minDeviceAspectRatio
maxDeviceAspectRatio
deviceHeight
minDeviceHeight
maxDeviceHeight
deviceWidth
minDeviceWidth
maxDeviceWidth
height
minHeight
maxHeight
monochrome
minMonochrome
maxMonochrome
orientation
resolution
minResolution
maxResolution
scan
width
minWidth
maxWidth

Неподдерживаемые match поля

Устаревшие типы
braille
embossed
handheld
projection
tty
tv

react-queries's People

Contributors

dependabot[bot] avatar yukioru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.