Sha256: 327e41e61e33241c6666d5ed69214c697bf3de3b22e891655afb570e275a5daa

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

Rev.registerMixin('Core', {

  suitSetObject: function(base, flags) {
    let obj = {}
    obj[base] = true
    for(let name in flags) {
      obj[`${base}--${name}`] = flags[name]
    }
    return obj
  },

  suitSet: function(base, flags) {
    return this.classSet(this.suitSetObject(base, flags))
  },

  getPropsWithout: function(...names) {
    return _.omit(this.props, names)
  },

  classSet: function(flags) {
    let classNames = []
    for(let name in flags) {
      if(flags[name]) {
        classNames.push(name)
      }
    }
    return classNames.join(' ')
  },

  cx: function() {
    this.classSet.apply(this, arguments)
  },

  getClassSetObjectFromClassName: function(className) {
    let obj = {}
    className.split(' ').forEach((name) => {
      obj[name.trim()] = true
    })
    return obj
  },

  classAdd: function(flags) {
    let obj = this.getClassSetObjectFromClassName(this.props.className || '')
    _.extend(obj, flags)
    return this.classSet(obj)
  },

  mapChildren: function(fn) {
    return React.Children.map(this.props.children, fn)
  },

  getNormalizedChildren: function() {
    console.warn('Core mixin method `getNormalizedChildren` is deprecated. Please use `mapChildren` or `React.Children.map`.')
    let children = this.props.children
    return children && children.length === 0 ? [children] : children
  },

})

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
revelry_core-0.1.24.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.23.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.22.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.21.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.20.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.19.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.18.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.17.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.16.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.15.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.14.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.13.0 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.6 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.5 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.4 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.3 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.2 app/assets/javascripts/revelry/mixins/core.es6
revelry_core-0.1.12.0 app/assets/javascripts/revelry/mixins/core.es6