{"action":"created","comment":{"url":"https://api.github.com/repos/FormidableLabs/radium/pulls/comments/24947715","id":24947715,"diff_hunk":"@@ -0,0 +1,48 @@\n+var React = require('react');\n+var hyphenateStyleName = require('react/lib/hyphenateStyleName');\n+var forEach = require('lodash.foreach');\n+var reduce = require('lodash.reduce');\n+\n+function buildCssString (selector, rules) {\n+  // TODO: Better error checking for rules object\n+  if (!selector || !rules) {\n+    return;\n+  }\n+\n+  var cssString = selector + \"{\";\n+\n+  // Turn rules into css properties\n+  cssString += reduce(rules, function (s, val, styleName) {\n+    return s + hyphenateStyleName(styleName) + \":\" + val + \";\"\n+  }, \"\");\n+\n+  // Close selector\n+  cssString += \"}\";\n+\n+  return cssString;\n+}\n+\n+var Style = React.createClass({\n+  render: function () {\n+    var styles;\n+\n+    // Throw error if someone passes in valid children that isn't an object\n+    if (this.props.children && typeof this.props.children !== \"object\") {\n+      throw new Error(\"Style tag requires an object for 'props.children'\");\n+    }\n+\n+    forEach(this.props.children, function (rules, selector) {\n+      styles = buildCssString(selector, rules);","path":"modules/components/style.jsx","position":35,"original_position":35,"commit_id":"6a94ff1a0cdd4fd478dea8483fc108b18a1cd0c4","original_commit_id":"6a94ff1a0cdd4fd478dea8483fc108b18a1cd0c4","user":{"login":"alexlande","id":808159,"avatar_url":"https://avatars.githubusercontent.com/u/808159?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlande","html_url":"https://github.com/alexlande","followers_url":"https://api.github.com/users/alexlande/followers","following_url":"https://api.github.com/users/alexlande/following{/other_user}","gists_url":"https://api.github.com/users/alexlande/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlande/subscriptions","organizations_url":"https://api.github.com/users/alexlande/orgs","repos_url":"https://api.github.com/users/alexlande/repos","events_url":"https://api.github.com/users/alexlande/events{/privacy}","received_events_url":"https://api.github.com/users/alexlande/received_events","type":"User","site_admin":false},"body":"Do we want a reduce here? This replaces `styles` with each iteration, no? Doesn't support multiple rulesets.","created_at":"2015-02-18T22:31:03Z","updated_at":"2015-02-18T22:31:03Z","html_url":"https://github.com/FormidableLabs/radium/pull/29#discussion_r24947715","pull_request_url":"https://api.github.com/repos/FormidableLabs/radium/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/comments/24947715"},"html":{"href":"https://github.com/FormidableLabs/radium/pull/29#discussion_r24947715"},"pull_request":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/FormidableLabs/radium/pulls/29","id":29495684,"html_url":"https://github.com/FormidableLabs/radium/pull/29","diff_url":"https://github.com/FormidableLabs/radium/pull/29.diff","patch_url":"https://github.com/FormidableLabs/radium/pull/29.patch","issue_url":"https://api.github.com/repos/FormidableLabs/radium/issues/29","number":29,"state":"open","locked":false,"title":"Style component","user":{"login":"rgerstenberger","id":710017,"avatar_url":"https://avatars.githubusercontent.com/u/710017?v=3","gravatar_id":"","url":"https://api.github.com/users/rgerstenberger","html_url":"https://github.com/rgerstenberger","followers_url":"https://api.github.com/users/rgerstenberger/followers","following_url":"https://api.github.com/users/rgerstenberger/following{/other_user}","gists_url":"https://api.github.com/users/rgerstenberger/gists{/gist_id}","starred_url":"https://api.github.com/users/rgerstenberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgerstenberger/subscriptions","organizations_url":"https://api.github.com/users/rgerstenberger/orgs","repos_url":"https://api.github.com/users/rgerstenberger/repos","events_url":"https://api.github.com/users/rgerstenberger/events{/privacy}","received_events_url":"https://api.github.com/users/rgerstenberger/received_events","type":"User","site_admin":false},"body":"This adds a style component that can be used with the following syntax:\r\n\r\n`<Style selector=\"h2\" styles={myStyles} />`\r\n\r\nThis component is very slow. Considering the main use case is for user generated content, I suggest we attempt to speed it up. Possibly with something like `insertRule` http://davidwalsh.name/add-rules-stylesheets. Really, all uses of this component should update a global stylesheet.\r\n\r\nAlso, I'm not happy with the API. If the main use case is unknown html on the page then there's probably more than a few selectors needed. I considered taking in an object like: \r\n```\r\n{\r\n \".myClass\": { background: \"#fff\"},\r\n \".otherClass: { background: \"#000\"}\r\n}\r\n```\r\n\r\nBut that logic could be very slow and the objects being passed in will be hard to validate. It's also might confuse the other radium style objects, so I opted to keep them similar. \r\n\r\nLastly, we should probably be reusing the existing logic for building styles so that someone could pass in your average radium style object. \r\n\r\nThis PR is not ready for primetime but I wanted to submit it to get clarity on which direction to pursue.\r\n\r\n/cc @alexlande, @aykayen, @colinmegill ","created_at":"2015-02-18T01:56:09Z","updated_at":"2015-02-18T22:31:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79f05c59241aeb1cc09357d6bd8952a7867abb88","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FormidableLabs/radium/pulls/29/commits","review_comments_url":"https://api.github.com/repos/FormidableLabs/radium/pulls/29/comments","review_comment_url":"https://api.github.com/repos/FormidableLabs/radium/pulls/comments/{number}","comments_url":"https://api.github.com/repos/FormidableLabs/radium/issues/29/comments","statuses_url":"https://api.github.com/repos/FormidableLabs/radium/statuses/6a94ff1a0cdd4fd478dea8483fc108b18a1cd0c4","head":{"label":"FormidableLabs:feature-style-element","ref":"feature-style-element","sha":"6a94ff1a0cdd4fd478dea8483fc108b18a1cd0c4","user":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":29031987,"name":"radium","full_name":"FormidableLabs/radium","owner":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FormidableLabs/radium","description":"A toolchain for React component styling.","fork":false,"url":"https://api.github.com/repos/FormidableLabs/radium","forks_url":"https://api.github.com/repos/FormidableLabs/radium/forks","keys_url":"https://api.github.com/repos/FormidableLabs/radium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FormidableLabs/radium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FormidableLabs/radium/teams","hooks_url":"https://api.github.com/repos/FormidableLabs/radium/hooks","issue_events_url":"https://api.github.com/repos/FormidableLabs/radium/issues/events{/number}","events_url":"https://api.github.com/repos/FormidableLabs/radium/events","assignees_url":"https://api.github.com/repos/FormidableLabs/radium/assignees{/user}","branches_url":"https://api.github.com/repos/FormidableLabs/radium/branches{/branch}","tags_url":"https://api.github.com/repos/FormidableLabs/radium/tags","blobs_url":"https://api.github.com/repos/FormidableLabs/radium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FormidableLabs/radium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FormidableLabs/radium/git/refs{/sha}","trees_url":"https://api.github.com/repos/FormidableLabs/radium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FormidableLabs/radium/statuses/{sha}","languages_url":"https://api.github.com/repos/FormidableLabs/radium/languages","stargazers_url":"https://api.github.com/repos/FormidableLabs/radium/stargazers","contributors_url":"https://api.github.com/repos/FormidableLabs/radium/contributors","subscribers_url":"https://api.github.com/repos/FormidableLabs/radium/subscribers","subscription_url":"https://api.github.com/repos/FormidableLabs/radium/subscription","commits_url":"https://api.github.com/repos/FormidableLabs/radium/commits{/sha}","git_commits_url":"https://api.github.com/repos/FormidableLabs/radium/git/commits{/sha}","comments_url":"https://api.github.com/repos/FormidableLabs/radium/comments{/number}","issue_comment_url":"https://api.github.com/repos/FormidableLabs/radium/issues/comments/{number}","contents_url":"https://api.github.com/repos/FormidableLabs/radium/contents/{+path}","compare_url":"https://api.github.com/repos/FormidableLabs/radium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FormidableLabs/radium/merges","archive_url":"https://api.github.com/repos/FormidableLabs/radium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FormidableLabs/radium/downloads","issues_url":"https://api.github.com/repos/FormidableLabs/radium/issues{/number}","pulls_url":"https://api.github.com/repos/FormidableLabs/radium/pulls{/number}","milestones_url":"https://api.github.com/repos/FormidableLabs/radium/milestones{/number}","notifications_url":"https://api.github.com/repos/FormidableLabs/radium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FormidableLabs/radium/labels{/name}","releases_url":"https://api.github.com/repos/FormidableLabs/radium/releases{/id}","created_at":"2015-01-09T19:35:59Z","updated_at":"2015-02-18T17:39:08Z","pushed_at":"2015-02-18T20:07:46Z","git_url":"git://github.com/FormidableLabs/radium.git","ssh_url":"git@github.com:FormidableLabs/radium.git","clone_url":"https://github.com/FormidableLabs/radium.git","svn_url":"https://github.com/FormidableLabs/radium","homepage":"","size":452,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"FormidableLabs:master","ref":"master","sha":"5413069ba9679f8ed6bff6bc7ea309e4f4ad4e81","user":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":29031987,"name":"radium","full_name":"FormidableLabs/radium","owner":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FormidableLabs/radium","description":"A toolchain for React component styling.","fork":false,"url":"https://api.github.com/repos/FormidableLabs/radium","forks_url":"https://api.github.com/repos/FormidableLabs/radium/forks","keys_url":"https://api.github.com/repos/FormidableLabs/radium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FormidableLabs/radium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FormidableLabs/radium/teams","hooks_url":"https://api.github.com/repos/FormidableLabs/radium/hooks","issue_events_url":"https://api.github.com/repos/FormidableLabs/radium/issues/events{/number}","events_url":"https://api.github.com/repos/FormidableLabs/radium/events","assignees_url":"https://api.github.com/repos/FormidableLabs/radium/assignees{/user}","branches_url":"https://api.github.com/repos/FormidableLabs/radium/branches{/branch}","tags_url":"https://api.github.com/repos/FormidableLabs/radium/tags","blobs_url":"https://api.github.com/repos/FormidableLabs/radium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FormidableLabs/radium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FormidableLabs/radium/git/refs{/sha}","trees_url":"https://api.github.com/repos/FormidableLabs/radium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FormidableLabs/radium/statuses/{sha}","languages_url":"https://api.github.com/repos/FormidableLabs/radium/languages","stargazers_url":"https://api.github.com/repos/FormidableLabs/radium/stargazers","contributors_url":"https://api.github.com/repos/FormidableLabs/radium/contributors","subscribers_url":"https://api.github.com/repos/FormidableLabs/radium/subscribers","subscription_url":"https://api.github.com/repos/FormidableLabs/radium/subscription","commits_url":"https://api.github.com/repos/FormidableLabs/radium/commits{/sha}","git_commits_url":"https://api.github.com/repos/FormidableLabs/radium/git/commits{/sha}","comments_url":"https://api.github.com/repos/FormidableLabs/radium/comments{/number}","issue_comment_url":"https://api.github.com/repos/FormidableLabs/radium/issues/comments/{number}","contents_url":"https://api.github.com/repos/FormidableLabs/radium/contents/{+path}","compare_url":"https://api.github.com/repos/FormidableLabs/radium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FormidableLabs/radium/merges","archive_url":"https://api.github.com/repos/FormidableLabs/radium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FormidableLabs/radium/downloads","issues_url":"https://api.github.com/repos/FormidableLabs/radium/issues{/number}","pulls_url":"https://api.github.com/repos/FormidableLabs/radium/pulls{/number}","milestones_url":"https://api.github.com/repos/FormidableLabs/radium/milestones{/number}","notifications_url":"https://api.github.com/repos/FormidableLabs/radium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FormidableLabs/radium/labels{/name}","releases_url":"https://api.github.com/repos/FormidableLabs/radium/releases{/id}","created_at":"2015-01-09T19:35:59Z","updated_at":"2015-02-18T17:39:08Z","pushed_at":"2015-02-18T20:07:46Z","git_url":"git://github.com/FormidableLabs/radium.git","ssh_url":"git@github.com:FormidableLabs/radium.git","clone_url":"https://github.com/FormidableLabs/radium.git","svn_url":"https://github.com/FormidableLabs/radium","homepage":"","size":452,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/29"},"html":{"href":"https://github.com/FormidableLabs/radium/pull/29"},"issue":{"href":"https://api.github.com/repos/FormidableLabs/radium/issues/29"},"comments":{"href":"https://api.github.com/repos/FormidableLabs/radium/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/FormidableLabs/radium/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/FormidableLabs/radium/statuses/6a94ff1a0cdd4fd478dea8483fc108b18a1cd0c4"}}}}