3.57.5 • Published 6 months ago

reflexy v3.57.5

Weekly downloads
18
License
MIT
Repository
github
Last release
6 months ago

Reflexy npm package

Reflexy is react components library for flexbox and responsive layouts:

  • Flex - flexbox layout with paddings and margins support.
  • styled/Flex - styled version of Flex powered by @mui.

  • styled/StyledReflexyWebpackPlugin - webpack plugin for replace regular imports of Flex with styled/Flex. Just import Flex like import { Flex, FlexWithRef } from 'reflexy'; or import { ResponsiveFlex } from 'reflexy/responsive'; and styled/Flex will be used instead.

  • FlexWithRef - Flex with forwarded ref.
  • TweakableElementWrapper - Wrapper for react element in order to use it with component prop of Flex.
  • responsive/Responsive - container with breakpoints.
  • responsive/ResponsiveRender - conditional render by breakpoints.
  • responsive/ResponsiveFlex - Like Flex but with breakpoints.
  • responsive/useMediaQuery - React hook for media queries.
  • responsive/MediaQuery - utils for work with media queries and breakpoints.

Custom media queries

Used in CSS.

NameValue
--xxsonly screen and (max-width: 479px)
--xsonly screen and (min-width: 480px) and (max-width: 767px)
--sonly screen and (min-width: 768px) and (max-width: 991px)
--monly screen and (min-width: 992px) and (max-width: 1279px)
--lonly screen and (min-width: 1280px) and (max-width: 1919px)
--xlonly screen and (min-width: 1920px) and (max-width: 2559px)
--xxlonly screen and (min-width: 2560px)

Custom media queries can be used with [postcss-custom-media](https://github.com/postcss/postcss-custom-media#importfrom). Example of configuration with [preset-env](https://preset-env.cssdb.org/):

const exportMediaQueries = require('reflexy/responsive/exportMediaQueries');

module.exports = {
  plugins: {
    'postcss-preset-env': {
      features: {
        'custom-media-queries': {
          importFrom: [{ customMedia: exportMediaQueries() }],
        },
      },
    },
  },
};

Installation

yarn add react reflexy
# or
npm install --save react reflexy

If you use styled version you should also install @mui packages.

Reflexy has own css files so you need provide loader for css files placed in node_modules folder (only if you do not use styled version). With webpack it could be [css-loader](https://github.com/webpack-contrib/css-loader):

{
  test: /\.css$/,
  include: path.join(__dirname, 'node_modules'),
  // or
  include: /reflexy/,
  use: [
    // ...
    { loader: 'css-loader', options: { modules: true } }, // enabled css-modules is necessary
    // ...
  ],
},

Flex

Usage

import { Flex, TweakableElementWrapper } from 'reflexy';

<Flex row justifyContent="center">
  ...
</Flex>

<Flex row justifyContent="center" component={TweakableElementWrapper} element={<button />}>
  ...
</Flex>

<Flex row justifyContent="center" component="button" onClick={...}>
  ...
</Flex>

<Flex row justifyContent="center" ref={ref}>
  ...
</Flex>

<Flex row justifyContent="center" component={CustomComponent} componentProp1={...} componentProp2={...}>
  ...
</Flex>

<Flex ml pb>
  ...
</Flex>;

Props

Default style is just display: flex.

PropTypeDescription
flex?booleanSets display to flex.
inline?booleanSets display to inline-flex.
row?booleanSets flow-direction to row.
column?booleanSets flow-direction to column. Takes a precedence over row.
reverse?booleanUsed with row or col. Sets flow-direction to column-reverse or row-reverse.
wrap?boolean \| 'inherit' \| 'initial' \| 'unset' \| 'nowrap' \| 'wrap' \| 'wrap-reverse'Sets flex-wrap to corresponding value. Also accepts boolean value: true equals to wrap, false equals to nowrap.
alignContent?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'space-between' \| 'space-around' \| 'space-evenly' \| 'stretch'Sets align-content to corresponding value.
alignItems?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'stretch' \| 'baseline'Sets align-items to corresponding value.
alignSelf?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'stretch' \| 'baseline' \| 'auto' \| 'initial' \| 'inherit'Sets align-self to corresponding value.
justifyContent?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'space-between' \| 'space-around' \| 'space-evenly'Sets justify-content to corresponding value.
center?booleanSets justifyContent and alignItems to center. justifyContent and alignItems take a precedence over center.
basis?'inherit' \| 'initial' \| 'unset' \| 'auto' \| 'content' \| 'number'Sets flex-basis to corresponding value.
grow?0..24 \| booleanSets flex-grow to corresponding value. true is equals to 1, false is equals to 0.
shrink?0..24 \| booleanSets flex-shrink to corresponding value. true is equals to 1, false is equals to 0.
order?numberSets order to corresponding value.
hfill?boolean \| number in range 0.0 to 1.0 inclusiveStretch by horizontal or sets width in percentage (numbers in range 0.0 to 1.0 inclusive).
vfill?boolean \| number in range 0.0 to 1.0 inclusiveStretch by vertical or sets height in percentage (numbers in range 0.0 to 1.0 inclusive).
fill?booleanStretch by vertical and horizontal.
shrinkByContent?booleanSets min-width: 0 and min-height: 0. By default, a flex item cannot be smaller than the size of its content. The initial setting on flex items is min-width: auto and min-height: auto. One way to enable flex items to shrink past their content is to set a flex item to min-width: 0 or min-height: 0.true by default
shrinkWidth?booleanSets min-width to 0. Takes a precedence over shrinkByContent.
shrinkHeight?booleanSets min-height to 0. Takes a precedence over shrinkByContent.
className?stringCSS class name.
style?React.CSSPropertiesInline styles.
component?React.ElementType<P>Sets custom react component as a container. Component must accept className and style through props.
unit?stringMeasure unit of space
mSize?'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| numberSize of margin
m?typeof mSize \| booleanmargin. Scaling value.
mt?typeof mSize \| booleanmargin-top
mr?typeof mSize \| booleanmargin-right
mb?typeof mSize \| booleanmargin-bottom
ml?typeof mSize \| booleanmargin-left
mx?typeof mSize \| booleanmargin by x axis: margin-left & margin-right
my?typeof mSize \| booleanmargin by y axis: margin-top & margin-bottom
pSize?'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| numberSize of padding
p?typeof pSize \| booleanpadding. Scaling value.
pt?typeof pSize \| booleanpadding-top
pr?typeof pSize \| booleanpadding-right
pb?typeof pSize \| booleanpadding-bottom
pl?typeof pSize \| booleanpadding-left
px?typeof pSize \| booleanpadding by x axis: padding-left & padding-right
py?typeof pSize \| booleanpadding by y axis: padding-top & padding-bottom

Flex Statics

PropTypeDescription
defaultUnitstringMeasure unit of space. Default: rem.
defaultSize'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl'Default: 'm'.
defaultSizesRecord<'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl', number>Space sizes. Default: { xs: 0.25, s: 0.5, m: 1, l: 1.5, xl: 2, xxl: 2.5 }.

ResponsiveFlex

Usage

import { ResponsiveFlex } from 'reflexy/responsive';

// `breakpoints` values will override default values for `row` and `order`.
<ResponsiveFlex
  row
  order={1}
  breakpoints={{
    l: { column: true, order: 2 },
    xxs: { alignItems: 'center', order: 4 },
  }}
>
  ...
</ResponsiveFlex>;

Props

All props of [Flex](#Flex) and:

PropTypeDescription
merge?boolean \| BreakpointsMergeTypedown - merge from top to down until current view size. top - merge from down to top until current view size. true treats as down. false - no merge, use only exact breakpoint. Default true.
breakpoints{ [P in ViewSize.Keys]?: FlexAllProps<C> }Props per breakpoint.

ViewSize

Same as [Custom media queries](#mq) but names without prefix --.

License

[MIT](https://opensource.org/licenses/mit-license.php)

3.57.5

6 months ago

3.57.4

7 months ago

3.57.3

7 months ago

3.57.2

7 months ago

3.57.1

7 months ago

3.56.0

7 months ago

3.57.0

7 months ago

3.52.7

1 year ago

3.54.3

12 months ago

3.54.2

12 months ago

3.54.1

1 year ago

3.54.0

1 year ago

3.55.0

11 months ago

3.53.0

1 year ago

3.52.6

1 year ago

3.52.5

1 year ago

3.52.4

1 year ago

3.52.3

1 year ago

3.52.2

2 years ago

3.52.1

2 years ago

3.52.0

2 years ago

3.50.1

2 years ago

3.50.0

2 years ago

3.51.0

2 years ago

3.47.1

2 years ago

3.47.2

2 years ago

3.47.3

2 years ago

3.47.4

2 years ago

3.47.5

2 years ago

3.48.0

2 years ago

3.48.1

2 years ago

3.49.0

2 years ago

3.49.1

2 years ago

3.49.2

2 years ago

3.49.3

2 years ago

3.47.0

2 years ago

3.45.1

2 years ago

3.46.0

2 years ago

3.46.1

2 years ago

3.46.2

2 years ago

3.46.3

2 years ago

3.46.4

2 years ago

3.45.0

3 years ago

3.43.0

3 years ago

3.44.0

3 years ago

3.44.1

3 years ago

3.42.5

3 years ago

3.42.6

3 years ago

3.42.3

3 years ago

3.42.0

3 years ago

3.42.1

3 years ago

3.42.2

3 years ago

3.41.8

3 years ago

3.41.4

3 years ago

3.41.5

3 years ago

3.41.6

3 years ago

3.41.7

3 years ago

3.41.1

4 years ago

3.41.2

4 years ago

3.41.3

3 years ago

3.41.0

4 years ago

3.40.0

4 years ago

3.38.0

4 years ago

3.39.0

4 years ago

3.37.6

4 years ago

3.37.5

4 years ago

3.37.1

4 years ago

3.37.2

4 years ago

3.37.3

4 years ago

3.37.4

4 years ago

3.37.0

4 years ago

3.36.1

4 years ago

3.36.0

4 years ago

3.35.0

4 years ago

3.35.1

4 years ago

3.34.2

4 years ago

3.34.1

4 years ago

3.34.0

4 years ago

3.33.6

4 years ago

3.33.7

4 years ago

3.33.3

4 years ago

3.33.4

4 years ago

3.33.5

4 years ago

3.33.2

4 years ago

3.33.1

4 years ago

3.33.0

4 years ago

3.32.0

5 years ago

3.31.0

5 years ago

3.30.0

5 years ago

3.29.0

5 years ago

3.28.2

5 years ago

3.28.1

5 years ago

3.28.0

5 years ago

3.27.0

5 years ago

3.26.0

5 years ago

3.25.0

5 years ago

3.24.0

5 years ago

3.23.2

5 years ago

3.23.1

5 years ago

3.23.0

5 years ago

3.22.4

5 years ago

3.22.3

5 years ago

3.22.5

5 years ago

3.22.2

5 years ago

3.22.1

5 years ago

3.22.0

5 years ago

3.21.0

5 years ago

3.20.2

5 years ago

3.20.1

5 years ago

3.20.0

5 years ago

3.19.1

5 years ago

3.19.0

5 years ago

3.18.0

5 years ago

3.17.1

5 years ago

3.17.0

5 years ago

3.16.0

5 years ago

3.15.1

5 years ago

3.15.0

5 years ago

3.14.0

5 years ago

3.13.0

5 years ago

3.12.6

5 years ago

3.12.3

5 years ago

3.12.5

5 years ago

3.12.4

5 years ago

3.12.2

5 years ago

3.12.1

5 years ago

3.12.0

5 years ago

3.11.3

5 years ago

3.11.2

5 years ago

3.11.0

5 years ago

3.11.1

5 years ago

3.10.0

6 years ago

3.9.2

6 years ago

3.9.1

6 years ago

3.9.0

6 years ago

3.8.0

6 years ago

3.7.0

6 years ago

3.6.0

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.3

6 years ago

3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.20.2

6 years ago

2.20.1

6 years ago

2.20.0

6 years ago

2.19.0

6 years ago

2.18.1

6 years ago

2.18.0

6 years ago

2.17.0

6 years ago

2.16.0

6 years ago

2.15.1

6 years ago

2.15.0

6 years ago

2.14.1

6 years ago

2.14.0

6 years ago

2.12.1

6 years ago

2.12.0

6 years ago

2.11.5

6 years ago

2.11.4

6 years ago

2.11.3

6 years ago

2.11.2

6 years ago

2.11.0

6 years ago

2.10.1

6 years ago

2.10.0

6 years ago

2.9.2

6 years ago

2.9.1

6 years ago

2.9.0

6 years ago

2.8.0

6 years ago

2.7.1

6 years ago

2.7.0

6 years ago

2.6.5

6 years ago

2.6.4

6 years ago

2.6.3

6 years ago

2.6.2

6 years ago

2.6.1

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.7

6 years ago

2.4.6

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.20.0

7 years ago

1.19.5

7 years ago

1.19.4

7 years ago

1.19.3

7 years ago

1.19.2

7 years ago

1.19.1

7 years ago

1.19.0

7 years ago

1.18.1

7 years ago

1.18.0

7 years ago

1.17.0

7 years ago

1.16.2

7 years ago

1.16.1

7 years ago

1.16.0

7 years ago

1.15.2

7 years ago

1.15.0

8 years ago

1.14.1

8 years ago

1.14.0

8 years ago

1.13.0

8 years ago

1.12.5

8 years ago

1.12.4

8 years ago

1.12.3

8 years ago

1.12.2

8 years ago

1.12.1

8 years ago

1.12.0

8 years ago

1.11.0

8 years ago

1.10.1

8 years ago

1.10.0

8 years ago

1.9.0

8 years ago

1.8.0

8 years ago

1.7.2

8 years ago

1.7.1

8 years ago

1.7.0

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago