Input requested: Generated SVG icon components #490
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hallo! We've been talking some about re-implementing how our icon component(s) work. The current goal is standalone icon components (e.g. one component for each icon).
This PR demonstrates one auto-generating approach which seems to be working fine except for a casing conflict between React and preact for SVG element attribute names. React camel-cases them; preact does not. The generating utility I used here (SVGR) is popping out React components and so the attribute casing is currently problematic.
I'm looking for input here on:
Casing-fix possibilities
preact-compat
. It works. But it's not what we want to do, and downstream projects would have to usepreact-compat
, too.ignore-existing
option when generating icons so that these changes don't get overwritten). @robertknight has expressed a preference for a script-able approach, however.hast-util-to-babel-ast
which has a set of mappings for attributes.Trying out this branch.
If you check out this branch and run
make dev
and visit http://localhost:4001/components-icons, you'll see something like:This is mostly right but the line weights, etc., are wrong because of the casing issue.
Turning on
preact-compat
gives this result (which is correct):