React Octicons!#222
Conversation
| const given = width ? 'width' : 'height' | ||
| const computed = given === 'width' ? 'height' : 'width' | ||
| attrs[given] = width || height || sizeMap[size] || size | ||
| attrs[computed] = attrs[given] * (dims[computed] / dims[given]) |
There was a problem hiding this comment.
If both the width and height aren't provided, we compute the width or the height — depending on whether they provide width, height, or size (which can be either a number or a string that's mapped via sizeMap).
There was a problem hiding this comment.
Note: the parens on that last line above are a linting requirement. * and / have the same operator precedence, so I think the rule that wants one expression grouped exists to help us be more explicit about what it's doing.
| height: PropTypes.number, | ||
| icon: PropTypes.func, | ||
| size: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(Object.keys(sizeMap))]), | ||
| verticalAlign: PropTypes.oneOf(['middle', 'text-bottom', 'text-top', 'top']), |
There was a problem hiding this comment.
Is there a good reason not to allow bottom here?
| "license": "MIT", | ||
| "main": "index.js", | ||
| "main": "build/index.js", | ||
| "module": "index.js", |
There was a problem hiding this comment.
This was wrong for me to include. I removed it in 02a007a.
| "presets": ["env", "stage-0", "react"], | ||
| "env": { | ||
| "production": { | ||
| "presets": ["next/babel"] |
There was a problem hiding this comment.
This is used when we call NODE_ENV=production next in the start run-script.
| @@ -0,0 +1 @@ | |||
| src/icons/*.js | |||
There was a problem hiding this comment.
Don't lint the generated files. 🙈
| @@ -0,0 +1 @@ | |||
| 8 | |||
There was a problem hiding this comment.
This is for development. I've added the equivalent to engines.node in the package.json as well.
This is a rehash of #196 introducing a React component API that looks like this:
With credit to @hiendv for the inspiration in #196 (comment) 🍻
Note that there's one wild assumption in the generated per-icon components here, and it's that the SVG from the
octiconspackage is valid XML, which is what allows us to use it in JSX without munging it. I've checked the generated icon component JS into git so that we can look at it without the module having to publish.TODO
README.mdwith new API (see rendered)