Skip to content

Commit

Permalink
Fix highlighting of top bar. Not highlight main page whole time (#2852)
Browse files Browse the repository at this point in the history
Fix highlighting of top bar. Not highlight main page whole time
### What's done:
* Fix highlighting of top bar. Not highlight main page whole time
  • Loading branch information
kgevorkyan authored Nov 9, 2023
1 parent 70423bd commit 0db5656
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@ data class TopBarLink(
private fun textColor(
hrefAnchor: String,
location: Location<*>,
) = if (location.pathname.endsWith(hrefAnchor) && location.pathname.count { it == '/' } < TOP_BAR_PATH_SEGMENTS_HIGHLIGHT) {
"text-warning"
} else {
"text-light"
): String {
val isMainPage = (location.pathname.count { it == '/' } == 1) && hrefAnchor.isBlank()
val isNeedToHighlightTopBar = (hrefAnchor.isNotBlank() &&
location.pathname.endsWith(hrefAnchor) && location.pathname.count { it == '/' } < TOP_BAR_PATH_SEGMENTS_HIGHLIGHT) ||
isMainPage

return if (isNeedToHighlightTopBar) {
"text-warning"
} else {
"text-light"
}
}

0 comments on commit 0db5656

Please sign in to comment.