Skip to content

Commit

Permalink
Mobile header font size #1475
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinAman authored and Kordyjan committed Sep 17, 2020
1 parent 803402b commit af9f246
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");"""
Expand Down
34 changes: 30 additions & 4 deletions plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}

fun FlowContent.buildBreakableText(name: String) =
if (name.contains(".")) buildBreakableDotSeparatedHtml(name)
else buildTextBreakableAfterCapitalLetters(name)
11 changes: 11 additions & 0 deletions plugins/base/src/main/resources/dokka/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
.breadcrumbs {
padding: 24px 0;
color: var(--breadcrumb-font-color);
max-width: calc(100% - 32px);
overflow-wrap: break-word;
}

.breadcrumbs a {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1131,4 +1138,8 @@ div.runnablesample {
padding-bottom: 16px;
overflow: auto;
}
h1.cover {
font-size: 32px;
line-height: 32px;
}
}

0 comments on commit af9f246

Please sign in to comment.