[JS, Wizard] Add react application template

^KT-41417 fixed
This commit is contained in:
Ilya Goncharov
2020-08-24 18:06:21 +03:00
parent 01064a4e46
commit d5340803bd
8 changed files with 43 additions and 2 deletions
@@ -78,5 +78,6 @@ public interface KotlinIcons {
Icon MAC_OS = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/wizard/macOS.svg");
Icon WINDOWS = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/wizard/windows.svg");
Icon NODE_JS = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/wizard/nodejs.svg");
Icon REACT_JS = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/wizard/react.svg");
}
}
@@ -85,6 +85,7 @@ private val ProjectTemplate.icon: Icon
FullStackWebApplicationProjectTemplate -> KotlinIcons.Wizard.WEB
NativeApplicationProjectTemplate -> KotlinIcons.Wizard.NATIVE
FrontendApplicationProjectTemplate -> KotlinIcons.Wizard.JS
ReactApplicationProjectTemplate -> KotlinIcons.Wizard.REACT_JS
MultiplatformMobileApplicationProjectTemplate -> KotlinIcons.Wizard.MULTIPLATFORM_MOBILE
MultiplatformMobileLibraryProjectTemplate -> KotlinIcons.Wizard.MULTIPLATFORM_MOBILE_LIBRARY
NodeJsApplicationProjectTemplate -> KotlinIcons.Wizard.NODE_JS
@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd" transform="translate(.7)">
<circle cx="7.333" cy="8" r="1.367" fill="#61DAFB"/>
<g stroke="#61DAFB">
<ellipse cx="7.333" cy="8" rx="7.333" ry="2.8"/>
<ellipse cx="7.333" cy="8" rx="7.333" ry="2.8" transform="rotate(60 7.333 8)"/>
<ellipse cx="7.333" cy="8" rx="7.333" ry="2.8" transform="rotate(120 7.333 8)"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 480 B

@@ -129,6 +129,9 @@ project.template.native.console.description=Application with Kotlin/Native that
project.template.browser.title=Browser Application
project.template.browser.description=A blank application targeting the browser
project.template.react.title=React Application
project.template.react.description=React application targeting Browser
project.template.nodejs.title=Node.JS Application
project.template.nodejs.description=A blank application targeting Node.js
@@ -77,6 +77,7 @@ sealed class ProjectTemplate : DisplayableSettingItem {
MultiplatformLibraryProjectTemplate,
NativeApplicationProjectTemplate,
FrontendApplicationProjectTemplate,
ReactApplicationProjectTemplate,
FullStackWebApplicationProjectTemplate,
NodeJsApplicationProjectTemplate
)
@@ -298,6 +299,31 @@ object FrontendApplicationProjectTemplate : ProjectTemplate() {
)
}
object ReactApplicationProjectTemplate : ProjectTemplate() {
override val title = KotlinNewProjectWizardBundle.message("project.template.react.title")
override val description = KotlinNewProjectWizardBundle.message("project.template.react.description")
override val id = "reactApplication"
@NonNls
override val suggestedProjectName = "myKotlinJsApplication"
override val projectKind = ProjectKind.Js
override val setsPluginSettings: List<SettingWithValue<*, *>>
get() = listOf(
KotlinPlugin.modules.reference withValue listOf(
Module(
"js",
BrowserJsSinglePlatformModuleConfigurator,
template = ReactJsClientTemplate(),
sourcesets = SourcesetType.ALL.map { type ->
Sourceset(type, dependencies = emptyList())
},
subModules = emptyList()
)
)
)
}
object MultiplatformMobileApplicationProjectTemplate : ProjectTemplate() {
override val title = KotlinNewProjectWizardBundle.message("project.template.mpp.mobile.title")
override val description = KotlinNewProjectWizardBundle.message("project.template.mpp.mobile.description")
@@ -52,7 +52,7 @@ class ReactJsClientTemplate : JsClientTemplate() {
buildList {
val hasKtorServNeighbourTarget = hasKtorServNeighbourTarget(module)
if (!hasKtorServNeighbourTarget) {
+(FileTemplateDescriptor("$id/index.html.vm") asResourceOf SourcesetType.main)
+(FileTemplateDescriptor("jsClient/index.html.vm") asResourceOf SourcesetType.main)
}
+(FileTemplateDescriptor("$id/reactClient.kt.vm", "client.kt".asPath()) asSrcOf SourcesetType.main)
+(FileTemplateDescriptor("$id/reactComponent.kt.vm", "welcome.kt".asPath()) asSrcOf SourcesetType.main)
@@ -57,7 +57,7 @@ class SimpleJsClientTemplate : JsClientTemplate() {
buildList {
val hasKtorServNeighbourTarget = hasKtorServNeighbourTarget(module)
if (!hasKtorServNeighbourTarget) {
+(FileTemplateDescriptor("$id/index.html.vm") asResourceOf SourcesetType.main)
+(FileTemplateDescriptor("jsClient/index.html.vm") asResourceOf SourcesetType.main)
}
if (useKotlinxHtml.reference.settingValue()) {
+(FileTemplateDescriptor("$id/client.kt.vm") asSrcOf SourcesetType.main)