Skip to content

Commit 0db5656

Browse files
authored
Fix highlighting of top bar. Not highlight main page whole time (#2852)
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
1 parent 70423bd commit 0db5656

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarLinks.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,15 @@ data class TopBarLink(
105105
private fun textColor(
106106
hrefAnchor: String,
107107
location: Location<*>,
108-
) = if (location.pathname.endsWith(hrefAnchor) && location.pathname.count { it == '/' } < TOP_BAR_PATH_SEGMENTS_HIGHLIGHT) {
109-
"text-warning"
110-
} else {
111-
"text-light"
108+
): String {
109+
val isMainPage = (location.pathname.count { it == '/' } == 1) && hrefAnchor.isBlank()
110+
val isNeedToHighlightTopBar = (hrefAnchor.isNotBlank() &&
111+
location.pathname.endsWith(hrefAnchor) && location.pathname.count { it == '/' } < TOP_BAR_PATH_SEGMENTS_HIGHLIGHT) ||
112+
isMainPage
113+
114+
return if (isNeedToHighlightTopBar) {
115+
"text-warning"
116+
} else {
117+
"text-light"
118+
}
112119
}

0 commit comments

Comments
 (0)