From dfefa90b4aa7ca0622cf01d14f4fb5083b8b74eb Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Wed, 20 May 2020 16:19:49 +0200 Subject: Adding tag bubbles to merged hints --- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 85005bc0..c62c5d3c 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -52,6 +52,7 @@ open class HtmlRenderer( nodes: Map>, pageContext: ContentPage ) { + var mergedToOneSourceSet : SourceSetData? = null div("platform-hinted") { attributes["data-platform-hinted"] = "data-platform-hinted" var counter = 0 @@ -94,11 +95,14 @@ open class HtmlRenderer( } } } + } else if (nodes.size > 1) { + mergedToOneSourceSet = contents.first().first } contents.forEach { consumer.onTagContentUnsafe { +it.second } } } + mergedToOneSourceSet?.let { createPlatformTagBubbles(listOf(it)) } } override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) { @@ -239,24 +243,30 @@ open class HtmlRenderer( } } - private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set? = null) { - node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let { - div("platform-tags") { - node.sourceSets.filter { sourceSetRestriction == null || it in sourceSetRestriction }.forEach { data -> - div("platform-tag") { - when(data.platform.key){ - "common" -> classes = classes + "common-like" - "native" -> classes = classes + "native-like" - "jvm" -> classes = classes + "jvm-like" - "js" -> classes = classes + "js-like" - } - text(data.sourceSetName) + private fun FlowContent.createPlatformTagBubbles(sourceSets: List) { + div("platform-tags") { + sourceSets.forEach { + div("platform-tag") { + when(it.platform.key){ + "common" -> classes = classes + "common-like" + "native" -> classes = classes + "native-like" + "jvm" -> classes = classes + "jvm-like" + "js" -> classes = classes + "js-like" } + text(it.sourceSetName) } } } } + private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set? = null) { + node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let { + createPlatformTagBubbles( node.sourceSets.filter { + sourceSetRestriction == null || it in sourceSetRestriction + }) + } + } + override fun FlowContent.buildTable( node: ContentTable, pageContext: ContentPage, -- cgit