Skip to content

Commit

Permalink
Fix order of platform bubbles in header (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Nov 14, 2021
1 parent 91b2fab commit b0ef738
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ open class HtmlRenderer(
if (shouldRenderSourceSetBubbles && page is ContentPage) {
div(classes = "filter-section") {
id = "filter-section"
page.content.withDescendants().flatMap { it.sourceSets }.distinct().forEach {
button(classes = "platform-tag platform-selector") {
attributes["data-active"] = ""
attributes["data-filter"] = it.sourceSetIDs.merged.toString()
when (it.platform.key) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
"jvm" -> classes = classes + "jvm-like"
"js" -> classes = classes + "js-like"
page.content.withDescendants().flatMap { it.sourceSets }.distinct()
.sortedBy { it.comparableKey }.forEach {
button(classes = "platform-tag platform-selector") {
attributes["data-active"] = ""
attributes["data-filter"] = it.sourceSetIDs.merged.toString()
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.name)
}
text(it.name)
}
}
}
}
}
Expand Down Expand Up @@ -223,7 +224,7 @@ open class HtmlRenderer(
+htmlContent
}
}
}.sortedBy { it.first.sourceSetIDs.merged.let { it.scopeId + it.sourceSetName } }
}.sortedBy { it.first.comparableKey }
}

override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) {
Expand Down Expand Up @@ -912,3 +913,6 @@ private fun PropertyContainer<ContentNode>.extraHtmlAttributes() = allOfType<Sim

private val ContentNode.sourceSetsFilters: String
get() = sourceSets.sourceSetIDs.joinToString(" ") { it.toString() }

private val DisplaySourceSet.comparableKey
get() = sourceSetIDs.merged.let { it.scopeId + it.sourceSetName }

0 comments on commit b0ef738

Please sign in to comment.