0.3.1 • Published 3 years ago

react-queries v0.3.1

Weekly downloads
90
License
MIT
Repository
github
Last release
3 years ago

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)

Пропсы

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

¹Matches

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

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

Типы²Запросы³
allaspectRatio
printminAspectRatio
screenmaxAspectRatio
speechminColor
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
0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago