aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-04-06 14:24:07 +0200
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-04-15 14:41:29 +0200
commit72db3a16521408509f4a0f61ef110851a252d2cc (patch)
tree24f0a93c809045d66063c4c643d6ded4d4c6a0bc /plugins/base/src/main/kotlin/renderers
parentfee86d79a3aa7357c68c2f8f519d187f43447e8c (diff)
downloaddokka-72db3a16521408509f4a0f61ef110851a252d2cc.tar.gz
dokka-72db3a16521408509f4a0f61ef110851a252d2cc.tar.bz2
dokka-72db3a16521408509f4a0f61ef110851a252d2cc.zip
Change PlatformHintedContent rendering, js and css to match Figma style
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt37
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt3
2 files changed, 27 insertions, 13 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index e1025ed4..bbb5b685 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -60,20 +60,33 @@ open class HtmlRenderer(
}
override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) {
- val distinct = content.platforms.map {
- it to createHTML(prettyPrint = false).div {
- buildContentNode(content.inner, pageContext, it)
- }.drop(5).dropLast(6) // TODO: Find a way to do it without arbitrary trims
- }.groupBy(Pair<PlatformData, String>::second, Pair<PlatformData, String>::first)
-
- if (distinct.size == 1)
- consumer.onTagContentUnsafe { +distinct.keys.single() }
- else
- distinct.forEach { text, platforms ->
- consumer.onTagContentUnsafe {
- +platforms.joinToString(prefix = " [", postfix = "] $text") { it.platformType.key }
+ div("platform-hinted") {
+ attributes["data-platform-hinted"] = "data-platform-hinted"
+ val contents = content.platforms.mapIndexed { index,platform ->
+ platform to createHTML(prettyPrint = false).div(classes = "content") {
+ if (index == 0) attributes["data-active"] = ""
+ attributes["data-togglable"] = platform.targets.joinToString("-")
+ buildContentNode(content.inner, pageContext, platform)
}
}
+
+ if(contents.size != 1) {
+ div("platform-bookmarks-row") {
+ attributes["data-toggle-list"] = "data-toggle-list"
+ contents.forEachIndexed { index,pair ->
+ button(classes = "platform-bookmark") {
+ if (index == 0) attributes["data-active"] = ""
+ attributes["data-toggle"] = pair.first.targets.joinToString("-")
+ text(pair.first.targets.joinToString(", "));
+ }
+ }
+ }
+ }
+
+ contents.forEach {
+ consumer.onTagContentUnsafe { +it.second }
+ }
+ }
}
override fun FlowContent.buildList(
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index 9fed74e2..aaf82ba8 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -64,7 +64,8 @@ object StyleAndScriptsAppender : PageTransformer {
it.modified(
embeddedResources = it.embeddedResources + listOf(
"styles/style.css",
- "scripts/navigationLoader.js"
+ "scripts/navigationLoader.js",
+ "scripts/platformContentHandler.js"
)
)
}