Skip to content

Commit

Permalink
lang added & initial loading changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat992 committed Sep 7, 2024
1 parent 0ef9d95 commit 3b48e02
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
1 change: 1 addition & 0 deletions site/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ version = "1.0-SNAPSHOT"
kobweb {
app {
index {
lang.set("en")
description.set("Patrick Hettich, mobile and web development, API integration, and data integration using technologies like Flutter, Java, C#, Javascript, Azure, and Kotlin.")
head.add {
style {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package com.pat.portfolio.components._widgets.loading
import androidx.compose.runtime.Composable
import com.pat.portfolio.components._widgets.text.Subtitle
import com.pat.portfolio.core.styles.Theme
import com.pat.portfolio.observables.GithubObservable
import com.pat.portfolio.observables.RequestStatus
import com.varabyte.kobweb.compose.foundation.layout.Arrangement
import com.varabyte.kobweb.compose.foundation.layout.Box
import com.varabyte.kobweb.compose.foundation.layout.Column
import com.varabyte.kobweb.compose.ui.Alignment
import com.varabyte.kobweb.compose.ui.Modifier
import com.varabyte.kobweb.compose.ui.modifiers.*
import com.varabyte.kobweb.compose.ui.styleModifier
import org.jetbrains.compose.web.css.DisplayStyle
import org.jetbrains.compose.web.css.px
import org.jetbrains.compose.web.css.vh
import org.jetbrains.compose.web.css.vw
Expand All @@ -19,6 +22,7 @@ fun LoadingSpinner() {
Column(
modifier = Modifier
.backgroundColor(Theme.BackgroundColor.rgb)
.display(if (GithubObservable.requestStatus == RequestStatus.LOADING) DisplayStyle.Flex else DisplayStyle.None)
.fillMaxSize()
.width(100.vw)
.height(100.vh),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import com.pat.portfolio.components._widgets.MouseFollowingGradient
import com.pat.portfolio.components.indexPage.contactSection.ContactModal
import com.pat.portfolio.core.styles.Theme
import com.pat.portfolio.observables.EmailJsObservable
import com.pat.portfolio.observables.GithubObservable
import com.pat.portfolio.observables.RequestStatus
import com.varabyte.kobweb.compose.css.Overflow
import com.varabyte.kobweb.compose.foundation.layout.Box
import com.varabyte.kobweb.compose.foundation.layout.Column
import com.varabyte.kobweb.compose.ui.Alignment
import com.varabyte.kobweb.compose.ui.Modifier
import com.varabyte.kobweb.compose.ui.modifiers.*
import org.jetbrains.compose.web.css.DisplayStyle
import org.jetbrains.compose.web.css.percent
import org.jetbrains.compose.web.css.px

Expand All @@ -23,6 +25,7 @@ fun PageWrapper(
modifier = Modifier
.fillMaxSize()
.backgroundColor(Theme.BackgroundColor.rgb)
.display(if (GithubObservable.requestStatus == RequestStatus.LOADING) DisplayStyle.None else DisplayStyle.Grid)
.overflow(Overflow.Hidden),
contentAlignment = Alignment.Center
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ data object GithubObservable {
var languagesCount by mutableStateOf(0)
var languages: MutableList<GithubLanguageDto> by mutableStateOf(mutableListOf())
var requestStatus by mutableStateOf(RequestStatus.NULL)
var hasRequestSent by mutableStateOf(false)
}
51 changes: 25 additions & 26 deletions site/src/jsMain/kotlin/com/pat/portfolio/pages/Index.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun HomePage() {
ViewportDataObservable.sectionId = Section.Projects.id
}

if (GithubObservable.requestStatus != RequestStatus.SUCCESS)
if (GithubObservable.requestStatus != RequestStatus.SUCCESS && GithubObservable.requestStatus != RequestStatus.FAILURE)
githubRepositoryGetLanguages()
}

Expand All @@ -53,29 +53,28 @@ fun HomePage() {
NavigationItem(section)
}
})
if (!GithubObservable.hasRequestSent) LoadingSpinner()
else
PageWrapper {
Navigation(navigationItems = {
Section
.entries
.filter { entry ->
entry != Section.Main &&
entry != Section.Footer &&
entry != Section.Contact
}
.forEach { section ->
if (section.ordinal == (Section.entries.size) / 2)
Box()
NavigationItem(section)
}
})
MainSection()
if (GithubObservable.requestStatus == RequestStatus.SUCCESS) LanguagesSection()
ProjectsSection()
WorkSection()
EducationSection()
ContactSection()
FooterSection()
}
LoadingSpinner()
PageWrapper {
Navigation(navigationItems = {
Section
.entries
.filter { entry ->
entry != Section.Main &&
entry != Section.Footer &&
entry != Section.Contact
}
.forEach { section ->
if (section.ordinal == (Section.entries.size) / 2)
Box()
NavigationItem(section)
}
})
MainSection()
if (GithubObservable.requestStatus == RequestStatus.SUCCESS) LanguagesSection()
ProjectsSection()
WorkSection()
EducationSection()
ContactSection()
FooterSection()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ suspend fun githubRepositoryGetLanguages() {
val res = githubInfrastructureGetLanguages()
if (res == null) {
GithubObservable.requestStatus = RequestStatus.FAILURE
GithubObservable.hasRequestSent = true
return
}

Expand All @@ -23,5 +22,4 @@ suspend fun githubRepositoryGetLanguages() {
GithubObservable.languagesCount += language.count
}
GithubObservable.requestStatus = RequestStatus.SUCCESS
GithubObservable.hasRequestSent = true
}

0 comments on commit 3b48e02

Please sign in to comment.