2.2.0 • Published 9 years ago

tbg_media_query v2.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Media Query Component

How to use

  MediaQuery  = React.createFactory(require('tbg_media_query'))
  
  ...

  renderTextLarge: ->
    DOM.p({}, 'Large Screen Text only'),

  renderTextSmall: ->
    DOM.p({}, 'Small Screen Text only'),

  render: ->
    textSmall = this.renderTextSmall()
    textLarge = this.renderTextLarge()

    DOM.div( null,
    [
      DOM.h1({}, 'The title'),
      MediaQuery({
        breakpoints: {
          baby:    textSmall
          sister:  textSmall
          brother: textLarge
          mother:  textLarge
        }
      })
      
    ])

Configuration

The component takes the following optional properties:

  • defaultBreakpoint - default: 'mother' - The size the server will render
  • component - default: 'div' - The component that the child content will be rendered into.
  • componentProps - default: {} - props to be based to parent component
  MediaQuery  = React.createFactory(require('tbg_media_query'))
  
  ...

  render: ->
    textSmall = this.renderTextSmall()
    textLarge = this.renderTextLarge()

    DOM.div( null,
    [
      DOM.h1({}, 'The title'),
      MediaQuery({
        defaultBreakpoint: "baby"
        component: 'aside'
        componentProps: {className: "sidebar"} 
        breakpoints: {
          baby:    textSmall
          sister:  textSmall
          brother: textLarge
          mother:  textLarge
        }
      })
    ])
2.2.0

9 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.0.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago