-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from m3dev/feat/responsive-and-style-refactor
トリ急ぎレスポンシブ対応と、スタイル情報を別ファイルに分離・トップページのトリを追加
- Loading branch information
Showing
40 changed files
with
532 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import androidx.compose.runtime.* | ||
import components.pages.QuizPage | ||
import components.pages.ResultPage | ||
import components.pages.TopPage | ||
import core.ComposeQuiz | ||
import core.ComposeResult | ||
import core.Quiz | ||
import core.Result | ||
import kotlinx.browser.window | ||
|
||
@Composable | ||
fun App() { | ||
var currentPage by remember { mutableStateOf(Page.TOP) } | ||
val quiz: Quiz by remember { mutableStateOf(ComposeQuiz()) } | ||
val result: Result by remember { mutableStateOf(ComposeResult()) } | ||
|
||
if (window.location.pathname in listOf("/", "")) { | ||
when (currentPage) { | ||
Page.TOP -> { | ||
TopPage( | ||
onClickStart = { currentPage = Page.QUIZ } | ||
) | ||
} | ||
Page.QUIZ -> { | ||
QuizPage(quiz = quiz) | ||
} | ||
} | ||
} else { | ||
ResultPage( | ||
diagnosis = result.getDiagnosis(window.location.pathname), | ||
onClickBack = { | ||
quiz.reset() | ||
window.location.pathname = "/" | ||
} | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,15 @@ | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import components.pages.QuizPage | ||
import components.pages.ResultPage | ||
import components.pages.TopPage | ||
import core.ComposeQuiz | ||
import core.ComposeResult | ||
import core.Quiz | ||
import core.Result | ||
import org.jetbrains.compose.web.css.Style | ||
import org.jetbrains.compose.web.renderComposable | ||
import style.GlobalStyle | ||
|
||
enum class Page { | ||
TOP, | ||
QUIZ, | ||
RESULT | ||
QUIZ | ||
} | ||
|
||
fun main() { | ||
renderComposable(rootElementId = "root") { | ||
var resultId by remember { mutableStateOf(0) } | ||
var currentPage by remember { mutableStateOf(Page.TOP) } | ||
val quiz: Quiz by remember { mutableStateOf(ComposeQuiz()) } | ||
val result: Result by remember { mutableStateOf(ComposeResult()) } | ||
|
||
when (currentPage) { | ||
Page.TOP -> TopPage( | ||
onClickStart = { currentPage = Page.QUIZ } | ||
) | ||
|
||
Page.QUIZ -> QuizPage( | ||
quiz = quiz, | ||
onClickFinish = { nextId: Int -> | ||
resultId = nextId | ||
currentPage = Page.RESULT | ||
} | ||
) | ||
|
||
Page.RESULT -> ResultPage( | ||
diagnosis = result.getDiagnosis(resultId), | ||
onClickBack = { | ||
quiz.reset() | ||
resultId = 0 | ||
currentPage = Page.TOP | ||
} | ||
) | ||
} | ||
|
||
Style(GlobalStyle) | ||
App() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
torisetsu/src/jsMain/kotlin/components/base/ButtonStyle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package components.base | ||
|
||
import org.jetbrains.compose.web.css.* | ||
import style.GlobalStyle | ||
import style.data | ||
import style.forMobile | ||
|
||
object ButtonStyle : StyleSheet(GlobalStyle) { | ||
val rootElm by style { | ||
data("size", "normal") { | ||
padding(16.px, 36.px) | ||
borderRadius(16.px) | ||
fontSize(32.px) | ||
} | ||
|
||
|
||
data("size", "large") { | ||
padding(40.px, 100.px) | ||
borderRadius(40.px) | ||
fontSize(60.px) | ||
} | ||
|
||
forMobile { | ||
data("size", "normal") { | ||
padding(16.px, 36.px) | ||
borderRadius(12.px) | ||
fontSize(24.px) | ||
} | ||
|
||
data("size", "large") { | ||
padding(20.px, 50.px) | ||
borderRadius(20.px) | ||
fontSize(32.px) | ||
} | ||
} | ||
|
||
backgroundImage("linear-gradient(#5772FF, #0054DD)") | ||
color(Color.white) | ||
fontWeight(700) | ||
property( | ||
"box-shadow", | ||
"0px 5.13px 5.13px 0px #F9F7F340 inset, 0px -5.13px 5.13px 0px #00000040 inset" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
package components.base | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.jetbrains.compose.web.css.* | ||
import org.jetbrains.compose.web.dom.Div | ||
|
||
@Composable | ||
fun Card( | ||
content: @Composable() () -> Unit | ||
) { | ||
Div( | ||
attrs = { | ||
style { | ||
padding(32.px) | ||
backgroundColor(rgb(255, 255, 255)) | ||
borderRadius(16.px) | ||
property("box-shadow", "0px 4px 4px rgba(0, 0, 0, 0.25), 0px 8px 6px rgba(0, 0, 0, 0.10)") | ||
|
||
} | ||
} | ||
) { | ||
Div(attrs = { classes(CardStyle.rootElm) }) { | ||
content() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package components.base | ||
|
||
import org.jetbrains.compose.web.css.* | ||
import style.GlobalStyle | ||
import style.forMobile | ||
|
||
object CardStyle : StyleSheet(GlobalStyle) { | ||
val rootElm by style { | ||
padding(32.px) | ||
backgroundColor(rgb(255, 255, 255)) | ||
borderRadius(16.px) | ||
property("box-shadow", "0px 4px 4px rgba(0, 0, 0, 0.25), 0px 8px 6px rgba(0, 0, 0, 0.10)") | ||
|
||
forMobile { | ||
padding(24.px) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
torisetsu/src/jsMain/kotlin/components/base/PageLayoutStyle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package components.base | ||
|
||
import org.jetbrains.compose.web.css.* | ||
import style.GlobalStyle | ||
|
||
object PageLayoutStyle : StyleSheet(GlobalStyle) { | ||
val rootElm by style { | ||
padding(32.px, 24.px) | ||
display(DisplayStyle.Flex) | ||
flexDirection(FlexDirection.Column) | ||
alignItems(AlignItems.Center) | ||
} | ||
val wrapper by style { | ||
width(649.px) | ||
maxWidth(100.percent) | ||
display(DisplayStyle.Flex) | ||
alignItems(AlignItems.Center) | ||
flexDirection(FlexDirection.Column) | ||
} | ||
val header by style { | ||
display(DisplayStyle.Flex) | ||
flexDirection(FlexDirection.Row) | ||
gap(60.px) | ||
} | ||
val titleLogo by style { | ||
width(150.px) | ||
} | ||
val m3Logo by style { | ||
width(160.px) | ||
} | ||
val main by style { | ||
marginTop(40.px) | ||
width(100.percent) | ||
} | ||
} |
Oops, something went wrong.