-
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.
Move every component into a single Kotlin source file
- Loading branch information
Showing
15 changed files
with
116 additions
and
90 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...-multiplatform-material/src/commonMain/kotlin/com/huanshankeji/compose/material/Button.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,11 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
expect /*value*/ class ButtonScope { | ||
@Composable | ||
fun Label(text: String) | ||
} | ||
|
||
@Composable | ||
expect fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Unit) |
6 changes: 6 additions & 0 deletions
6
...se-multiplatform-material/src/commonMain/kotlin/com/huanshankeji/compose/material/Card.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,6 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
expect fun Card(content: @Composable () -> Unit) |
7 changes: 7 additions & 0 deletions
7
...se-multiplatform-material/src/commonMain/kotlin/com/huanshankeji/compose/material/Icon.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,7 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.huanshankeji.compose.material.icon.MaterialIcon | ||
|
||
@Composable | ||
expect fun Icon(materialIcon: MaterialIcon) |
6 changes: 6 additions & 0 deletions
6
...tiplatform-material/src/commonMain/kotlin/com/huanshankeji/compose/material/IconButton.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,6 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
expect fun IconButton(onClick: () -> Unit, content: @Composable () -> Unit) |
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
17 changes: 17 additions & 0 deletions
17
compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/Button.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,17 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import dev.petuska.kmdc.button.Label | ||
import dev.petuska.kmdc.button.MDCButton | ||
import dev.petuska.kmdc.button.MDCButtonScope | ||
import org.w3c.dom.HTMLButtonElement | ||
|
||
actual class ButtonScope(val mdcButtonScope: MDCButtonScope<HTMLButtonElement>) { | ||
@Composable | ||
actual fun Label(text: String) = | ||
mdcButtonScope.Label(text) | ||
} | ||
|
||
@Composable | ||
actual fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Unit) = | ||
MDCButton(attrs = { onClick { onClick() } }) { ButtonScope(this).content() } |
8 changes: 8 additions & 0 deletions
8
compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/Card.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,8 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import dev.petuska.kmdc.card.MDCCard | ||
|
||
@Composable | ||
actual fun Card(content: @Composable () -> Unit) = | ||
MDCCard { content() } |
12 changes: 12 additions & 0 deletions
12
compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/Icon.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,12 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.huanshankeji.compose.material.icon.MaterialIcon | ||
import dev.petuska.kmdcx.icons.MDCIconSpan | ||
|
||
/** | ||
* There is often a better alternative of adding the CSS rule to the parent element to using this composable directly. | ||
*/ | ||
@Composable | ||
actual fun Icon(materialIcon: MaterialIcon) = | ||
MDCIconSpan(materialIcon.mdcIcon) |
10 changes: 10 additions & 0 deletions
10
...-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/IconButton.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,10 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import dev.petuska.kmdc.icon.button.MDCIconButton | ||
|
||
@Composable | ||
actual fun IconButton(onClick: () -> Unit, content: @Composable () -> Unit) = | ||
MDCIconButton(attrs = { | ||
onClick { onClick() } | ||
}) { 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
14 changes: 14 additions & 0 deletions
14
...ose-multiplatform-material/src/jvmMain/kotlin/com/huanshankeji/compose/material/Button.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,14 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.runtime.Composable | ||
|
||
actual class ButtonScope(val rowScope: RowScope) { | ||
@Composable | ||
actual fun Label(text: String) = | ||
androidx.compose.material.Text(text) | ||
} | ||
|
||
@Composable | ||
actual fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Unit) = | ||
androidx.compose.material.Button(onClick) { ButtonScope(this).content() } |
7 changes: 7 additions & 0 deletions
7
compose-multiplatform-material/src/jvmMain/kotlin/com/huanshankeji/compose/material/Card.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,7 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
actual fun Card(content: @Composable () -> Unit) = | ||
androidx.compose.material.Card { content() } |
9 changes: 9 additions & 0 deletions
9
compose-multiplatform-material/src/jvmMain/kotlin/com/huanshankeji/compose/material/Icon.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,9 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.huanshankeji.compose.material.icon.MaterialIcon | ||
|
||
@Composable | ||
actual fun Icon(materialIcon: MaterialIcon) = | ||
androidx.compose.material.Icon(materialIcon, null) | ||
// no `contentDescription` for now |
7 changes: 7 additions & 0 deletions
7
...multiplatform-material/src/jvmMain/kotlin/com/huanshankeji/compose/material/IconButton.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,7 @@ | ||
package com.huanshankeji.compose.material | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
actual fun IconButton(onClick: () -> Unit, content: @Composable () -> Unit) = | ||
androidx.compose.material.IconButton(onClick = onClick, content = 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