npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-flex-material

v1.1.0

Published

Flex component built for React based on Angular Material Flex Layout

Downloads

10

Readme

react-flex-material

Flex component built for React based on Angular Material Flex Layout which's features provide sugar to enable developers to more easily create modern, responsive layouts on top of CSS3 flexbox.

Installation

react-flex-material is distributed via npm:

$ npm i -S react
$ npm i -S react-flex-material

Configuration

There are several ways to load react-flex-material. Preferable way is using webpack

Webpack with css-loader

import React from 'react';
import {Flex} from 'react-flex-material';
...

Webpack configuration

...
{
  test: /\.css$/,
  loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
...

In this case required styles will be loaded automatically.

Webpack with css-modules

import React from 'react';
import {Flex} from 'react-flex-material/modules';
...

And webpack configuration

...
module: [{
  test: /\.scss$/,
  loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]!postcss-loader!sass-loader')
  }],
postcss: () => [autoprefixer()]
...

You will need a couple of loaders for webpack:

npm install node-sass sass-loader postcss postcss-loader

Including postcss for autoprefixer to make more browser compatible CSS.

Using library without webpack

In this case you load library without styles

import React from 'react';
import {Flex} from 'react-flex-material/lib/flex';
...

And then load them separately

<link rel="stylesheet" href="node_modules/react-flex-material/lib/flex.css">

Documentation

The library is based on Angular Material Flex Layout. So you can use their documentation as a main source.

Only one change. Since this library is for React, we are using camelCased style instead of snake-cased.

Base attributes are 'layout', 'flex', 'order', 'offset', 'align', 'hide', 'show'

Responsive modifiers '', 'Xs', 'GtXs', 'Sm', 'GtSm', 'Md', 'GtMd', 'Lg', 'GtLg'

Some other attributes 'layoutWrap', 'layoutNoWrap', 'layoutFill', 'layoutMargin', 'layoutPadding'

So you'll get 'layoutXs', 'layoutGtSm', 'flexGtXs', 'flexGtMd', 'orderSm' etc

The value for attributes is the same to Angular Material Flex Layout

<Flex flex flexGtSm="75"> ... </Flex>
<Flex layoutGtXs="row"> ... </Flex>
<Flex layout align="space-between center"> ... </Flex>

Examples

Library has only one Main component called Flex.

By default Flex is just a div. But you can change it via tag attribute

<Flex tag="span"> ... </Flex>

Basic row:

<Flex layout="row">
  <Flex flex>Col 1</Flex>
  <Flex flex>Col 2</Flex>
</Flex>

For row layout, attribute value could be omitted:

<Flex layout>
  <Flex flex>Col 1</Flex>
  <Flex flex>Col 2</Flex>
</Flex>

Row layout with equal columns:

<Flex layout>
  <Flex flex>Col 1</Flex>
  <Flex flex>Col 2</Flex>
</Flex>

Row layout with a specific columns width

<Flex layout>
  <Flex flex="20">
    Col 1
  </Flex>
  <Flex flex="80">
    Col 2
  </Flex>
</Flex>

Row layout with a specific alignment

<Flex layout align="space-between center">
  <div>Col 1</div>
  <div>Col 2</div>
</Flex>

Column layout with a specific alignment

Important: use it only if you need a specific alignment. <Flex layout="column" /> is the same to <Flex /> by default.

<Flex layout="column" align="center center">
  <div>
    Row 1
  </div>
  <div>
    Row 2
  </div>
</Flex>

Special attribute for Flex called divider.

If you want to add some space between components.

<Flex layout align="space-between center">
  <Flex flex>Col 1</Flex>
  <Flex divider />
  <Flex flex>Col 2</Flex>
</Flex>