Skip to content

Commit bf951b3

Browse files
committed
Checkboxes can be configured in the section
1 parent 1d48e8c commit bf951b3

File tree

8 files changed

+186
-59
lines changed

8 files changed

+186
-59
lines changed

CHANGE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- v0.5.0 Checkboxes checked by default can be configured in the settings
12
- v0.4.0 Add Customisable templates. Improve a lot of code. Update doc
23
- v0.2.1 Export enum for action types
34
- v0.2.1 Export enum for action types

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ SCSS, Spec, Storybook.
1111
- Add custom templates to match your coding style and your needs.
1212

1313

14-
![Create Reducer](./doc/settings.png "")
15-
![Create component](./doc/create_component.gif "")
16-
![Create Reducer](./doc/create_reducer.gif "")
14+
![Settings](https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/settings.png?raw=true "")
15+
![Create component](https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/create_component.gif?raw=true "")
16+
![Create Reducer](https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/create_reducer.gif?raw=true "")
1717

1818
# Install
1919
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)

resources/META-INF/plugin.xml

Lines changed: 57 additions & 44 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.4.0</version>
4+
<version>0.5.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 -->
@@ -14,54 +14,67 @@
1414
<description>
1515
<![CDATA[
1616
<h1><a href="#react-component-creator" id="react-component-creator">react-component-creator</a></h1>
17-
<ul>
18-
<li>An Brainstorm Plugin to create a new react functional component with all additional files like
19-
SCSS, Spec, Storybook.</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>
22-
</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>
17+
<p><img src="https://img.shields.io/jetbrains/plugin/d/13965-react-component-creator?style=for-the-badge" alt="Downloads" />
18+
<img src="https://img.shields.io/jetbrains/plugin/v/13965-react-component-creator?style=for-the-badge" alt="Version" />
19+
<img src="https://img.shields.io/jetbrains/plugin/r/rating/13965-react-component-creator?style=for-the-badge" alt="Rating" /></p>
20+
<ul>
21+
<li>An Brainstorm Plugin to create a new react functional component with all additional files like
22+
SCSS, Spec, Storybook.</li>
23+
<li>Add Redux reducer module with actions, mutations, state and types.</li>
24+
<li>Add custom templates to match your coding style and your needs.</li>
25+
</ul>
26+
<p><img src="https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/settings.png?raw=true" alt="Settings" title="" />
27+
<img src="https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/create_component.gif?raw=true" alt="Create component" title="" />
28+
<img src="https://github.com/faebeee/react-component-creator-plugin/blob/master/doc/create_reducer.gif?raw=true" alt="Create Reducer" title="" /></p>
29+
<h1><a href="#install" id="install">Install</a></h1>
30+
<p>Search for <code>React Component Creator</code> in the plugins settings. Or download the plugin from the <a href="https://github.com/faebeee/react-component-creator-plugin/releases">release site</a></p>
31+
<h1><a href="#custom-templates" id="custom-templates">Custom Templates</a></h1>
32+
<p>If you are not happy with the predefined templates, you can choose your
33+
own templates. The templates will be processed with mustache as templating.
34+
All variables can also be used for the filenames.</p>
35+
<p>Following variables are available</p>
36+
<p><strong>Component</strong></p>
37+
<table>
38+
<thead>
39+
<tr><th> variable </th><th> Description </th></tr>
40+
</thead>
41+
<tbody>
42+
<tr><td> {{componentName}} </td><td> the inputted component name. Without any alterations </td></tr>
43+
<tr><td> {{componentCamelcaseName}} </td><td> Camelcased input <code>my-component</code> becomes <code>MyComponent</code> </td></tr>
44+
</tbody>
45+
</table>
46+
<p><strong>Reducer</strong></p>
47+
<table>
48+
<thead>
49+
<tr><th> variable </th><th> Description </th></tr>
50+
</thead>
51+
<tbody>
52+
<tr><td> {{actionFunctionName}} </td><td> Name of the function inside the <code>actions.ts</code> file </td></tr>
53+
<tr><td> {{moduleName}} </td><td> Name of the folder </td></tr>
54+
<tr><td> {{mutationType}} </td><td> String which will be used as type of the dispatch/mutation </td></tr>
55+
<tr><td> {{moduleNamePascalCase}} </td><td> Pascalcased moduleName </td></tr>
56+
<tr><td> {{stateName}} </td><td> Name for the state. <code>my-component</code> becomes <code>MyComponentState</code> </td></tr>
57+
<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>
58+
<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>
59+
</tbody>
60+
</table>
61+
<h1><a href="#development" id="development">Development</a></h1>
62+
<p>Follow the <a href="./doc/DEVELOPMENT.md">Setup Instructions</a></p>
63+
<h1><a href="#icons" id="icons">Icons</a></h1>
64+
<p>Icons provided by <a href="https://www.iconfinder.com/justicon">https://www.iconfinder.com/justicon</a> via <a href="https://www.iconfinder.com">https://www.iconfinder.com</a></p>
5365
]]>
5466
</description>
5567

5668
<change-notes>
5769
<![CDATA[
58-
<ul>
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>
63-
<li>v0.1.0 Add <code>Add React Component</code> Action</li>
64-
</ul>
70+
<ul>
71+
<li>v0.5.0 Checkboxes checked by default can be configured in the settings</li>
72+
<li>v0.4.0 Add Customisable templates. Improve a lot of code. Update doc</li>
73+
<li>v0.2.1 Export enum for action types</li>
74+
<li>v0.2.1 Export enum for action types</li>
75+
<li>v0.2.0 Add <code>Add Redux Reducer</code> Action</li>
76+
<li>v0.1.0 Add <code>Add React Component</code> Action</li>
77+
</ul>
6578
]]>
6679
</change-notes>
6780

src/fabs/react/component/data/ComponentCreateOptions.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ public class ComponentCreateOptions extends AbstractOptions {
2828
private String storyTemplateFile = defaultStoryTemplateFile;
2929
private String markdownTemplateFile = defaultMarkdownTemplateFile;
3030

31+
private final String MD_CHECKBOX_KEY = "MD_CHECKBOX_KEY";
32+
private final String STORY_CHECKBOX_KEY = "STORY_CHECKBOX_KEY";
33+
private final String SCSS_CHECKBOX_KEY = "SCSS_CHECKBOX_KEY";
34+
private final String SPEC_CHECKBOX_KEY = "SPEC_CHECKBOX_KEY";
35+
36+
private boolean isCreateStorybookDefaultChecked = false;
37+
private boolean isCreateSpecDefaultChecked = false;
38+
private boolean isCreateScssDefaultChecked = false;
39+
private boolean isCreateMarkdownDefaultChecked = false;
40+
3141
private Boolean isCreateSassFile = false;
3242
private Boolean isCreateSpecFile = false;
3343
private Boolean isCreateStoryFile = false;
@@ -43,6 +53,11 @@ public Element serialize() {
4353
element.setAttribute(SPEC_TEMPLATE_KEY, specTemplateFile);
4454
element.setAttribute(STORY_TEMPLATE_KEY, storyTemplateFile);
4555
element.setAttribute(MD_TEMPLATE_KEY, markdownTemplateFile);
56+
57+
element.setAttribute(MD_CHECKBOX_KEY, Boolean.toString(isCreateMarkdownDefaultChecked));
58+
element.setAttribute(STORY_CHECKBOX_KEY, Boolean.toString(isCreateStorybookDefaultChecked));
59+
element.setAttribute(SCSS_CHECKBOX_KEY, Boolean.toString(isCreateScssDefaultChecked));
60+
element.setAttribute(SPEC_CHECKBOX_KEY, Boolean.toString(isCreateSpecDefaultChecked));
4661
return element;
4762
}
4863

@@ -53,6 +68,11 @@ public void deserialize(Element element) {
5368
setSpecTemplateFile(element.getAttributeValue(SPEC_TEMPLATE_KEY));
5469
setStoryTemplateFile(element.getAttributeValue(STORY_TEMPLATE_KEY));
5570
setMarkdownTemplateFile(element.getAttributeValue(MD_TEMPLATE_KEY));
71+
72+
setCreateMarkdownDefaultChecked(Boolean.valueOf(element.getAttributeValue(MD_TEMPLATE_KEY)));
73+
setCreateStorybookDefaultChecked(Boolean.valueOf(element.getAttributeValue(STORY_CHECKBOX_KEY)));
74+
setCreateScssDefaultChecked(Boolean.valueOf(element.getAttributeValue(SCSS_CHECKBOX_KEY)));
75+
setCreateSpecDefaultChecked(Boolean.valueOf(element.getAttributeValue(SPEC_CHECKBOX_KEY)));
5676
}
5777

5878
@Override
@@ -192,12 +212,48 @@ public String getMarkdownTemplateFile() {
192212
return markdownTemplateFile;
193213
}
194214

215+
public boolean isCreateStorybookDefaultChecked() {
216+
return isCreateStorybookDefaultChecked;
217+
}
218+
219+
public boolean isCreateSpecDefaultChecked() {
220+
return isCreateSpecDefaultChecked;
221+
}
222+
223+
public boolean isCreateScssDefaultChecked() {
224+
return isCreateScssDefaultChecked;
225+
}
226+
227+
public boolean isCreateMarkdownDefaultChecked() {
228+
return isCreateMarkdownDefaultChecked;
229+
}
230+
231+
public void setCreateStorybookDefaultChecked(boolean createStorybookDefaultChecked) {
232+
isCreateStorybookDefaultChecked = createStorybookDefaultChecked;
233+
}
234+
235+
public void setCreateSpecDefaultChecked(boolean createSpecDefaultChecked) {
236+
isCreateSpecDefaultChecked = createSpecDefaultChecked;
237+
}
238+
239+
public void setCreateScssDefaultChecked(boolean createScssDefaultChecked) {
240+
isCreateScssDefaultChecked = createScssDefaultChecked;
241+
}
242+
243+
public void setCreateMarkdownDefaultChecked(boolean createMarkdownDefaultChecked) {
244+
isCreateMarkdownDefaultChecked = createMarkdownDefaultChecked;
245+
}
246+
195247
public boolean equals(ComponentCreateOptions options) {
196248
return (options.getComponentTemplateFile().equals(componentTemplateFile)
197249
&& options.getStoryTemplateFile().equals(storyTemplateFile)
198250
&& options.getSpecTemplateFile().equals(specTemplateFile)
199251
&& options.getSassTemplateFile().equals(sassTemplateFile)
200252
&& options.getMarkdownTemplateFile().equals(markdownTemplateFile)
253+
&& options.isCreateMarkdownDefaultChecked() == isCreateMarkdownDefaultChecked
254+
&& options.isCreateScssDefaultChecked() == isCreateScssDefaultChecked
255+
&& options.isCreateSpecDefaultChecked() == isCreateSpecDefaultChecked
256+
&& options.isCreateStorybookDefaultChecked() == isCreateStorybookDefaultChecked
201257
);
202258
}
203259
}

src/fabs/react/component/ui/CreateComponentForm.form

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="436" height="315"/>
6+
<xy x="48" y="54" width="436" height="319"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -55,7 +55,7 @@
5555
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
5656
</constraints>
5757
<properties>
58-
<selected value="true"/>
58+
<selected value="false"/>
5959
<text value="Storybook"/>
6060
</properties>
6161
</component>
@@ -74,7 +74,7 @@
7474
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
7575
</constraints>
7676
<properties>
77-
<selected value="true"/>
77+
<selected value="false"/>
7878
<text value="Unit Test"/>
7979
</properties>
8080
</component>
@@ -93,7 +93,7 @@
9393
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9494
</constraints>
9595
<properties>
96-
<selected value="true"/>
96+
<selected value="false"/>
9797
<text value="SCSS"/>
9898
</properties>
9999
</component>
@@ -112,7 +112,7 @@
112112
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
113113
</constraints>
114114
<properties>
115-
<selected value="true"/>
115+
<selected value="false"/>
116116
<text value="Markdown"/>
117117
</properties>
118118
</component>

src/fabs/react/component/ui/CreateComponentForm.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public void windowClosing(WindowEvent e) {
3333

3434
// call onCancel() on ESCAPE
3535
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
36+
37+
storybookCheckBox.setSelected(options.isCreateStorybookDefaultChecked());
38+
unitTestCheckBox.setSelected(options.isCreateSpecDefaultChecked());
39+
SCSSCheckBox.setSelected(options.isCreateScssDefaultChecked());
40+
markdownCheckBox.setSelected(options.isCreateMarkdownDefaultChecked());
3641
}
3742

3843
@Override

src/fabs/react/component/ui/SettingsForm.form

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="fabs.react.component.ui.SettingsForm">
3-
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
66
<xy x="20" y="20" width="508" height="400"/>
@@ -180,9 +180,51 @@
180180
</grid>
181181
<vspacer id="80939">
182182
<constraints>
183-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
183+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
184184
</constraints>
185185
</vspacer>
186+
<grid id="5ca26" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
187+
<margin top="0" left="0" bottom="0" right="0"/>
188+
<constraints>
189+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
190+
</constraints>
191+
<properties/>
192+
<border type="none" title="Default checkboxes"/>
193+
<children>
194+
<component id="8e2f5" class="javax.swing.JCheckBox" binding="storybookCheckbox">
195+
<constraints>
196+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
197+
</constraints>
198+
<properties>
199+
<text value="Storybook"/>
200+
</properties>
201+
</component>
202+
<component id="c5cc5" class="javax.swing.JCheckBox" binding="specCheckBox">
203+
<constraints>
204+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
205+
</constraints>
206+
<properties>
207+
<text value="Unit Test"/>
208+
</properties>
209+
</component>
210+
<component id="2d907" class="javax.swing.JCheckBox" binding="SCSSCheckBox" default-binding="true">
211+
<constraints>
212+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
213+
</constraints>
214+
<properties>
215+
<text value="SCSS"/>
216+
</properties>
217+
</component>
218+
<component id="75231" class="javax.swing.JCheckBox" binding="mdCheckBox">
219+
<constraints>
220+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
221+
</constraints>
222+
<properties>
223+
<text value="Markdown"/>
224+
</properties>
225+
</component>
226+
</children>
227+
</grid>
186228
</children>
187229
</grid>
188230
</form>

0 commit comments

Comments
 (0)