@@ -2,6 +2,10 @@ import androidx.compose.runtime.getValue
2
2
import androidx.compose.runtime.mutableStateOf
3
3
import androidx.compose.runtime.remember
4
4
import androidx.compose.runtime.setValue
5
+ import common.BaseStyles
6
+ import common.Theme
7
+ import common.ThemeProvider
8
+ import common.ThemeVariables
5
9
import components.Layout
6
10
import components.PageContent
7
11
import components.PageFooter
@@ -11,23 +15,21 @@ import org.jetbrains.compose.web.css.Style
11
15
import org.jetbrains.compose.web.dom.*
12
16
import org.jetbrains.compose.web.renderComposableInBody
13
17
14
- enum class Theme { Dark , Light }
15
-
16
18
fun main () {
17
19
renderComposableInBody {
18
- var theme by remember { mutableStateOf(Theme .Light ) }
19
20
Style {
20
21
root {
21
- when (theme) {
22
+ when (ThemeProvider . theme) {
22
23
Theme .Light -> {
23
- ThemeVariables .mainColor(Color (" #333 " ))
24
- ThemeVariables .accentColor(Color (" #6200ea " ))
25
- ThemeVariables .backgroundColor(Color (" #f0f0f0 " ))
24
+ ThemeVariables .mainColor(Color (" #201e1f " ))
25
+ ThemeVariables .accentColor(Color (" #1d7874 " ))
26
+ ThemeVariables .backgroundColor(Color (" #F8F4E3 " ))
26
27
}
28
+
27
29
Theme .Dark -> {
28
- ThemeVariables .mainColor(Color (" #f0f0f0 " ))
29
- ThemeVariables .accentColor(Color (" #6200ea " ))
30
- ThemeVariables .backgroundColor(Color (" #333 " ))
30
+ ThemeVariables .mainColor(Color (" #F8F4E3 " ))
31
+ ThemeVariables .accentColor(Color (" #1d7874 " ))
32
+ ThemeVariables .backgroundColor(Color (" #201e1f " ))
31
33
}
32
34
}
33
35
}
@@ -39,15 +41,8 @@ fun main() {
39
41
PageHeader {
40
42
H1 { Text (" My delicious site" ) }
41
43
Div {
42
- Button (attrs = {
43
- onClick {
44
- theme = when (theme) {
45
- Theme .Light -> Theme .Dark
46
- Theme .Dark -> Theme .Light
47
- }
48
- }
49
- }) {
50
- Text (" Switch theme" )
44
+ components.Button (" Switch theme" ) {
45
+ ThemeProvider .theme = ThemeProvider .theme.opposite
51
46
}
52
47
}
53
48
}
@@ -58,14 +53,8 @@ fun main() {
58
53
}
59
54
Div {
60
55
Span {
61
- Button (
62
- attrs = {
63
- onClick {
64
- counter++
65
- }
66
- },
67
- ) {
68
- Text (" Increment" )
56
+ components.Button (" Increment" ) {
57
+ counter++
69
58
}
70
59
}
71
60
}
0 commit comments