aboutsummaryrefslogtreecommitdiff
path: root/examples/helloworld/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-03 23:21:46 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-03 23:21:46 +0100
commit9665fe692681bc958e55d00cc0d0b238b7aee694 (patch)
treedd222dec725f64b8065a09311d9b034e9b9751b3 /examples/helloworld/src
parent180528f620e53e4a828d6f4d427ce83817572f44 (diff)
downloadkvision-9665fe692681bc958e55d00cc0d0b238b7aee694.tar.gz
kvision-9665fe692681bc958e55d00cc0d0b238b7aee694.tar.bz2
kvision-9665fe692681bc958e55d00cc0d0b238b7aee694.zip
Refactoring for kdoc API documentation with dokka
Diffstat (limited to 'examples/helloworld/src')
-rw-r--r--examples/helloworld/src/main/kotlin/com/example/Helloworld.kt32
-rw-r--r--examples/helloworld/src/main/kotlin/com/example/Main.kt42
-rw-r--r--examples/helloworld/src/main/resources/css/style.css3
-rw-r--r--examples/helloworld/src/main/web/index.html19
-rw-r--r--examples/helloworld/src/test/kotlin/test/com/example/HelloworldSpec.kt21
-rw-r--r--examples/helloworld/src/test/kotlin/test/com/example/TestUtil.kt32
6 files changed, 0 insertions, 149 deletions
diff --git a/examples/helloworld/src/main/kotlin/com/example/Helloworld.kt b/examples/helloworld/src/main/kotlin/com/example/Helloworld.kt
deleted file mode 100644
index 61e75482..00000000
--- a/examples/helloworld/src/main/kotlin/com/example/Helloworld.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.example
-
-import pl.treksoft.kvision.ApplicationBase
-import pl.treksoft.kvision.core.Root
-import pl.treksoft.kvision.html.TAG
-import pl.treksoft.kvision.html.Tag
-import pl.treksoft.kvision.panel.FLEXDIR
-import pl.treksoft.kvision.panel.FLEXJUSTIFY
-import pl.treksoft.kvision.panel.FlexPanel
-import pl.treksoft.kvision.utils.px
-
-class Helloworld : ApplicationBase() {
-
- override fun start(state: Map<String, Any>) {
- val root = Root("helloworld")
- val panel = FlexPanel(FLEXDIR.ROW, justify = FLEXJUSTIFY.CENTER)
- val hello = Tag(TAG.DIV, "Hello world!", classes = setOf("helloworld")).apply {
- marginTop = 50.px()
-
- }
- panel.add(hello)
- root.add(panel)
- }
-
- override fun dispose(): Map<String, Any> {
- return mapOf()
- }
-
- companion object {
- val css = require("./css/style.css")
- }
-}
diff --git a/examples/helloworld/src/main/kotlin/com/example/Main.kt b/examples/helloworld/src/main/kotlin/com/example/Main.kt
deleted file mode 100644
index 53b6b0ae..00000000
--- a/examples/helloworld/src/main/kotlin/com/example/Main.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.example
-
-import pl.treksoft.kvision.ApplicationBase
-import pl.treksoft.kvision.core.KVManager
-import pl.treksoft.kvision.module
-import kotlin.browser.document
-
-external fun require(name: String): dynamic
-
-fun main(args: Array<String>) {
- var application: ApplicationBase? = null
-
- val state: dynamic = module.hot?.let { hot ->
- hot.accept()
-
- hot.dispose { data ->
- data.appState = application?.dispose()
- KVManager.shutdown()
- application = null
- }
-
- hot.data
- }
-
- if (document.body != null) {
- KVManager.start()
- application = start(state)
- } else {
- KVManager.init()
- application = null
- document.addEventListener("DOMContentLoaded", { application = start(state) })
- }
-}
-
-fun start(state: dynamic): ApplicationBase? {
- if (document.getElementById("helloworld") == null) return null
- val application = Helloworld()
- @Suppress("UnsafeCastFromDynamic")
- application.start(state?.appState ?: emptyMap())
- return application
-}
-
diff --git a/examples/helloworld/src/main/resources/css/style.css b/examples/helloworld/src/main/resources/css/style.css
deleted file mode 100644
index 76482c15..00000000
--- a/examples/helloworld/src/main/resources/css/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.helloworld {
- font-size: 30px;
-}
diff --git a/examples/helloworld/src/main/web/index.html b/examples/helloworld/src/main/web/index.html
deleted file mode 100644
index a29727fe..00000000
--- a/examples/helloworld/src/main/web/index.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>KVision Helloworld</title>
- <script type="text/javascript" src="main.bundle.js"></script>
- <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
- <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
- <!--[if lt IE 9]>
- <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
- <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
- <![endif]-->
-</head>
-<body>
-<div id="helloworld"></div>
-</body>
-</html>
diff --git a/examples/helloworld/src/test/kotlin/test/com/example/HelloworldSpec.kt b/examples/helloworld/src/test/kotlin/test/com/example/HelloworldSpec.kt
deleted file mode 100644
index 8054c000..00000000
--- a/examples/helloworld/src/test/kotlin/test/com/example/HelloworldSpec.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.com.example
-
-import com.example.Helloworld
-import kotlin.browser.document
-import kotlin.test.Test
-import kotlin.test.assertTrue
-
-class HelloworldSpec : DomSpec {
-
- @Test
- fun render() {
- run {
- Helloworld().start(mapOf())
- val element = document.getElementById("helloworld")
- assertTrue(
- element?.innerHTML?.contains("Hello world!") ?: false,
- "Application should render Hello world! text"
- )
- }
- }
-}
diff --git a/examples/helloworld/src/test/kotlin/test/com/example/TestUtil.kt b/examples/helloworld/src/test/kotlin/test/com/example/TestUtil.kt
deleted file mode 100644
index c5ec014f..00000000
--- a/examples/helloworld/src/test/kotlin/test/com/example/TestUtil.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package test.com.example
-
-import pl.treksoft.jquery.jQuery
-import kotlin.browser.document
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"helloworld\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.remove()
- jQuery(`object` = ".modal-backdrop").remove()
- }
-
-}