feat: Custom Component Files to master #40
Merged
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.
Custom component files
GRC comes with corresponding built-in files for a given component if you need them (i.e.,
withStyle
,withTest
,withStory
, andwithLazy
).What if you wanted to add custom files of your own?
For example, let's say you wanted to add an
index.js
file for each component, so you don't have to add the additional component name with each import (i.e.,import Box from './components/Box'
instead ofimport Box from './components/Box/Box'
).Or maybe you need an additional style file for your component stories.
You can do so by editing your generate-react-cli.json config file like so.
In this case, we added a
withIndex
&withStoryStyle
to thecomponent.default
. Note: You can add custom files to any of your custom component types.You should also see that we added
index
andstoryStyle
to ourcustomTemplates
object. That's because custom files require custom templates. Otherwise, you will get an error when you generate a component.Also, we used the
TemplateName
keyword for thestoryStyle
custom file. GRC will generate this corresponding file and replaceTemplateName
with the component name.This PR should close #21, #22, #27, #34, #36, #37, #39