import React, { Component, PropTypes } from 'react'
import classnames from 'classnames'

export const Divider = () => <hr className="divider"/>

export default class Dropdown extends Component {

    static propTypes = {
        dropup: PropTypes.bool,
        className: PropTypes.string,
        btnClass: PropTypes.string.isRequired
    }

    static defaultProps = {
        dropup: false
    }

    constructor(props, context) {
        super(props, context)
        this.state = { open: false }
        this.close = this.close.bind(this)
        this.open = this.open.bind(this)
    }

    close() {
        this.setState({ open: false })
        document.removeEventListener('click', this.close)
    }

    open(e){
        e.preventDefault()
        if (this.state.open) {
            return
        }
        this.setState({open: !this.state.open})
        document.addEventListener('click', this.close)
    }

    render() {
        const {dropup, className, btnClass, text, children} = this.props
        return (
            <div className={classnames( (dropup ? 'dropup' : 'dropdown'), className, { open: this.state.open })}>
                <a href='#' className={btnClass}
                   onClick={this.open}>
                    {text}
                </a>
                <ul className="dropdown-menu" role="menu">
                    {children.map ( (item, i) =>  <li key={i}> {item} </li> )}
                </ul>
            </div>
        )
    }
}
>upstream</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>upstream openwrt</td><td class='sub right'>James</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/openwrt/upstream/about/?h=v19.07.3'>about</a><a href='/cgit.cgi/openwrt/upstream/?h=v19.07.3'>summary</a><a href='/cgit.cgi/openwrt/upstream/refs/?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>refs</a><a href='/cgit.cgi/openwrt/upstream/log/target/linux/ar71xx/Makefile?h=v19.07.3'>log</a><a class='active' href='/cgit.cgi/openwrt/upstream/tree/target/linux/ar71xx/Makefile?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>tree</a><a href='/cgit.cgi/openwrt/upstream/commit/target/linux/ar71xx/Makefile?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>commit</a><a href='/cgit.cgi/openwrt/upstream/diff/target/linux/ar71xx/Makefile?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>diff</a><a href='/cgit.cgi/openwrt/upstream/stats/target/linux/ar71xx/Makefile?h=v19.07.3'>stats</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/openwrt/upstream/log/target/linux/ar71xx/Makefile'>
<input type='hidden' name='h' value='v19.07.3'/><input type='hidden' name='id' value='0e2586a7748385c97062a8d8816c98011175fb3d'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/openwrt/upstream/tree/?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>root</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>target</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>linux</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux/ar71xx?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>ar71xx</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux/ar71xx/Makefile?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>Makefile</a></div><div class='content'>blob: b65fe860655066204374e9f9ebb510fc45d9bd06 (<a href='/cgit.cgi/openwrt/upstream/plain/target/linux/ar71xx/Makefile?h=v19.07.3&amp;id=0e2586a7748385c97062a8d8816c98011175fb3d'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
</pre></td>
<td class='lines'><pre><code>