Skip to content

Instantly share code, notes, and snippets.

@patowens
Last active September 28, 2015 00:09
Show Gist options
  • Save patowens/c81b2343cd305a8f0900 to your computer and use it in GitHub Desktop.
Save patowens/c81b2343cd305a8f0900 to your computer and use it in GitHub Desktop.
<dropdown>
<span class="handle { expanded: is_open }" onclick={ toggle }>{ opts.title }</span>
<ul>
<li each={ items } onclick={ select }></li>
</ul>
</dropdown>
// require your favourite things..
var dependency = require('your-favourite-lib');
// logic comes here..
this.items = [
{ title: 'hello' },
{ title: 'world' }
];
toggle() {
this.is_open = !this.is_open;
};
select(e) {
console.log('you have selected: ', e.target);
};
this.on('mount', function() {
this.is_open = false;
// do things, perhaps with famous etc..
});
// allowing scss please
dropdown {
span ul {
display:none;
}
span.expanded ul {
display: "";
}
}
<html>
<head></head>
<body>
<h1>Hello world, this is my page</h1>
<dropdown title="click here!" items={ someArrayOfItems }></dropdown>
</body>
</html>
testComponent('dropdown', {title="click here!", items: [{ title: 'hello', 'world'}] }, function(err, document) {
f = feryt(document);
f.find('.handle').equals("click here!")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment