Sha256: 9a60138781e93a65e37a4250adb4307aea16ce765a492fd2523115e73eab26a8

Contents?: true

Size: 1.11 KB

Versions: 22

Compression:

Stored size: 1.11 KB

Contents

Rev.registerComponent 'TabsAccordion',

  getDefaultProps: ->
    props =
      onChange: () -> # noop
      activeKey: null

  getInitialState: ->
    children = @getNormalizedChildren()

    activeTabKey = @props.activeKey
    activeTabKey ||= children[0].key if children.length > 0

    state =
      activeTabKey: activeTabKey

  render: ->
    children = @getNormalizedChildren()
    <ul className="RevAccordion accordion">{children.map @renderChild}</ul>

  renderChild: (child) ->
    key = child.key

    active = key == @state.activeTabKey

    className = @classSet
      "RevTabsAccordion": true
      "RevTabsAccordion is-active": true
      "accordion-navigation": true
      "active": active

    tab = React.addons.cloneWithProps child.props.tab,
      onClick: @handleTabClick child

    content = React.addons.cloneWithProps child,
      active: active

    <li key={key} className={className}>
      {tab}
      {content}
    </li>

  handleTabClick: (activeTab) -> (e) =>
    e.preventDefault()
    e.stopPropagation()
    @setState
      activeTabKey: activeTab.key
    e.activeTab = activeTab
    @props.onChange(e)

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
revelry_core-0.1.8.4 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.8.3 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.8.2 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.8.1 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.8.0 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.7.0 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.8 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.7 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.6 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.5 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.4 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.3 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.2 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.6.1 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.5 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.4 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.3 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.2 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.1 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx
revelry_core-0.1.0 app/assets/javascripts/revelry/ui/tabs/TabsAccordion.js.cjsx