diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-09-15 11:34:54 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-09-17 11:08:38 +0200 |
commit | bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03 (patch) | |
tree | 87c52e3ad2e94e2af192879ad46cb8dbf2acbc57 /plugins/base | |
parent | d810c7782814697bb65d078432cd2ace84748a21 (diff) | |
download | dokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.tar.gz dokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.tar.bz2 dokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.zip |
Mobile header font size #1475
Diffstat (limited to 'plugins/base')
4 files changed, 43 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 93a20157..01f4ed6d 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -633,7 +633,7 @@ open class HtmlRenderer( consumer.onTagContentEntity(Entities.nbsp) text(textNode.text) } - textNode.hasStyle(TextStyle.Cover) -> buildBreakableDotSeparatedHtml(textNode.text) + textNode.hasStyle(TextStyle.Cover) -> buildBreakableText(textNode.text) else -> text(textNode.text) } diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index 24065e57..bc414e23 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -26,7 +26,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { id = navId attributes["pageId"] = node.dri.toString() div("overview") { - buildLink(node.dri, node.sourceSets.toList()) { buildBreakableDotSeparatedHtml(node.name) } + buildLink(node.dri, node.sourceSets.toList()) { buildBreakableText(node.name) } if (node.children.isNotEmpty()) { span("navButton pull-right") { onClick = """document.getElementById("$navId").classList.toggle("hidden");""" diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt index 1102b86d..65bf59fa 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt @@ -3,15 +3,41 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.FlowContent import kotlinx.html.span +fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String) { + if (name.contains(" ")) { + val withOutSpaces = name.split(" ") + withOutSpaces.dropLast(1).forEach { + buildBreakableText(it) + +" " + } + buildBreakableText(withOutSpaces.last()) + } else { + val content = name.replace(Regex("(?!^)([A-Z])"), " $1").split(" ") + joinToHtml(content){ + it + } + } +} + fun FlowContent.buildBreakableDotSeparatedHtml(name: String) { val phrases = name.split(".") - phrases.dropLast(1).forEach { + joinToHtml(phrases){ + "$it." + } +} + +private fun FlowContent.joinToHtml(elements: List<String>, onEach: (String) -> String) { + elements.dropLast(1).forEach { span { - +"$it." + +onEach(it) } wbr { } } span { - +phrases.last() + +elements.last() } -}
\ No newline at end of file +} + +fun FlowContent.buildBreakableText(name: String) = + if (name.contains(".")) buildBreakableDotSeparatedHtml(name) + else buildTextBreakableAfterCapitalLetters(name)
\ No newline at end of file diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index 7b4aaa33..d1c86eb1 100644 --- a/plugins/base/src/main/resources/dokka/styles/style.css +++ b/plugins/base/src/main/resources/dokka/styles/style.css @@ -19,6 +19,8 @@ .breadcrumbs { padding: 24px 0; color: var(--breadcrumb-font-color); + max-width: calc(100% - 32px); + overflow-wrap: break-word; } .breadcrumbs a { @@ -1073,6 +1075,11 @@ div.runnablesample { .filter-section { position: unset; } + h1.cover { + font-size: 48px; + line-height: 48px; + padding-bottom: 8px; + } } @media screen and (max-width: 759px) { @@ -1131,4 +1138,8 @@ div.runnablesample { padding-bottom: 16px; overflow: auto; } + h1.cover { + font-size: 32px; + line-height: 32px; + } }
\ No newline at end of file |