react-flexbox-svg
Flexbox for SVG in React, using css-layout.
css-layout is Facebook's JavaScript reimplementation of CSS which is now part of Yoga.
Based on react-flexbox-svg by David Manning.
Features
- Define item layout statically or compute it from props.
- Render layout rectangles for debugging (visible or not).
- Pass layout into child props if needed.
- No magic.
- ES7 decorator ready.
Usage
import React from 'react'import FlexContext FlexContainer from 'react-flexbox-svg' Component { return <svg ="800" ="600"> <FlexContext> <FlexContainer => <Item ="1" /> <Item ="2" /> <Item ="3" /> </FlexContainer> </FlexContext> </svg> }
Component { const height = Itemlayout return <rect = ="100%" ="black" ="3" /> }Itemlayout = margin: 25 height: 50 ItemlayoutItem
As a functional component:
const Item = <rect ="50" ="100%" ="black" ="3" />
Using ES7 decorators:
@Component { const height = Itemlayout return <rect = ="100%" ="black" ="3" /> }Itemlayout = margin: 10 height: 100
In the examples folder is a more interesting example featuring a dynamic collection.
Installation
npm install --save babel-runtime react-flexbox-svg
Contribute
- Issue Tracker: https://github.com/metabolize/react-flexbox-svg/issues
- Source Code: https://github.com/metabolize/react-flexbox-svg/
Pull requests welcome!
Support
If you are having issues, please let me know.
License
This projects is licensed under the ISC license.