Skip to content

Commit

Permalink
JS target rework
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Mar 15, 2021
1 parent 497e2eb commit 67c9dd0
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 45 deletions.
17 changes: 13 additions & 4 deletions app/src/jsMain/kotlin/app/view/Header.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private fun RenderContext.SearchModal() = modal({
}
stackUpClose {
TargetCheckboxGroup(mapOf(
"js" to "js",
"legacy" to "legacy",
"ir" to "ir",
)) {
h4 { +"JS" }
}
Expand Down Expand Up @@ -221,17 +222,25 @@ fun RenderContext.Pagination() = lineUp {
spacing { none }
items {
LibraryStore.data.mapLatest { it.libraries }.mapNotNull { it }.render { libs ->
clickButton {
clickButton({
css("border-top-right-radius: 0")
css("border-bottom-right-radius: 0")
}) {
size { small }
icon { fromTheme { caretLeft } }
disabled(libs.prev == null)
} handledBy fetchLibraryPage(libs.page - 1)
clickButton {
clickButton({
css("border-radius: 0")
}) {
size { small }
variant { outline }
text("${libs.page}")
}
clickButton {
clickButton({
css("border-top-left-radius: 0")
css("border-bottom-left-radius: 0")
}) {
size { small }
icon { fromTheme { caretRight } }
disabled(libs.next == null)
Expand Down
41 changes: 27 additions & 14 deletions app/src/jsMain/kotlin/app/view/component/LibraryCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import dev.fritz2.binding.*
import dev.fritz2.components.*
import dev.fritz2.dom.html.*
import dev.fritz2.styling.theme.*
import io.ktor.http.*
import io.ktor.util.date.*
import kamp.domain.*
import kotlinx.coroutines.flow.*

Expand Down Expand Up @@ -41,7 +43,7 @@ private fun RenderContext.TargetBadge(category: String, targets: List<KotlinTarg
}, content)
}

if (targets.size > 1 || targets.firstOrNull()?.variant != null) {
if (targets.size > 1) {
popover({
width { minContent }
css("border-radius: 0.5rem")
Expand Down Expand Up @@ -71,11 +73,7 @@ private fun RenderContext.TargetBadge(category: String, targets: List<KotlinTarg
color { base }
textShadow { flat }
}) {
+if (target.category == KotlinTarget.JS.category) {
target.variant ?: "UNKNOWN"
} else {
target.platform
}
+target.platform
}
}
}
Expand Down Expand Up @@ -123,18 +121,33 @@ private fun RenderContext.CardHeader(library: KotlinMPPLibrary) {
}
}
lineUp({
justifyContent { flexEnd }
justifyContent { spaceBetween }
}) {
spacing { none }
items {
library.website?.let {
Link(it, "_new") {
+"Website"
box({
css("align-self: flex-end")
}) {
library.lastUpdated?.let {
sub {
+GMTDate(it).toHttpDate()
}
}
}
library.scm?.let {
Link(it, "_new") {
+"SCM"
lineUp({
justifyContent { flexEnd }
}) {
spacing { none }
items {
library.website?.let {
Link(it, "_new") {
+"Website"
}
}
library.scm?.let {
Link(it, "_new") {
+"SCM"
}
}
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions app/src/jsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<!doctype html>
<html lang="en">
<html lang='en'>
<head>
<meta charset="utf-8">
<meta content="width=device-width, minimum-scale=1, initial-scale=1, shrink-to-fit=no" name="viewport">
<meta content="#000000" name="theme-color">
<meta charset='utf-8'>
<meta content='width=device-width, minimum-scale=1, initial-scale=1, shrink-to-fit=no' name='viewport'>
<meta content='#000000' name='theme-color'>

<link href="/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link color="#5bbad5" href="/safari-pinned-tab.svg" rel="mask-icon">
<meta content="#da532c" name="msapplication-TileColor">
<meta content="#ffffff" name="theme-color">
<link href='/apple-touch-icon.png' rel='apple-touch-icon' sizes='180x180'>
<link href='/favicon-32x32.png' rel='icon' sizes='32x32' type='image/png'>
<link href='/favicon-16x16.png' rel='icon' sizes='16x16' type='image/png'>
<link href='/site.webmanifest' rel='manifest'>
<link color='#5bbad5' href='/safari-pinned-tab.svg' rel='mask-icon'>
<meta content='#da532c' name='msapplication-TileColor'>
<meta content='#ffffff' name='theme-color'>

<title id="title">KAMP</title>
<title id='title'>KAMP</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<script src="${jsOutputFileName}" type="text/javascript"></script>
<div id='root'></div>
<script src='${jsOutputFileName}' type='text/javascript'></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class GradleModuleProcessorTest : FunSpec({

test("listSupportedTargets") {
with(GradleModuleProcessor()) {

val targets = module.supportedTargets

targets shouldContainExactlyInAnyOrder setOf(
KotlinTarget.JVM.Android(),
KotlinTarget.JVM.Java(),
Expand All @@ -31,7 +31,7 @@ class GradleModuleProcessorTest : FunSpec({
KotlinTarget.Native("ios_x64"),
KotlinTarget.Common(),
)

val targets1 = parseJsonFile<GradleModule>("redux-kotlin-0.5.5.module").supportedTargets
targets1 shouldContainExactlyInAnyOrder setOf(
KotlinTarget.Native("android_arm32"),
Expand Down
18 changes: 8 additions & 10 deletions src/commonMain/kotlin/kamp/domain/KotlinTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@ import kotlinx.serialization.*

@Serializable
public class KotlinTarget private constructor(
public val platform: String,
public val category: String,
public val variant: String? = null,
public val platform: String,
) {

override fun toString(): String = "$category:$platform${if (variant == null) "" else ":$variant"}"
override fun toString(): String = "$category:$platform"
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is KotlinTarget) return false

if (platform != other.platform) return false
if (category != other.category) return false
if (variant != other.variant) return false

return true
}

override fun hashCode(): Int {
var result = variant.hashCode()
var result = platform.hashCode()
result = 31 * result + category.hashCode()
return result
}
Expand All @@ -34,18 +32,18 @@ public class KotlinTarget private constructor(

public object JS {
public const val category: String = "js"
public fun Legacy(): KotlinTarget = KotlinTarget(category, category, "legacy")
public fun IR(): KotlinTarget = KotlinTarget(category, category, "ir")
public fun Legacy(): KotlinTarget = KotlinTarget(category, "legacy")
public fun IR(): KotlinTarget = KotlinTarget(category, "ir")
}

public object JVM {
public const val category: String = "jvm"
public fun Java(): KotlinTarget = KotlinTarget("jvm", category)
public fun Android(): KotlinTarget = KotlinTarget("android", category)
public fun Java(): KotlinTarget = KotlinTarget(category, "jvm")
public fun Android(): KotlinTarget = KotlinTarget(category, "android")
}

public object Native {
public const val category: String = "native"
public operator fun invoke(name: String): KotlinTarget = KotlinTarget(name, category)
public operator fun invoke(platform: String): KotlinTarget = KotlinTarget(category, platform)
}
}

0 comments on commit 67c9dd0

Please sign in to comment.