Flexr
React Flexbox grid made simple. Based on the "Solved-by-flexbox"-grid
Usage
Base example.
If you don't use webpack with css-loader, make sure to include the react-flexr/styles.css
somewhere in your project. For more advanced use cases, the Stilr
stylesheet is also exposed.
Cell sizes can be controlled with fractions.
Component API:
Grid
Cell
* Ergonomic breakpoints accepts 'hidden' as well. This will prevent the
component from being rendered in that state.
See the example folder for more examples.
Responsive Props
The responsive props are based on ergonomics.
We've used these breakpoints in a variety of apps and grids with success. So far the following breakpoints have beeen implemented:
- Palm
- Lap
- Portable
- Desk
See the breakpoint config object for sizes.
Flexr Helpers
Use these to get the most out of Flexr. Especially findMatch
is very useful when you need to add different behaviour based on window width outside of the grid/cell elements.
string|false findMatch(string arguments)
This is the internal function that Flexr uses to check which ergonomic state
it's currently in. It's really useful if you have components outside the grid, that you
want to show/hide/manipulate passed properties or stuff in your lifecycle hooks.
The function accepts multipe ergonomic breakpoints as strings and returns the first one matched or false if nothing matches.
Example
setBreakpoints( array breakpoints )
It's posible to force flexr to be in a specific ergonomic state. This is
primarily usefull when rendering on the server. E.g. looking at the user agent
string on rendering the app in palm/portable if it's an iOS/iPhone or
lap/portable if iOS/iPad.
Example
array|false findBreakpoints()
Force flexr to find the current breakpoints. Returns an array of the current
breakpoints that flexr matches in. If they haven't changed since the last time
findBreakpoints()
was called, false will be returned.
Use in combination with optimizedResize
.
Example
optimizedResize.init( function )
Simple resize event throttler. Usefull for force updating when the app have been
resized. For best performance, use it in your main app component in the
componentDidMount life cycle.
Example
array getBreakpoints()
returns an array of current breakpoints.
Map stylesheet
The internal Stilr stylesheet used to
handle basic flexbox styling for the components.
Usefull if you need full controll of how the CSS is rendered. Reed the Stilr
documentation on how to use Stilr if you need finegrained controll over you
styling.
palm, lap, portable, desk
The ergonomic breakpoint media queries that flexr uses internally is also
exposed. These are especially useful in combination with Stilr.
Example