UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

29 lines 1 kB
import _map from "lodash/map"; import _last from "lodash/last"; import _isEmpty from "lodash/isEmpty"; import React from 'react'; import createClass from 'create-react-class'; import { DropMenu } from '../../../index'; export default createClass({ getInitialState: function getInitialState() { return { selectedIndices: [] }; }, handleSelect: function handleSelect(optionIndex) { this.setState({ selectedIndices: [optionIndex] }); }, render: function render() { var selectedIndices = this.state.selectedIndices; var options = ['Red', 'Green', 'Blue']; return /*#__PURE__*/React.createElement(DropMenu, { onSelect: this.handleSelect }, /*#__PURE__*/React.createElement(DropMenu.Control, null, _isEmpty(selectedIndices) ? 'Select' : options[_last(selectedIndices)]), _map(options, function (optionText, index) { return /*#__PURE__*/React.createElement(DropMenu.Option, { key: 'Option-' + index }, optionText); })); } });