all files / packages/layout/ Layout.js

0% Statements 0/8
0% Branches 0/4
0% Functions 0/1
0% Lines 0/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import { Component } from '../../ui'
 
/**
  Layout component for simple layout tasks, without having to write CSS
 
  @class
  @component
 
  @prop {String} width 'small', 'medium', 'large' and 'full'
  @prop {String} [textAlign] 'center', 'left' or 'right'
  @prop {String} [noPadding] No padding around layout, will fill the whole space
 
  @example
 
  ```js
  var form = $$(Layout, {
    width: 'large',
    textAlign: 'center'
  });
  ```
*/
class Layout extends Component {
 
  render($$) {
    let el = $$('div').addClass('sc-layout')
    el.addClass('sm-width-'+this.props.width)
    if (this.props.textAlign) {
      el.addClass('sm-text-align-'+this.props.textAlign)
    }
 
    if (this.props.noPadding) {
      el.addClass('sm-no-padding')
    }
 
    el.append(this.props.children)
    return el
  }
}
 
export default Layout