Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
• calculate the years of experience dynamically
• no need to write the svh unit as a string & use an unsafe cast anymore since now Kobweb supports dynamic viewport units
  • Loading branch information
Luki120 committed Dec 2, 2024
1 parent a5f37b0 commit 80e80f8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions site/src/jsMain/kotlin/me/luki/website/sections/MainSection.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) }
Expand All @@ -39,7 +42,7 @@ private fun About() {
modifier = Modifier
.id("about")
.classNames("section-container")
.height("100svh".unsafeCast<CSSLengthNumericValue>())
.height(100.svh)
.fillMaxWidth(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
Expand All @@ -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)
Expand All @@ -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()
}

0 comments on commit 80e80f8

Please sign in to comment.