All Projects → nosix → Vue Kotlin

nosix / Vue Kotlin

Licence: apache-2.0
Libraries and tools supporting the use of Vue.js in Kotlin.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Vue Kotlin

Vue Ba
vue 百度统计埋点插件
Stars: ✭ 155 (-4.32%)
Mutual labels:  vuejs2
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (-3.09%)
Mutual labels:  gradle-plugin
Vue Info Card
Simple and beautiful card component with an elegant spark line, for VueJS.
Stars: ✭ 159 (-1.85%)
Mutual labels:  vuejs2
Buildkonfig
BuildConfig for Kotlin Multiplatform Project
Stars: ✭ 156 (-3.7%)
Mutual labels:  gradle-plugin
Shipkit
Toolkit for shipping it used by Mockito library
Stars: ✭ 157 (-3.09%)
Mutual labels:  gradle-plugin
Retropiler
PoC of Java8 Standard Library for Android for API version >= 15
Stars: ✭ 159 (-1.85%)
Mutual labels:  gradle-plugin
Vue Admin Manager
整合 vue,element,echarts,video,bootstrap(AdminLTE),admin等,搭建的后台管理系统
Stars: ✭ 153 (-5.56%)
Mutual labels:  vuejs2
Vue Materialize Datatable
A fancy Materialize CSS datatable VueJS component.
Stars: ✭ 162 (+0%)
Mutual labels:  vuejs2
Vue Codemirror
⌨️ @codemirror component for @vuejs
Stars: ✭ 2,115 (+1205.56%)
Mutual labels:  vuejs2
Vue Chimera
VueJS reactive RESTful API
Stars: ✭ 160 (-1.23%)
Mutual labels:  vuejs2
Vue Ui For Pc
基于Vue2.x的一套PC端UI组件,包括了Carousel 跑马灯、Cascader 级联、Checkbox 多选框、Collapse 折叠面板、DatePicker 日期选择、Dialog 对话框、Form 表单、Input 输入框、InputNumber 数字输入框、Layer 弹窗层、Loading 加载、Menu 菜单、Page 分页、Progress 进度条、Radio 单选框、SelectDropDown 仿select、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 文字提示、BackTop 返回顶部、steps 步骤条、Transfer 穿梭框、Tree 树形、Upload 文件上传、Lazy 图片懒加载、Loading 加载、Pagination 分页等等
Stars: ✭ 156 (-3.7%)
Mutual labels:  vuejs2
Pendulum
A simple markdown editor for static files (Hugo, Nexo, Jekyll, MkDocs, ...)
Stars: ✭ 157 (-3.09%)
Mutual labels:  vuejs2
Microjs.com
Fantastic Micro-Frameworks and Micro-Libraries for Fun and Profit!
Stars: ✭ 1,927 (+1089.51%)
Mutual labels:  libraries
Gradle Android Plugin
[Deprecated] Gradle Android Plugin 中文版使用手册,如有纰漏,望斧正
Stars: ✭ 155 (-4.32%)
Mutual labels:  gradle-plugin
Vue Notifyjs
Minimalist 1kb Notification component
Stars: ✭ 160 (-1.23%)
Mutual labels:  vuejs2
V Tooltip
💬 Easy tooltips, popovers, dropdown for Vue
Stars: ✭ 2,109 (+1201.85%)
Mutual labels:  vuejs2
Awesome Pharo
A collection of awesome Pharo libraries, tools, frameworks and software.
Stars: ✭ 159 (-1.85%)
Mutual labels:  libraries
Vue Supply
Create resources that can automatically be activated and deactivated when used (like subscriptions)
Stars: ✭ 162 (+0%)
Mutual labels:  vuejs2
Github Ranking
🔍GitHub不同语言热门项目排行,Vue.js做页面展示
Stars: ✭ 160 (-1.23%)
Mutual labels:  vuejs2
Vuetify Todo Pwa
✔️ A simple Todo PWA built with Vue CLI 3 + Vuex + Vuetify.
Stars: ✭ 160 (-1.23%)
Mutual labels:  vuejs2

English | 日本語/Japanese

vue-kotlin

Libraries and tools supporting the use of Vue.js in Kotlin.

  • vuekt
    • Type definition of Vue.js for Kotlin/JS
  • vuekt-js2vue
    • A library for creating Kotlin files that replace vue files
    • Use Kotlin DSL for CSS
  • vuekt-plugin
    • Gradle plugin to support development using vuekt
      • Generate vue files from code written with vuekt-js2vue
      • Extend kotlin-frontend-plugin

Usage

Gradle setting

buildscript {
    repositories {
        jcenter()
        maven {
            // kotlin-frontend-plugin (vuekt-plugin depends)
            url "https://dl.bintray.com/kotlin/kotlin-eap"
        }
        maven {
            // vuekt-plugin
            url "https://nosix.github.io/vue-kotlin/release"
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:$kotlin_frontend_version"
        classpath "org.musyozoku:vuekt-plugin:$vuekt_plugin_version"
    }
}

repositories {
    jcenter()
    maven {
        // vuekt, vuekt-js2vue
        url "https://nosix.github.io/vue-kotlin/release"
    }
}

apply plugin: 'kotlin2js'
apply plugin: 'org.jetbrains.kotlin.frontend' // kotlin-frontend-plugin
apply plugin: 'org.musyozoku.vuekt' // vuekt-plugin

dependencies {
    // sub projects
    compile project(':greeting') // application that use vue component
    compile project(':greeting-component') // single file vue component
}

kotlinFrontend {
    downloadNodeJsVersion = node_version

    npm {
        dependency('vue', vue_version)

        devDependency('vue-loader', '*')
        devDependency('vue-template-compiler', vue_version)
        devDependency('css-loader', '*')
        devDependency('html-webpack-plugin', '*')
    }

    webpackBundle {
        contentPath = file("$projectDir/webContent")
        publicPath = "/"
        port = 8088
    }
}

subprojects {

    apply plugin: 'kotlin2js'
    
    dependencies {
        compile "org.musyozoku:vuekt:$vuekt_version"
        compile "org.musyozoku:vuekt-js2vue:$vuekt_js2vue_version"
    }
    
    sourceSets {
        main.kotlin.srcDirs += "main"
        test.kotlin.srcDirs += "test"
    }

    compileKotlin2Js {
        kotlinOptions {
            moduleKind = "commonjs" // webpack use CommonJS
        }
    }
}

optional vuekt-plugin settings:

vue {
    targetPattern = ".*-component\\.js"
    configFile = "01_js2vue.js"
}
  • targetPattern
    • vuekt-plugin searches targetPattern for JavaScript files generated from ComponentVue
    • JavaScript files generate vue files
  • configFile
    • vuekt-plugin generate additional webpack config in webpack.config.d directory
    • This config is required when bundling

Project structure

For example:

project_root
    greeting
        main
            [application: Kotlin]
    greeting-component
        main
            [component: Kotlin]
    src
        main
            kotlin
                dummy.kt (*1)
    webContent
      [web resources: HTML, etc.]
    webpack.config.d
      [webpack config: JavaScript]

You need to set webpack config. See single-file project in GitHub repository.

(*1): It is necessary if you have multiple entries in webpack config. kotlin-frontend-plugin assumes one entry. By default it does not create sub projects.

Application

For example:

// GreetingComponent = require('greeting-component.vue')
@JsModule("greeting-component.vue")
external val GreetingComponent: Component = definedExternally

@JsModule("vue") // module name in node_modules
@JsName("Vue") // `AppVue` is converted to the name `Vue` in JavaScript code
external class AppVue(options: ComponentOptions<AppVue>) : Vue {
    var message: String
}

val vm = AppVue(ComponentOptions {
    el = ElementConfig("#app") // ElementConfig is union type
    data = Data(json<AppVue> { // json function create JSON instance
        message = "Vue & Kotlin" // accessible property of AppVue
    })
    components = json {
        this["greeting"] = ComponentConfig(GreetingComponent)
    }
})

Component

For example:

external class GreetingComponent : Vue {
    var greeting: String
}

// class name is used for file name (can be overridden)
class GreetingComponentVue : ComponentVue<GreetingComponent> {

    // vue template (Note: in IntelliJ, editing with inject language will result in syntax highlighting)
    override val template: String = """<p>{{ greeting }} World!</p>"""

    // CSS (it becomes scoped if scopedStyle property is overridden with true)
    override val style: StyleBuilder = {
        p {
            fontSize = 2.em
            textAlign = center
        }
    }

    override val script: ComponentOptionsBuilder<GreetingComponent> = {
        data = Data {
            json<GreetingComponent> {
                greeting = "Hello"
            }
        }
    }
}

@Suppress("unused")
val options = translate(GreetingComponentVue()) // required, used by bundling

CSS library: null-dev/Aza-Kotlin-CSS-JS (MIT License)

Two files are generated:

  • greeting-component.js (kotlin2js generated)
  • greeting-component.vue (js2vue generated)

Generated vue file (greeting-component.vue):

<template>
<p>{{ greeting }} World!</p>
</template>

<style>
p{font-size:2em;text-align:center}
</style>

<script>
module.exports = require('greeting-component.js').options
</script>

options in the component is used in the vue file.

Data flow

  • greeting-component.js and greeting-component.vue are named from GreetingComponentVue
    • Vue of prefix/suffix is removed
    • Camel case is converted to kebab case
    • You can change the name by overriding ComponentVue::name property
      • default is this::class.js.name.replace("^Vue|Vue$".toRegex(), "").replace("([A-Z])".toRegex(), "-$1").toLowerCase().trim('-')
  • vuekt-js2vue finds *-component.js
    • You can change the pattern by setting targetPattern in build.gradle

Trial

  1. Clone this repository.

  2. Publish plugin to local repository.

    $ ./gradlew --project-dir=vuekt-plugin publishToMavenLocal
    

Try production build (minify is still)

  1. Generate bundle files.

    $ ./gradlew bundle
    
  2. Open the following in a browser.

    • guide/index.html
    • guide/instance.html
    • guide/syntax.html
    • guide/computed.html
    • guide/class-and-style.html
    • guide/list.html
    • guide/events_.html
    • guide/forms.html
    • guide/components.html
    • guide/filters.html
    • single-file/build/bundle/greeting.html

Try development build

  1. Run webpack-dev-server. (-t is option for continuous build)

    $ ./gradlew -t single-file:run
    
  2. Open http://localhost:8088/ on the browser.

    HMR (Hot Module Replacement) is enabled. (Edit greeting/main/greeting.kt and/or greeting-component/main/GreetingComponent.kt)

  3. Stop webpack-dev-server.

    $ ./gradlew single-file:stop
    

Troubleshooting

  1. Execution failed for task webpack-bundle: node webpack.js failed

    Please try the following script:

    $ bin/webpack.sh
    
  2. Changing vuekt and/or vuekt-js2vue don't update guide and single-file project.

    kotlin-frontend-plugin does not update node_modules.

    Please try the following command:

    $ ./gradlew clean
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].