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-flexview

v6.0.1

Published

A react component to abstract over flexbox

Downloads

19,189

Readme

FlexView

A powerful React component to abstract over flexbox and create any layout on any browser.

Install

yarn add react-flexview

Why

The flexbox API is powerful but far from being perfect. The API is complex and there are still many inconsistencies between browsers that force developers to overuse vendor prefixes and literally do magic tricks to achieve the desired layout.

For these reasons, we asked ourselves: is there a way to simplify the API and handle any browser inconsistency in a single place? Our attempt to answer "yes!" to that question gave birth to FlexView.

// flex row
<FlexView />

// flex column
<FlexView column />

// grow, shrink and basis
<FlexView grow shrink basis={100} />
<FlexView grow={2} shrink={1} basis='auto' />
<FlexView basis={100} /> // shrink is set to `false` by default so you're certain to a have it `100px` wide/tall

// wrap
<FlexView wrap />

Remember how difficult it was to center a div inside another div? flexbox definitely improved it, but still having to switch from align-items to justify-content based on flex-direction of the parent is confusing and error prone.

FlexView lets you align and center children with two intuitive props: vAlignContent and hAlignContent.

<FlexView hAlignContent='center' vAlignContent='center'>
  <FlexView>the center of the Earth</FlexView>
</FlexView>

How to use

In your component:

import React from 'react';
import FlexView from 'react-flexview';

export default class Component extends React.Component {
  render() {
    return (
      <FlexView vAlignContent='center'>
        I'm vertically centered!
      </FlexView>
    );
  }
}

Props

|Name|Type|Default|Description| |----|----|-------|-----------| | children | ReactChildren | | required. FlexView content | | column | Boolean | | optional. Flex-direction: column | | vAlignContent | enum("top" | "center" | "bottom") | | optional. Align content vertically | | hAlignContent | enum("left" | "center" | "right") | | optional. Align content horizontally | | marginLeft | union(String | Number) | | optional. Margin-left property ("auto" to align self right) | | marginTop | union(String | Number) | | optional. Margin-top property ("auto" to align self bottom) | | marginRight | union(String | Number) | | optional. Margin-right property ("auto" to align self left) | | marginBottom | union(String | Number) | | optional. Margin-bottom property ("auto" to align self top) | | grow | union(Boolean | Number) | | optional. Property (for parent primary axis) | | shrink | union(Boolean | Number) | | optional. Flex-shrink property | | basis | union(String | Number) | | optional. Flex-basis property | | wrap | Boolean | | optional. Wrap content | | height | union(String | Number) | | optional. Height property (for parent secondary axis) | | width | union(String | Number) | | optional. Width property (for parent secondary axis) | | className | String | | optional. Additional className for wrapper element | | style | Object | | optional. Inline-style overrides for wrapper element |

Demo

Here's a live playground

Documentation

Refer to the Book of FlexView

Supported browsers

We removed vendor prefixes in #66, since than we only supports browsers that don't require prefixes for flexbox CSS properties which are most browsers:

  • IE 11
  • Edge (any version)
  • Google Chrome 29+
  • Firefox 28+
  • Safari 9+

If you need to support older browsers, try with FlexView 3.x.

Used By

At buildo we've been using FlexView in production in every web application we built since July 2015 (it was in a different repo back then).

As of today, FlexView has replaced the div as the brick of our projects and, thanks to it, our developers can finally build without too much trouble complex layouts that work the same on Chrome, Firefox, Safari and Internet Explorer 11.

You can see it in action here: