diff --git a/src/app/ui/dropdown.js b/src/app/ui/dropdown.js new file mode 100644 index 0000000000..60567adf0d --- /dev/null +++ b/src/app/ui/dropdown.js @@ -0,0 +1,138 @@ +var yo = require('yo-yo') +var csjs = require('csjs-inject') +var EventManager = require('ethereum-remix').lib.EventManager + +var css = csjs` + .dropdown { + position : relative; + display : flex; + flex-direction : column; + color : black; + } + .selectbox { + display : flex; + align-items : center; + background-color : lightgrey; + border-radius : 5px; + margin : 3px; + cursor : pointer; + } + .selected { + display : inline-block; + min-width : 30ch; + max-width : 30ch; + white-space : nowrap; + text-overflow : ellipsis; + overflow : hidden; + } + .icon { + padding : 0px 5px; + } + .options { + position : absolute; + display : flex; + flex-direction : column; + min-width : 30ch; + max-width : 30ch; + top : 21px; + left : 10px; + background-color : white; + border : 1px solid black; + } + .option { + margin: 0; + } +` +/* USAGE: + + var dropdown = new Dropdown({ + options: [ + 'knownTransaction', + 'unknownTransaction', + 'log', + 'info', + 'error' + ], + defaults: ['knownTransaction'] + }) + dropdown.event.register('deselect', function (label) { }) + dropdown.event.register('select', function (label) { }) + +*/ +class Dropdown { + constructor (opts = {}) { + var self = this + self.event = new EventManager() + self.data = { + _options: opts.options || [], + selected: opts.defaults || [] + } + self._view = {} + self._api = opts.api + self._events = opts.events + } + render () { + var self = this + if (self._view.el) return self._view.el + self._view.selected = yo` +