2019-02-26 18:51:22 +03:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classNames from 'classnames'
|
|
|
|
import { navigate } from 'gatsby'
|
|
|
|
|
|
|
|
import classes from '../styles/dropdown.module.sass'
|
|
|
|
|
2020-08-06 02:22:49 +03:00
|
|
|
export default function Dropdown({ defaultValue, className, onChange, children }) {
|
2019-02-26 18:51:22 +03:00
|
|
|
const defaultOnChange = ({ target }) => navigate(target.value)
|
|
|
|
return (
|
|
|
|
<select
|
|
|
|
defaultValue={defaultValue}
|
|
|
|
className={classNames(classes.root, className)}
|
|
|
|
onChange={onChange || defaultOnChange}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</select>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Dropdown.propTypes = {
|
|
|
|
defaultValue: PropTypes.string,
|
|
|
|
className: PropTypes.string,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
}
|