import React, { Component } from 'react'
import PropTypes from 'prop-types'
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>
        )
    }
}
table class='tabs'><tr><td>
<a href='/cgit/xen/xen/about/?h=staging-4.1'>about</a><a href='/cgit/xen/xen/?h=staging-4.1'>summary</a><a href='/cgit/xen/xen/refs/?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>refs</a><a href='/cgit/xen/xen/log/buildconfigs/mk.linux-2.6-native?h=staging-4.1'>log</a><a class='active' href='/cgit/xen/xen/tree/buildconfigs/mk.linux-2.6-native?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>tree</a><a href='/cgit/xen/xen/commit/buildconfigs/mk.linux-2.6-native?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>commit</a><a href='/cgit/xen/xen/diff/buildconfigs/mk.linux-2.6-native?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>diff</a><a href='/cgit/xen/xen/stats/buildconfigs/mk.linux-2.6-native?h=staging-4.1'>stats</a></td><td class='form'><form class='right' method='get' action='/cgit/xen/xen/log/buildconfigs/mk.linux-2.6-native'>
<input type='hidden' name='h' value='staging-4.1'/><input type='hidden' name='id' value='ec4e2ccc864036432b993c46e3a173e64767761c'/><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/xen/xen/tree/?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>root</a>/<a href='/cgit/xen/xen/tree/buildconfigs?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>buildconfigs</a>/<a href='/cgit/xen/xen/tree/buildconfigs/mk.linux-2.6-native?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>mk.linux-2.6-native</a></div><div class='content'>blob: c7c094937189088bf5f0b357e6d49e73299b65ac (<a href='/cgit/xen/xen/plain/buildconfigs/mk.linux-2.6-native?h=staging-4.1&amp;id=ec4e2ccc864036432b993c46e3a173e64767761c'>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>
</pre></td>
<td class='lines'><pre><code>