Skip to content

Commit 5230a6d

Browse files
authored
Merge pull request #3 from faebeee/feature/settings
Add persistent settings for redux
2 parents 638f155 + f2ebc8e commit 5230a6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1366
-253
lines changed

CHANGE-NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- v0.4.0 Add Customisable templates. Improve a lot of code. Update doc
2+
- v0.2.1 Export enum for action types
13
- v0.2.1 Export enum for action types
24
- v0.2.0 Add `Add Redux Reducer` Action
35
- v0.1.0 Add `Add React Component` Action

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
# react-component-creator
22
- An Brainstorm Plugin to create a new react functional component with all additional files like
33
SCSS, Spec, Storybook.
4-
- Add Redux reducer module with actions, mutations, state and types
4+
- Add Redux reducer module with actions, mutations, state and types.
5+
- Add custom templates to match your coding style and your needs.
56

67

8+
![Create Reducer](./doc/settings.png "")
79
![Create component](./doc/create_component.gif "")
810
![Create Reducer](./doc/create_reducer.gif "")
911

1012
# Install
1113
Search for `React Component Creator` in the plugins settings. Or download the plugin from the [release site](https://github.com/faebeee/react-component-creator-plugin/releases)
1214

15+
# Custom Templates
16+
If you are not happy with the predefined templates, you can choose your
17+
own templates. The templates will be processed with mustache as templating.
18+
All variables can also be used for the filenames.
19+
20+
Following variables are available
21+
22+
23+
**Component**
24+
25+
| variable | Description |
26+
|---|---|
27+
| {{componentName}} | the inputted component name. Without any alterations |
28+
| {{componentCamelcaseName}} | Camelcased input `my-component` becomes `MyComponent` |
29+
30+
**Reducer**
31+
32+
| variable | Description |
33+
|---|---|
34+
| {{actionFunctionName}} | Name of the function inside the `actions.ts` file |
35+
| {{moduleName}} | Name of the folder |
36+
| {{mutationType}} | String which will be used as type of the dispatch/mutation |
37+
| {{moduleNamePascalCase}} | Pascalcased moduleName |
38+
| {{stateName}} | Name for the state. `my-component` becomes `MyComponentState` |
39+
| {{actionTypeName}} | Takes the input of `actionFunctionName` and capitalizes the first letter and appends `Action`. From `setData` becomes `SetDataAction` |
40+
| {{actionTypesEnumName}} | Name used for the action types enum. actionTypesEnumName is the namespace where all `mutationType` actions are kept |
41+
1342

1443
# Development
1544
Follow the [Setup Instructions](./doc/DEVELOPMENT.md)

doc/settings.png

53.3 KB
Loading

resources/META-INF/plugin.xml

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>com.faebeee.reactcomponentcreator</id>
33
<name>React Component Creator</name>
4-
<version>0.3.1</version>
4+
<version>0.4.0</version>
55
<vendor email="[email protected]" url="http://fabs.io">Fabio Gianini</vendor>
66

77
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
@@ -17,39 +17,95 @@
1717
<ul>
1818
<li>An Brainstorm Plugin to create a new react functional component with all additional files like
1919
SCSS, Spec, Storybook.</li>
20-
<li>Add Redux reducer module with actions, mutations, state and types</li>
20+
<li>Add Redux reducer module with actions, mutations, state and types.</li>
21+
<li>Add custom templates to match your coding style and your needs.</li>
2122
</ul>
23+
<h1><a href="#custom-templates" id="custom-templates">Custom Templates</a></h1>
24+
<p>If you are not happy with the predefined templates, you can choose your
25+
own templates. The templates will be processed with mustache as templating.
26+
All variables can also be used for the filenames.</p>
27+
<p>Following variables are available</p>
28+
<p><strong>Component</strong></p>
29+
<table>
30+
<thead>
31+
<tr><th> variable </th><th> Description </th></tr>
32+
</thead>
33+
<tbody>
34+
<tr><td> {{componentName}} </td><td> the inputted component name. Without any alterations </td></tr>
35+
<tr><td> {{componentCamelcaseName}} </td><td> Camelcased input <code>my-component</code> becomes <code>MyComponent</code> </td></tr>
36+
</tbody>
37+
</table>
38+
<p><strong>Reducer</strong></p>
39+
<table>
40+
<thead>
41+
<tr><th> variable </th><th> Description </th></tr>
42+
</thead>
43+
<tbody>
44+
<tr><td> {{actionFunctionName}} </td><td> Name of the function inside the <code>actions.ts</code> file </td></tr>
45+
<tr><td> {{moduleName}} </td><td> Name of the folder </td></tr>
46+
<tr><td> {{mutationType}} </td><td> String which will be used as type of the dispatch/mutation </td></tr>
47+
<tr><td> {{moduleNamePascalCase}} </td><td> Pascalcased moduleName </td></tr>
48+
<tr><td> {{stateName}} </td><td> Name for the state. <code>my-component</code> becomes <code>MyComponentState</code> </td></tr>
49+
<tr><td> {{actionTypeName}} </td><td> Takes the input of <code>actionFunctionName</code> and capitalizes the first letter and appends <code>Action</code>. From <code>setData</code> becomes <code>SetDataAction</code> </td></tr>
50+
<tr><td> {{actionTypesEnumName}} </td><td> Name used for the action types enum. actionTypesEnumName is the namespace where all <code>mutationType</code> actions are kept </td></tr>
51+
</tbody>
52+
</table>
2253
]]>
2354
</description>
2455

2556
<change-notes>
2657
<![CDATA[
2758
<ul>
28-
<li>v0.3.1 Export enum for action types</li>
29-
<li>v0.3.0 Add <code>Add Redux Reducer</code> Action</li>
30-
<li>v0.2.0 Update UI & improve code</li>
59+
<li>v0.4.0 Add Customisable templates. Improve a lot of code. Update doc</li>
60+
<li>v0.2.1 Export enum for action types</li>
61+
<li>v0.2.1 Export enum for action types</li>
62+
<li>v0.2.0 Add <code>Add Redux Reducer</code> Action</li>
3163
<li>v0.1.0 Add <code>Add React Component</code> Action</li>
3264
</ul>
3365
]]>
3466
</change-notes>
3567

3668

3769
<extensions defaultExtensionNs="com.intellij">
38-
<!-- Add your extensions here -->
70+
<projectConfigurable
71+
instance="fabs.component.settings.ComponentSettings"
72+
id="rcc.settings"
73+
displayName="React Component Creator"
74+
nonDefaultProject="true"/>
75+
76+
<projectConfigurable
77+
instance="fabs.reducer.settings.ReducerSettings"
78+
id="rcc.settings.redux"
79+
displayName="Redux"
80+
parentId="rcc.settings"
81+
nonDefaultProject="true"/>
82+
83+
<projectConfigurable
84+
instance="fabs.component.settings.ComponentSettings"
85+
id="rcc.settings.component"
86+
displayName="Component"
87+
parentId="rcc.settings"
88+
nonDefaultProject="true"/>
89+
90+
<projectService serviceInterface="fabs.reducer.data.ReducerSettingsState"
91+
serviceImplementation="fabs.reducer.data.ReducerSettingsState"/>
92+
93+
<projectService serviceInterface="fabs.component.data.ComponentSettingsState"
94+
serviceImplementation="fabs.component.data.ComponentSettingsState"/>
3995
</extensions>
4096

4197
<actions>
4298
<group description="React" id="React">
4399
<separator/>
44100
<action id="ReactComponent.ComponentCreatorAction"
45-
class="fabs.component.ComponentCreatorAction"
101+
class="fabs.component.action.ComponentCreatorAction"
46102
icon="/icons/component.png"
47103
text="React component"
48104
description="create new react component">
49105
</action>
50106

51107
<action id="ReactComponent.ReducerCreatorAction"
52-
class="fabs.reducer.ReducerCreatorAction"
108+
class="fabs.reducer.action.ReducerCreatorAction"
53109
icon="/icons/store.png"
54110
text="Redux reducer"
55111
description="create new redux reducer">

resources/templates/component/_component.scss.mustache renamed to resources/templates/component/_{{componentName}}.scss.mustache

File renamed without changes.

resources/templates/component/component.md.mustache renamed to resources/templates/component/{{componentName}}.md.mustache

File renamed without changes.

resources/templates/component/component.spec.tsx.mustache renamed to resources/templates/component/{{componentName}}.spec.tsx.mustache

File renamed without changes.

resources/templates/component/component.story.tsx.mustache renamed to resources/templates/component/{{componentName}}.story.tsx.mustache

File renamed without changes.

resources/templates/component/component.tsx.mustache renamed to resources/templates/component/{{componentName}}.tsx.mustache

File renamed without changes.

resources/templates/reducer/actions.ts.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { Dispatch } from 'redux';
22
import { {{ actionTypesEnumName }} } from './action-types';
33
import { {{ actionTypeName }} } from './types';
44

5-
export const {{ actionFunctionName }} = () => async (dispatch: Dispatch<{{ actionTypesEnumName }}.{{ actionTypeName }}>) => {
6-
dispatch({ type: {{ mutationType }} , data });
5+
export const {{ actionFunctionName }} = (data: any) => (dispatch: Dispatch<{{ actionTypeName }}>) => {
6+
dispatch({ type: {{ actionTypesEnumName }}.{{ mutationType }}, data });
77
};

0 commit comments

Comments
 (0)