Merge remote-tracking branch 'origin/master'
This commit is contained in:
2
.idea/modules/komp.iml
generated
2
.idea/modules/komp.iml
generated
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id="komp" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.version="0.0.2-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$/../..">
|
<content url="file://$MODULE_DIR$/../..">
|
||||||
|
|||||||
2
.idea/modules/komp_main.iml
generated
2
.idea/modules/komp_main.iml
generated
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id="komp:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.0.2-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="2" platform="JavaScript " useProjectSettings="false">
|
<configuration version="2" platform="JavaScript " useProjectSettings="false">
|
||||||
|
|||||||
2
.idea/modules/komp_test.iml
generated
2
.idea/modules/komp_test.iml
generated
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id="komp:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.0.2-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="2" platform="JavaScript " useProjectSettings="false">
|
<configuration version="2" platform="JavaScript " useProjectSettings="false">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
group 'nl.astraeus'
|
group 'nl.astraeus'
|
||||||
version '0.0.1-SNAPSHOT'
|
version '0.0.2-SNAPSHOT'
|
||||||
|
|
||||||
apply plugin: 'kotlin2js'
|
apply plugin: 'kotlin2js'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,4 +1,4 @@
|
|||||||
#Sun Apr 02 22:05:18 CEST 2017
|
#Wed May 10 15:59:40 CEST 2017
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
24
src/main/kotlin/nl/astraeus/komp/ComponentSize.kt
Normal file
24
src/main/kotlin/nl/astraeus/komp/ComponentSize.kt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package nl.astraeus.komp
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: rnentjes
|
||||||
|
* Date: 10-5-17
|
||||||
|
* Time: 16:48
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum class SizeType {
|
||||||
|
NONE,
|
||||||
|
ABSOLUTE,
|
||||||
|
PERCENTAGE,
|
||||||
|
FLEX,
|
||||||
|
FILL
|
||||||
|
}
|
||||||
|
|
||||||
|
open class ComponentSize(
|
||||||
|
val xType: SizeType,
|
||||||
|
val yType: SizeType,
|
||||||
|
val xValue: Float,
|
||||||
|
val yValue: Float
|
||||||
|
)
|
||||||
|
|
||||||
|
class NotSized : ComponentSize(SizeType.NONE, SizeType.NONE, 0f, 0f)
|
||||||
@@ -36,4 +36,6 @@ abstract class HtmlComponent {
|
|||||||
open fun refresh() {
|
open fun refresh() {
|
||||||
Komp.refresh(element)
|
Komp.refresh(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun getSize(): ComponentSize? = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.astraeus.komp
|
package nl.astraeus.komp
|
||||||
|
|
||||||
import org.w3c.dom.HTMLElement
|
import org.w3c.dom.HTMLElement
|
||||||
|
import kotlin.browser.window
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: rnentjes
|
* User: rnentjes
|
||||||
@@ -54,7 +55,44 @@ object Komp {
|
|||||||
val newElement = comp.create()
|
val newElement = comp.create()
|
||||||
|
|
||||||
parent?.replaceChild(newElement, element)
|
parent?.replaceChild(newElement, element)
|
||||||
|
|
||||||
|
window.setTimeout({
|
||||||
|
resize(comp)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resize(component: HtmlComponent) {
|
||||||
|
println("Resize $component")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sizeElement(element: HTMLElement, size: ComponentSize) {
|
||||||
|
var width = ""
|
||||||
|
var height = ""
|
||||||
|
val parent = element.parentElement as HTMLElement
|
||||||
|
|
||||||
|
when(size.xType) {
|
||||||
|
SizeType.ABSOLUTE -> {
|
||||||
|
width = "${size.xValue.toInt()}px"
|
||||||
|
}
|
||||||
|
SizeType.PERCENTAGE -> {
|
||||||
|
width = "${(parent.clientWidth * size.xValue / 100f).toInt()}px"
|
||||||
|
}
|
||||||
|
SizeType.FILL -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
SizeType.FLEX -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width.isNotBlank()) {
|
||||||
|
element.style.width = width
|
||||||
|
}
|
||||||
|
if (height.isNotBlank()) {
|
||||||
|
element.style.height = height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user