Sha256: b11681fd5952cb258112cc313a1484752c85a07b6b569c683b229b3018b121ec

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 KB

Contents

Rev.registerComponent 'Tabs',

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

  getInitialState: ->
    children = @getNormalizedChildren()

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

    state =
      activeTabKey: activeTabKey

  renderTab: (child) ->
    key = child.key
    className = @classSet
      active: key == @state.activeTabKey
    <dd key={key} className={className} onClick={@handleTabClick(child)}>{child.props.tab}</dd>

  renderContent: (child) ->
    newProps =
      key: child.key
    newProps.active = true if child.key == @state.activeTabKey
    React.addons.cloneWithProps child, newProps

  render: ->
    children = @getNormalizedChildren()
    dlClassName = @classSet
      tabs: true
      vertical: @props.vertical
    <div>
      <dl className={dlClassName}>
        {children.map @renderTab}
      </dl>
      <div className="RevTabsContent tabs-content">
        {children.map @renderContent}
      </div>
    </div>

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
revelry_core-0.1.6.6 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.6.5 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.6.4 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.6.3 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.6.2 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.6.1 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.5 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.4 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.3 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.2 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.1 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.1.0 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.0.1 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx
revelry_core-0.0.0 app/assets/javascripts/revelry/ui/tabs/Tabs.js.cjsx