From 6f11b73e24e536ddcfe7de5d754559efc97a5821 Mon Sep 17 00:00:00 2001 From: luki120 Date: Tue, 17 Sep 2024 20:06:30 -0300 Subject: [PATCH] =?UTF-8?q?Header=20improvements=20=E2=80=A2=20close=20the?= =?UTF-8?q?=20submenu=20on=20mobile=20devices=20if=20a=20link=20is=20click?= =?UTF-8?q?ed=20=E2=80=A2=20replaced=20deprecated=20deferRender=20function?= =?UTF-8?q?=20=E2=87=9D=20Deferred?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/me/luki/website/composables/Header.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/site/src/jsMain/kotlin/me/luki/website/composables/Header.kt b/site/src/jsMain/kotlin/me/luki/website/composables/Header.kt index aae440b..85e72e9 100644 --- a/site/src/jsMain/kotlin/me/luki/website/composables/Header.kt +++ b/site/src/jsMain/kotlin/me/luki/website/composables/Header.kt @@ -24,7 +24,7 @@ import com.varabyte.kobweb.silk.components.navigation.UncoloredLinkVariant import com.varabyte.kobweb.silk.components.navigation.UndecoratedLinkVariant import com.varabyte.kobweb.silk.components.overlay.* import com.varabyte.kobweb.silk.components.text.SpanText -import com.varabyte.kobweb.silk.defer.deferRender +import com.varabyte.kobweb.silk.defer.Deferred import com.varabyte.kobweb.silk.style.animation.Keyframes import com.varabyte.kobweb.silk.style.animation.toAnimation import com.varabyte.kobweb.silk.style.breakpoint.Breakpoint @@ -60,7 +60,7 @@ private enum class SideMenuState { @Composable fun Header() { - deferRender { + Deferred { Row( TranslucentNavBarStyle.toModifier() .displayIfAtLeast(Breakpoint.MD) @@ -137,7 +137,7 @@ private fun SideMenu(menuState: SideMenuState, close: () -> Unit, onAnimationEnd .textAlign(TextAlign.Center), horizontalAlignment = Alignment.End ) { - MenuItems() + MenuItems(onLinkClick = { close() }) } } } @@ -145,19 +145,19 @@ private fun SideMenu(menuState: SideMenuState, close: () -> Unit, onAnimationEnd } @Composable -private fun MenuItems() { - MenuLink(path = "#experience", text = "Experience") - MenuLink(path = "#projects", text = "Projects") +private fun MenuItems(onLinkClick: () -> Unit = {}) { + MenuLink(path = "#experience", text = "Experience", onClick = onLinkClick) + MenuLink(path = "#projects", text = "Projects", onClick = onLinkClick) } @Composable -private fun MenuLink(path: String, text: String) { +private fun MenuLink(path: String, text: String, onClick: () -> Unit) { val breakpoint = rememberBreakpoint() Link( path = path, text = text, - modifier = LinkStyle.toModifier(), + modifier = LinkStyle.toModifier().onClick { onClick() }, variant = if (breakpoint == Breakpoint.ZERO) UndecoratedLinkVariant.then(UncoloredLinkVariant) else UndecoratedLinkVariant ) }