From 80e80f83ef3639ef19c2c4dbc2b8bfc7cd725694 Mon Sep 17 00:00:00 2001 From: luki120 Date: Mon, 2 Dec 2024 00:20:58 -0300 Subject: [PATCH] =?UTF-8?q?improvements=20=E2=80=A2=20calculate=20the=20ye?= =?UTF-8?q?ars=20of=20experience=20dynamically=20=E2=80=A2=20no=20need=20t?= =?UTF-8?q?o=20write=20the=20svh=20unit=20as=20a=20string=20&=20use=20an?= =?UTF-8?q?=20unsafe=20cast=20anymore=20since=20now=20Kobweb=20supports=20?= =?UTF-8?q?dynamic=20viewport=20units?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/luki/website/sections/MainSection.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/site/src/jsMain/kotlin/me/luki/website/sections/MainSection.kt b/site/src/jsMain/kotlin/me/luki/website/sections/MainSection.kt index 3d6c130..193be55 100644 --- a/site/src/jsMain/kotlin/me/luki/website/sections/MainSection.kt +++ b/site/src/jsMain/kotlin/me/luki/website/sections/MainSection.kt @@ -1,7 +1,9 @@ package me.luki.website.sections import androidx.compose.runtime.Composable -import com.varabyte.kobweb.compose.css.* +import com.varabyte.kobweb.compose.css.AnimationIterationCount +import com.varabyte.kobweb.compose.css.TextAlign +import com.varabyte.kobweb.compose.css.svh import com.varabyte.kobweb.compose.foundation.layout.Arrangement import com.varabyte.kobweb.compose.foundation.layout.Column import com.varabyte.kobweb.compose.ui.Alignment @@ -20,6 +22,7 @@ import me.luki.website.styles.AboutStyle import me.luki.website.styles.DescriptionStyle import me.luki.website.utils.toSitePalette import org.jetbrains.compose.web.css.* +import kotlin.js.Date val JumpKeyframe = Keyframes { from { Modifier.translateY(0.px) } @@ -39,7 +42,7 @@ private fun About() { modifier = Modifier .id("about") .classNames("section-container") - .height("100svh".unsafeCast()) + .height(100.svh) .fillMaxWidth(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally @@ -54,7 +57,7 @@ private fun About() { .fontFamily("Quicksand") ) SpanText( - text = "iOS developer with +3 years of experience", + text = "iOS developer with +${getYearsOfExperience()} years of experience", modifier = DescriptionStyle.toModifier() .align(Alignment.CenterHorizontally) .color(Colors.LightGray) @@ -81,3 +84,13 @@ private fun About() { } } } + +private fun getYearsOfExperience(): Int { + val startDate = Date(2020, 10, 1) + + val diffMilliseconds = Date.now() - startDate.getTime() + val millisecondsInYear = 1000 * 60 * 60 * 24 * 365.25 + val diffYears = diffMilliseconds / millisecondsInYear + + return diffYears.toInt() +}