{"action":"created","comment":{"url":"https://api.github.com/repos/dasherapp/dasher/pulls/comments/184820383","pull_request_review_id":116093766,"id":184820383,"diff_hunk":"@@ -0,0 +1,260 @@\n+import React, { Component } from 'react'\n+import { oneOf, oneOfType, func, string, number } from 'prop-types'\n+import glamorous from 'glamorous'\n+import posed from 'react-pose'\n+\n+import {\n+  spacing,\n+  colors,\n+  radii,\n+  fontSizes,\n+  lineHeights,\n+  shadows,\n+  transition,\n+} from '../theme'\n+import { joinSpacing, toAlpha } from '../utils/style'\n+\n+const MenuContainer = glamorous.div({\n+  position: 'relative',\n+  display: 'inline-block',\n+})\n+\n+const PosedMenu = posed.div({\n+  open: {\n+    scale: 1,\n+  },\n+  closed: {\n+    scale: 0,\n+    display: 'none',\n+  },\n+})\n+\n+const Menu = glamorous(PosedMenu, { filterProps: ['minWidth', 'align'] })(\n+  props => ({\n+    position: 'absolute',\n+    [props.align]: 0,\n+    display: 'flex',\n+    flexDirection: 'column',\n+    minWidth: props.minWidth,\n+    marginTop: spacing[0],\n+    padding: joinSpacing(spacing[0], 0),\n+    backgroundColor: colors.gray[8],\n+    borderRadius: radii[1],\n+    boxShadow: shadows[3],\n+    overflow: 'hidden',\n+    transformOrigin: `top ${props.align}`,\n+  }),\n+)\n+\n+export const MenuItem = glamorous('button', {\n+  withProps: { role: 'menuitem', tabIndex: -1 },\n+})({\n+  display: 'block',\n+  width: '100%',\n+  padding: joinSpacing(spacing[1], spacing[3]),\n+  fontFamily: 'inherit',\n+  fontSize: fontSizes[1],\n+  lineHeight: lineHeights.tight,\n+  textAlign: 'left',\n+  color: colors.white,\n+  backgroundColor: 'transparent',\n+  border: 0,\n+  outline: 0,\n+  cursor: 'pointer',\n+  whiteSpace: 'nowrap',\n+  transition: `background-color ${transition.duration} ${transition.easing}`,\n+\n+  ':hover,:focus': {\n+    backgroundColor: toAlpha(colors.gray[8], colors.black),\n+  },\n+})\n+\n+export const MenuDivider = glamorous.div({\n+  display: 'block',\n+  width: '100%',\n+  height: 0,\n+  borderTop: `1px solid ${toAlpha(colors.gray[9], colors.black)}`,\n+  margin: joinSpacing(spacing[0], 0),\n+})\n+\n+class Dropdown extends Component {\n+  static propTypes = {\n+    renderMenuButton: func.isRequired,\n+    align: oneOf(['right', 'left']),\n+    minWidth: oneOfType([number, string]),\n+  }\n+\n+  static defaultProps = {\n+    align: 'right',\n+    minWidth: 'auto',\n+  }\n+\n+  constructor(props) {\n+    super(props)\n+\n+    this.menuButtonRef = React.createRef()\n+    this.menuRef = React.createRef()\n+\n+    this.state = {\n+      isOpen: false,\n+    }\n+  }\n+\n+  componentDidMount() {\n+    this.menuItems = this.menuRef.current.querySelectorAll('[role^=\"menuitem\"]')\n+\n+    if (this.menuItems.length < 1) {\n+      throw new Error('No menu items')\n+    }\n+\n+    const activeMenuItems = Array.prototype.filter.call(\n+      this.menuItems,\n+      item => !item.disabled,\n+    )\n+\n+    // Disable menu button if all menu items are disabled\n+    if (activeMenuItems.length < 1) {\n+      this.menuButtonRef.current.disabled = true\n+      return\n+    }\n+\n+    this.firstItem = this.menuItems[0]\n+    this.lastItem = this.menuItems[this.menuItems.length - 1]\n+\n+    Array.prototype.forEach.call(this.menuItems, menuItem => {\n+      menuItem.addEventListener('keydown', this.handleMenuItemKeyDown)\n+    })\n+\n+    this.menuButtonRef.current.addEventListener(\n+      'keydown',\n+      this.handleMenuButtonKeyDown,\n+    )\n+  }\n+\n+  componentWillUnmount() {\n+    Array.prototype.forEach.call(this.menuItems, menuItem => {\n+      menuItem.removeEventListener('keydown', this.handleMenuItemKeyDown)\n+    })\n+\n+    this.menuButtonRef.current.removeEventListener(\n+      'keydown',\n+      this.handlMenuButtonKeyDown,\n+    )\n+\n+    document.removeEventListener('click', this.close)\n+  }\n+\n+  handleMenuButtonKeyDown = event => {\n+    if (event.key === 'ArrowDown') {\n+      event.preventDefault()\n+      if (this.state.isOpen) {\n+        this.menuRef.current\n+          .querySelector('[role^=\"menuitem\"]:not([disabled])')\n+          .focus()\n+      } else {\n+        this.open()\n+      }\n+    }\n+\n+    if (event.key === 'Escape' || event.key === 'Tab') {\n+      this.close()\n+    }\n+\n+    if (event.key === 'Escape') {\n+      event.preventDefault()","path":"src/components/Dropdown.js","position":164,"original_position":164,"commit_id":"8bd5944f01ba6cb252e08303736a517a94e20140","original_commit_id":"8bd5944f01ba6cb252e08303736a517a94e20140","user":{"login":"lexahall","id":10774982,"avatar_url":"https://avatars3.githubusercontent.com/u/10774982?v=4","gravatar_id":"","url":"https://api.github.com/users/lexahall","html_url":"https://github.com/lexahall","followers_url":"https://api.github.com/users/lexahall/followers","following_url":"https://api.github.com/users/lexahall/following{/other_user}","gists_url":"https://api.github.com/users/lexahall/gists{/gist_id}","starred_url":"https://api.github.com/users/lexahall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexahall/subscriptions","organizations_url":"https://api.github.com/users/lexahall/orgs","repos_url":"https://api.github.com/users/lexahall/repos","events_url":"https://api.github.com/users/lexahall/events{/privacy}","received_events_url":"https://api.github.com/users/lexahall/received_events","type":"User","site_admin":false},"body":"I'm not sure I understand why we have two separate `if`s to check for `Escape`","created_at":"2018-04-27T22:27:39Z","updated_at":"2018-04-27T22:33:01Z","html_url":"https://github.com/dasherapp/dasher/pull/30#discussion_r184820383","pull_request_url":"https://api.github.com/repos/dasherapp/dasher/pulls/30","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/comments/184820383"},"html":{"href":"https://github.com/dasherapp/dasher/pull/30#discussion_r184820383"},"pull_request":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/dasherapp/dasher/pulls/30","id":184712916,"html_url":"https://github.com/dasherapp/dasher/pull/30","diff_url":"https://github.com/dasherapp/dasher/pull/30.diff","patch_url":"https://github.com/dasherapp/dasher/pull/30.patch","issue_url":"https://api.github.com/repos/dasherapp/dasher/issues/30","number":30,"state":"open","locked":false,"title":"Add Dropdown component","user":{"login":"colebemis","id":4608155,"avatar_url":"https://avatars0.githubusercontent.com/u/4608155?v=4","gravatar_id":"","url":"https://api.github.com/users/colebemis","html_url":"https://github.com/colebemis","followers_url":"https://api.github.com/users/colebemis/followers","following_url":"https://api.github.com/users/colebemis/following{/other_user}","gists_url":"https://api.github.com/users/colebemis/gists{/gist_id}","starred_url":"https://api.github.com/users/colebemis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colebemis/subscriptions","organizations_url":"https://api.github.com/users/colebemis/orgs","repos_url":"https://api.github.com/users/colebemis/repos","events_url":"https://api.github.com/users/colebemis/events{/privacy}","received_events_url":"https://api.github.com/users/colebemis/received_events","type":"User","site_admin":false},"body":"# To Do\r\n- [ ] Write tests","created_at":"2018-04-27T19:52:35Z","updated_at":"2018-04-27T22:33:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8b44855d0429453209623e39a6fe2220f1e8619","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dasherapp/dasher/pulls/30/commits","review_comments_url":"https://api.github.com/repos/dasherapp/dasher/pulls/30/comments","review_comment_url":"https://api.github.com/repos/dasherapp/dasher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dasherapp/dasher/issues/30/comments","statuses_url":"https://api.github.com/repos/dasherapp/dasher/statuses/8bd5944f01ba6cb252e08303736a517a94e20140","head":{"label":"dasherapp:dropdown","ref":"dropdown","sha":"8bd5944f01ba6cb252e08303736a517a94e20140","user":{"login":"dasherapp","id":38197409,"avatar_url":"https://avatars3.githubusercontent.com/u/38197409?v=4","gravatar_id":"","url":"https://api.github.com/users/dasherapp","html_url":"https://github.com/dasherapp","followers_url":"https://api.github.com/users/dasherapp/followers","following_url":"https://api.github.com/users/dasherapp/following{/other_user}","gists_url":"https://api.github.com/users/dasherapp/gists{/gist_id}","starred_url":"https://api.github.com/users/dasherapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasherapp/subscriptions","organizations_url":"https://api.github.com/users/dasherapp/orgs","repos_url":"https://api.github.com/users/dasherapp/repos","events_url":"https://api.github.com/users/dasherapp/events{/privacy}","received_events_url":"https://api.github.com/users/dasherapp/received_events","type":"Organization","site_admin":false},"repo":{"id":129560260,"name":"dasher","full_name":"dasherapp/dasher","owner":{"login":"dasherapp","id":38197409,"avatar_url":"https://avatars3.githubusercontent.com/u/38197409?v=4","gravatar_id":"","url":"https://api.github.com/users/dasherapp","html_url":"https://github.com/dasherapp","followers_url":"https://api.github.com/users/dasherapp/followers","following_url":"https://api.github.com/users/dasherapp/following{/other_user}","gists_url":"https://api.github.com/users/dasherapp/gists{/gist_id}","starred_url":"https://api.github.com/users/dasherapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasherapp/subscriptions","organizations_url":"https://api.github.com/users/dasherapp/orgs","repos_url":"https://api.github.com/users/dasherapp/repos","events_url":"https://api.github.com/users/dasherapp/events{/privacy}","received_events_url":"https://api.github.com/users/dasherapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dasherapp/dasher","description":"Flexible project dashboards powered by GitHub queries","fork":false,"url":"https://api.github.com/repos/dasherapp/dasher","forks_url":"https://api.github.com/repos/dasherapp/dasher/forks","keys_url":"https://api.github.com/repos/dasherapp/dasher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dasherapp/dasher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dasherapp/dasher/teams","hooks_url":"https://api.github.com/repos/dasherapp/dasher/hooks","issue_events_url":"https://api.github.com/repos/dasherapp/dasher/issues/events{/number}","events_url":"https://api.github.com/repos/dasherapp/dasher/events","assignees_url":"https://api.github.com/repos/dasherapp/dasher/assignees{/user}","branches_url":"https://api.github.com/repos/dasherapp/dasher/branches{/branch}","tags_url":"https://api.github.com/repos/dasherapp/dasher/tags","blobs_url":"https://api.github.com/repos/dasherapp/dasher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dasherapp/dasher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dasherapp/dasher/git/refs{/sha}","trees_url":"https://api.github.com/repos/dasherapp/dasher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dasherapp/dasher/statuses/{sha}","languages_url":"https://api.github.com/repos/dasherapp/dasher/languages","stargazers_url":"https://api.github.com/repos/dasherapp/dasher/stargazers","contributors_url":"https://api.github.com/repos/dasherapp/dasher/contributors","subscribers_url":"https://api.github.com/repos/dasherapp/dasher/subscribers","subscription_url":"https://api.github.com/repos/dasherapp/dasher/subscription","commits_url":"https://api.github.com/repos/dasherapp/dasher/commits{/sha}","git_commits_url":"https://api.github.com/repos/dasherapp/dasher/git/commits{/sha}","comments_url":"https://api.github.com/repos/dasherapp/dasher/comments{/number}","issue_comment_url":"https://api.github.com/repos/dasherapp/dasher/issues/comments{/number}","contents_url":"https://api.github.com/repos/dasherapp/dasher/contents/{+path}","compare_url":"https://api.github.com/repos/dasherapp/dasher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dasherapp/dasher/merges","archive_url":"https://api.github.com/repos/dasherapp/dasher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dasherapp/dasher/downloads","issues_url":"https://api.github.com/repos/dasherapp/dasher/issues{/number}","pulls_url":"https://api.github.com/repos/dasherapp/dasher/pulls{/number}","milestones_url":"https://api.github.com/repos/dasherapp/dasher/milestones{/number}","notifications_url":"https://api.github.com/repos/dasherapp/dasher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dasherapp/dasher/labels{/name}","releases_url":"https://api.github.com/repos/dasherapp/dasher/releases{/id}","deployments_url":"https://api.github.com/repos/dasherapp/dasher/deployments","created_at":"2018-04-14T22:54:26Z","updated_at":"2018-04-24T05:47:19Z","pushed_at":"2018-04-27T19:52:36Z","git_url":"git://github.com/dasherapp/dasher.git","ssh_url":"git@github.com:dasherapp/dasher.git","clone_url":"https://github.com/dasherapp/dasher.git","svn_url":"https://github.com/dasherapp/dasher","homepage":"","size":333,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"dasherapp:master","ref":"master","sha":"c663ae64d4c7fd7bbc189c153c0e260b1bf9f47e","user":{"login":"dasherapp","id":38197409,"avatar_url":"https://avatars3.githubusercontent.com/u/38197409?v=4","gravatar_id":"","url":"https://api.github.com/users/dasherapp","html_url":"https://github.com/dasherapp","followers_url":"https://api.github.com/users/dasherapp/followers","following_url":"https://api.github.com/users/dasherapp/following{/other_user}","gists_url":"https://api.github.com/users/dasherapp/gists{/gist_id}","starred_url":"https://api.github.com/users/dasherapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasherapp/subscriptions","organizations_url":"https://api.github.com/users/dasherapp/orgs","repos_url":"https://api.github.com/users/dasherapp/repos","events_url":"https://api.github.com/users/dasherapp/events{/privacy}","received_events_url":"https://api.github.com/users/dasherapp/received_events","type":"Organization","site_admin":false},"repo":{"id":129560260,"name":"dasher","full_name":"dasherapp/dasher","owner":{"login":"dasherapp","id":38197409,"avatar_url":"https://avatars3.githubusercontent.com/u/38197409?v=4","gravatar_id":"","url":"https://api.github.com/users/dasherapp","html_url":"https://github.com/dasherapp","followers_url":"https://api.github.com/users/dasherapp/followers","following_url":"https://api.github.com/users/dasherapp/following{/other_user}","gists_url":"https://api.github.com/users/dasherapp/gists{/gist_id}","starred_url":"https://api.github.com/users/dasherapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasherapp/subscriptions","organizations_url":"https://api.github.com/users/dasherapp/orgs","repos_url":"https://api.github.com/users/dasherapp/repos","events_url":"https://api.github.com/users/dasherapp/events{/privacy}","received_events_url":"https://api.github.com/users/dasherapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dasherapp/dasher","description":"Flexible project dashboards powered by GitHub queries","fork":false,"url":"https://api.github.com/repos/dasherapp/dasher","forks_url":"https://api.github.com/repos/dasherapp/dasher/forks","keys_url":"https://api.github.com/repos/dasherapp/dasher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dasherapp/dasher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dasherapp/dasher/teams","hooks_url":"https://api.github.com/repos/dasherapp/dasher/hooks","issue_events_url":"https://api.github.com/repos/dasherapp/dasher/issues/events{/number}","events_url":"https://api.github.com/repos/dasherapp/dasher/events","assignees_url":"https://api.github.com/repos/dasherapp/dasher/assignees{/user}","branches_url":"https://api.github.com/repos/dasherapp/dasher/branches{/branch}","tags_url":"https://api.github.com/repos/dasherapp/dasher/tags","blobs_url":"https://api.github.com/repos/dasherapp/dasher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dasherapp/dasher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dasherapp/dasher/git/refs{/sha}","trees_url":"https://api.github.com/repos/dasherapp/dasher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dasherapp/dasher/statuses/{sha}","languages_url":"https://api.github.com/repos/dasherapp/dasher/languages","stargazers_url":"https://api.github.com/repos/dasherapp/dasher/stargazers","contributors_url":"https://api.github.com/repos/dasherapp/dasher/contributors","subscribers_url":"https://api.github.com/repos/dasherapp/dasher/subscribers","subscription_url":"https://api.github.com/repos/dasherapp/dasher/subscription","commits_url":"https://api.github.com/repos/dasherapp/dasher/commits{/sha}","git_commits_url":"https://api.github.com/repos/dasherapp/dasher/git/commits{/sha}","comments_url":"https://api.github.com/repos/dasherapp/dasher/comments{/number}","issue_comment_url":"https://api.github.com/repos/dasherapp/dasher/issues/comments{/number}","contents_url":"https://api.github.com/repos/dasherapp/dasher/contents/{+path}","compare_url":"https://api.github.com/repos/dasherapp/dasher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dasherapp/dasher/merges","archive_url":"https://api.github.com/repos/dasherapp/dasher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dasherapp/dasher/downloads","issues_url":"https://api.github.com/repos/dasherapp/dasher/issues{/number}","pulls_url":"https://api.github.com/repos/dasherapp/dasher/pulls{/number}","milestones_url":"https://api.github.com/repos/dasherapp/dasher/milestones{/number}","notifications_url":"https://api.github.com/repos/dasherapp/dasher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dasherapp/dasher/labels{/name}","releases_url":"https://api.github.com/repos/dasherapp/dasher/releases{/id}","deployments_url":"https://api.github.com/repos/dasherapp/dasher/deployments","created_at":"2018-04-14T22:54:26Z","updated_at":"2018-04-24T05:47:19Z","pushed_at":"2018-04-27T19:52:36Z","git_url":"git://github.com/dasherapp/dasher.git","ssh_url":"git@github.com:dasherapp/dasher.git","clone_url":"https://github.com/dasherapp/dasher.git","svn_url":"https://github.com/dasherapp/dasher","homepage":"","size":333,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/30"},"html":{"href":"https://github.com/dasherapp/dasher/pull/30"},"issue":{"href":"https://api.github.com/repos/dasherapp/dasher/issues/30"},"comments":{"href":"https://api.github.com/repos/dasherapp/dasher/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dasherapp/dasher/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/dasherapp/dasher/statuses/8bd5944f01ba6cb252e08303736a517a94e20140"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"lexahall"}}