1.0.0-beta9 • Published 6 years ago

robox-modern v1.0.0-beta9

Weekly downloads
3
License
MIT
Repository
-
Last release
6 years ago

Robox

Higher-order React component for adding style helper props based on understyle

Build Status js-standard-style

npm i robox
// Example component
import React from 'react'
import Robox from 'robox'

const Button = (props) => {
  return <button {...props} />
}

export default Robox(Button)
// Example component instance

<div>
  <Button
    m={2}
    p={2}
    onClick={e => alert('hello')}
    children='Hello' />
</div>

Props

Margin

Sets margin based on a 0–6 spacing scale array [0, 8, 16, 32, 48, 64, 96]

proptypedescription
mnumbermargin
mtnumbermargin-top
mrnumbermargin-right
mbnumbermargin-bottom
mlnumbermargin-left
mxnumbermargin-left and margin-right
mynumbermargin-top and margin-bottom

Padding

Sets padding based on the same spacing scale

proptypedescription
pnumberpadding
ptnumberpadding-top
prnumberpadding-right
pbnumberpadding-bottom
plnumberpadding-left
pxnumberpadding-left and padding-right
pynumberpadding-top and padding-bottom

Width

Sets percentage-based width based on a 12 column grid

proptypedescription
colnumber0-12

Display

Sets display based on the prop name

proptype
blockboolean
inlineBlockboolean
inlineboolean
tableboolean
tableRowboolean
tableCellboolean
flexboolean
inlineFlexboolean

Flexbox

Sets various flexbox layout properties

proptypedescription
wrapbooleanflex-wrap: wrap
alignstringalign-items
justifystringjustify-content
flexColumnbooleanflex-direction: column
flexAutobooleanflex: 1 1 auto
flexNonebooleanflex: none
ordernumberorder

Configuration

The space scale and number of grid columns can be configured through React context.

// Example context configuration
class App extends React.Component {
  getChildContext () {
    return {
      robox: {
        scale: [0, 6, 12, 18, 24, 30, 36],
        columns: 16
      }
    }
  }
}

App.contextTypes = {
  robox: React.PropTypes.object
}

MIT License