{"action":"created","comment":{"url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments/38852150","id":38852150,"diff_hunk":"@@ -0,0 +1,77 @@\n+var React = require('react');\n+var cx = require('classnames');\n+\n+var utils = require('../lib/widget-utils.js');\n+\n+var defaultTemplate = `<a href=\"{{href}}\">{{name}}</a> {{count}}`;\n+\n+var hierarchicalCounter = 0;\n+\n+/**\n+ * Instantiate a list of refinements based on a facet\n+ * @param  {String|DOMElement} options.container Valid CSS Selector as a string or DOMElement\n+ * @param  {String} options.facetName Name of the attribute for faceting\n+ * @param  {String[]} [options.sortBy=['count:desc']] How to sort refinements. Possible values: `count|isRefined|name:asc|desc`\n+ * @param  {String} [options.limit=100] How much facet values to get.\n+ * @param  {String|String[]} [options.rootClass=null] CSS class(es) for the root `<ul>` element\n+ * @param  {String|String[]} [options.itemClass=null] CSS class(es) for the item `<li>` element\n+ * @param  {String|Function} [options.template] Item template, provided with `name`, `count`, `isRefined`\n+ * @return {Object}\n+ */\n+function menu({\n+    container = null,\n+    facetName = null,\n+    sortBy = ['count:desc'],\n+    limit = 100,\n+    rootClass = null,\n+    itemClass = null,\n+    template = defaultTemplate\n+  }) {\n+  hierarchicalCounter++;\n+\n+  var MultipleChoiceList = require('../components/MultipleChoiceList');\n+\n+  var containerNode = utils.getContainerNode(container);\n+  var usage = 'Usage: menu({container, facetName, [sortBy, limit, rootClass, itemClass, template]})';\n+\n+  if (container === null || facetName === null) {\n+    throw new Error(usage);\n+  }\n+\n+  var hierarchicalFacetName = 'instantsearch.js' + hierarchicalCounter;\n+\n+  return {\n+    getConfiguration: () => ({","path":"widgets/menu.js","position":44,"original_position":44,"commit_id":"0454d0460c6092402d2bd4bf416925d04f3a9422","original_commit_id":"0454d0460c6092402d2bd4bf416925d04f3a9422","user":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"body":"In fact here it's required by ES6, Sylvain asked the same question. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions\r\n\r\nI agree this is a bit surprising.\r\n\r\n\"Because curly braces are used to denote the function’s body, an arrow function that wants to return an object literal outside of a function body must wrap the literal in parentheses. For example\"\r\n\r\nhttps://www.nczonline.net/blog/2013/09/10/understanding-ecmascript-6-arrow-functions/","created_at":"2015-09-07T10:46:36Z","updated_at":"2015-09-07T10:46:36Z","html_url":"https://github.com/algolia/instantsearch.js/pull/63#discussion_r38852150","pull_request_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments/38852150"},"html":{"href":"https://github.com/algolia/instantsearch.js/pull/63#discussion_r38852150"},"pull_request":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63","id":44259754,"html_url":"https://github.com/algolia/instantsearch.js/pull/63","diff_url":"https://github.com/algolia/instantsearch.js/pull/63.diff","patch_url":"https://github.com/algolia/instantsearch.js/pull/63.patch","issue_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/63","number":63,"state":"open","locked":false,"title":"feat(menu): first widget version","user":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"body":"So it works(tm).\r\n\r\n![untitled screencast 2](https://cloud.githubusercontent.com/assets/123822/9694558/04653428-535a-11e5-89b3-8a6d94fc8f9c.gif)\r\n\r\nAfter a bit of tuning I was even able to get the bootstrap rendering to be fine. I first thought that we would hit a wall because of the react div wrapping but we are still ok.\r\n\r\nAs for the APIs: `menu`, `multipleChoiceList` (or `refinementList` is we rename it).\r\nIt does seems that they could all be the same widget. We only have three behaviors:\r\n- `menu`: refinementList with only one selectable item at a time\r\n- `refinementList` + multiple selectable items + AND\r\n- `refinementList` + multiple selectable items + AND\r\n\r\nWe could merge both widgets into a single widget.\r\n\r\nBut we still need to express the hierarchical menu feature.\r\nSo having already a menu widget seems the easiest rather than trying to bend the `multipleChoiceList` API into something understanding the hierarchical menu. cc @redox ?","created_at":"2015-09-04T20:45:27Z","updated_at":"2015-09-07T10:46:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b63351567ed798ffdf70be221916075652454006","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63/commits","review_comments_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63/comments","review_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/63/comments","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/0454d0460c6092402d2bd4bf416925d04f3a9422","head":{"label":"algolia:feat/menu-1st-version","ref":"feat/menu-1st-version","sha":"0454d0460c6092402d2bd4bf416925d04f3a9422","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":39443258,"name":"instantsearch.js","full_name":"algolia/instantsearch.js","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/instantsearch.js","description":"Instant search for everyone","fork":false,"url":"https://api.github.com/repos/algolia/instantsearch.js","forks_url":"https://api.github.com/repos/algolia/instantsearch.js/forks","keys_url":"https://api.github.com/repos/algolia/instantsearch.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/instantsearch.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/instantsearch.js/teams","hooks_url":"https://api.github.com/repos/algolia/instantsearch.js/hooks","issue_events_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/instantsearch.js/events","assignees_url":"https://api.github.com/repos/algolia/instantsearch.js/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/instantsearch.js/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/instantsearch.js/tags","blobs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/instantsearch.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/instantsearch.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/instantsearch.js/languages","stargazers_url":"https://api.github.com/repos/algolia/instantsearch.js/stargazers","contributors_url":"https://api.github.com/repos/algolia/instantsearch.js/contributors","subscribers_url":"https://api.github.com/repos/algolia/instantsearch.js/subscribers","subscription_url":"https://api.github.com/repos/algolia/instantsearch.js/subscription","commits_url":"https://api.github.com/repos/algolia/instantsearch.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/instantsearch.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/instantsearch.js/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/instantsearch.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/instantsearch.js/merges","archive_url":"https://api.github.com/repos/algolia/instantsearch.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/instantsearch.js/downloads","issues_url":"https://api.github.com/repos/algolia/instantsearch.js/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/instantsearch.js/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/instantsearch.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/instantsearch.js/labels{/name}","releases_url":"https://api.github.com/repos/algolia/instantsearch.js/releases{/id}","created_at":"2015-07-21T12:10:27Z","updated_at":"2015-09-05T06:26:26Z","pushed_at":"2015-09-04T22:28:54Z","git_url":"git://github.com/algolia/instantsearch.js.git","ssh_url":"git@github.com:algolia/instantsearch.js.git","clone_url":"https://github.com/algolia/instantsearch.js.git","svn_url":"https://github.com/algolia/instantsearch.js","homepage":null,"size":408,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":3,"default_branch":"develop"}},"base":{"label":"algolia:develop","ref":"develop","sha":"5cbf451b798ea89d744ad7abcf37f8ac669a7c0c","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":39443258,"name":"instantsearch.js","full_name":"algolia/instantsearch.js","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/instantsearch.js","description":"Instant search for everyone","fork":false,"url":"https://api.github.com/repos/algolia/instantsearch.js","forks_url":"https://api.github.com/repos/algolia/instantsearch.js/forks","keys_url":"https://api.github.com/repos/algolia/instantsearch.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/instantsearch.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/instantsearch.js/teams","hooks_url":"https://api.github.com/repos/algolia/instantsearch.js/hooks","issue_events_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/instantsearch.js/events","assignees_url":"https://api.github.com/repos/algolia/instantsearch.js/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/instantsearch.js/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/instantsearch.js/tags","blobs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/instantsearch.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/instantsearch.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/instantsearch.js/languages","stargazers_url":"https://api.github.com/repos/algolia/instantsearch.js/stargazers","contributors_url":"https://api.github.com/repos/algolia/instantsearch.js/contributors","subscribers_url":"https://api.github.com/repos/algolia/instantsearch.js/subscribers","subscription_url":"https://api.github.com/repos/algolia/instantsearch.js/subscription","commits_url":"https://api.github.com/repos/algolia/instantsearch.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/instantsearch.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/instantsearch.js/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/instantsearch.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/instantsearch.js/merges","archive_url":"https://api.github.com/repos/algolia/instantsearch.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/instantsearch.js/downloads","issues_url":"https://api.github.com/repos/algolia/instantsearch.js/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/instantsearch.js/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/instantsearch.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/instantsearch.js/labels{/name}","releases_url":"https://api.github.com/repos/algolia/instantsearch.js/releases{/id}","created_at":"2015-07-21T12:10:27Z","updated_at":"2015-09-05T06:26:26Z","pushed_at":"2015-09-04T22:28:54Z","git_url":"git://github.com/algolia/instantsearch.js.git","ssh_url":"git@github.com:algolia/instantsearch.js.git","clone_url":"https://github.com/algolia/instantsearch.js.git","svn_url":"https://github.com/algolia/instantsearch.js","homepage":null,"size":408,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63"},"html":{"href":"https://github.com/algolia/instantsearch.js/pull/63"},"issue":{"href":"https://api.github.com/repos/algolia/instantsearch.js/issues/63"},"comments":{"href":"https://api.github.com/repos/algolia/instantsearch.js/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/algolia/instantsearch.js/statuses/0454d0460c6092402d2bd4bf416925d04f3a9422"}}}}