Sha256: 68986420fa4bc90e11e82afa0a6a5d7cac24e31291917ff92ed913c96c7179c7
Contents?: true
Size: 1.88 KB
Versions: 30
Compression:
Stored size: 1.88 KB
Contents
Rev.registerMixin 'Core', cx: React.addons.classSet suitSet: (base, flags)-> classes = {} classes[base] = true for key, value of flags classes["#{base}--#{key}"] = value @cx classes # Returns a copy of @props sans specific keys # Example: # props = @getPropsWithout "className" # <div {...props}><button className={@props.className}>hi</button></div> getPropsWithout: -> skipList = {} skipList[name] = true for name in arguments props = {} for name, value of @props props[name] = value unless skipList[name] props # An object that maps the CSS classes of @props.className from their name to `true`. _getClassSetObject: -> return {} unless @props.className classNames = @props.className.split ' ' object = {} object[name] = true for name in classNames object # Like React.addons.classSet but where the existing classes of @props.className are included. # (Unless they are overridden by `classToBoolMap`.) # Example: # className = @classAdd # active: @props.active # <div className={className}>hi</div> classAdd: (classToBoolMap) -> newClassToBoolMap = @_getClassSetObject() newClassToBoolMap[name] = value for name, value of classToBoolMap React.addons.classSet newClassToBoolMap # Alias for `React.addons.classSet` classSet: React.addons.classSet # Alias for `@classSet` cx: -> @classSet.apply this, arguments # Returns @props.children always as either `null` or an array. # This is because for some reason in React `children` is only an array when # there is more than one. Sometimes it's easier to be able to assume it's an # array. # Example: # <ul>{@getNormalizedChildren().map (i, child) -> <li key={i}>{child}</li>}</ul> getNormalizedChildren: -> children = @props.children if children? and not children.length children = [children] children
Version data entries
30 entries across 30 versions & 1 rubygems