-
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.
v0.2.0 release
- Loading branch information
Showing
30 changed files
with
446 additions
and
426 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
//mavenLocal() | ||
gradlePluginPortal() | ||
//maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("gradle-plugin", "1.7.20")) | ||
implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.1") | ||
implementation("com.huanshankeji:kotlin-common-gradle-plugins:0.3.2") | ||
implementation("com.huanshankeji.team:gradle-plugins:0.3.2") | ||
} |
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,26 @@ | ||
import com.huanshankeji.team.`Shreck Ye` | ||
import com.huanshankeji.team.pomForTeamDefaultOpenSource | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.tasks.bundling.Jar | ||
import org.gradle.kotlin.dsl.* | ||
|
||
plugins { | ||
id("com.huanshankeji.kotlin-multiplatform-js-browser-conventions") | ||
id("org.jetbrains.compose") | ||
id("com.huanshankeji.sonatype-ossrh-publish") | ||
} | ||
|
||
repositories { | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
|
||
group = "com.huanshankeji" | ||
version = projectVersion | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
publishing.publications.withType<MavenPublication> { | ||
artifact(javadocJar) | ||
} |
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,23 @@ | ||
import com.huanshankeji.team.`Shreck Ye` | ||
import com.huanshankeji.team.pomForTeamDefaultOpenSource | ||
|
||
plugins { | ||
`lib-conventions` | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val jsMain by getting { | ||
dependencies { | ||
implementation(compose.web.core) | ||
implementation(compose.runtime) | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishing.publications.withType<MavenPublication> { | ||
pomForTeamDefaultOpenSource(project, "Huanshankeji Compose for Web common", "Huanshankeji's common code for Compose for Web") { | ||
`Shreck Ye`() | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
compose-web-common/src/jsMain/kotlin/com/huanshankeji/compose/web/Layouts.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,156 @@ | ||
package com.huanshankeji.compose.web | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.huanshankeji.compose.web.attributes.attrs | ||
import com.huanshankeji.compose.web.attributes.plus | ||
import com.huanshankeji.compose.web.css.FIT_CONTENT | ||
import com.huanshankeji.compose.web.css.Styles | ||
import com.huanshankeji.compose.web.css.width | ||
import com.huanshankeji.compose.web.css.wrapInAttrs | ||
import org.jetbrains.compose.web.css.* | ||
import org.jetbrains.compose.web.dom.AttrBuilderContext | ||
import org.jetbrains.compose.web.dom.ContentBuilder | ||
import org.jetbrains.compose.web.dom.Div | ||
import org.w3c.dom.HTMLDivElement | ||
|
||
// try to follow names in Android Jetpack Compose | ||
|
||
@Composable | ||
fun Flexbox( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Div(attrs<HTMLDivElement> { | ||
style { | ||
display(DisplayStyle.Flex) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun Flexbox(styles: Styles? = null, content: ContentBuilder<HTMLDivElement>) = | ||
Flexbox(styles.wrapInAttrs(), content) | ||
|
||
@Composable | ||
fun Column( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
fitContent: Boolean = true, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Flexbox(attrs<HTMLDivElement> { | ||
style { | ||
flexDirection(FlexDirection.Column) | ||
if (fitContent) width(FIT_CONTENT) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun Column(styles: Styles? = null, fitContent: Boolean = true, content: ContentBuilder<HTMLDivElement>) = | ||
Column(styles.wrapInAttrs(), fitContent, content) | ||
|
||
@Composable | ||
fun ColumnWithSpaceBetween( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
fitContent: Boolean = true, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Column(attrs<HTMLDivElement> { | ||
style { | ||
justifyContent(JustifyContent.SpaceBetween) | ||
} | ||
} + attrs, fitContent, content) | ||
|
||
|
||
@Composable | ||
fun Row( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Flexbox(attrs<HTMLDivElement> { | ||
style { | ||
flexDirection(FlexDirection.Row) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun Row( | ||
styles: Styles? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Row(styles.wrapInAttrs(), content) | ||
|
||
@Composable | ||
fun RowWithSpaceBetween( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Row(attrs<HTMLDivElement> { | ||
style { | ||
justifyContent(JustifyContent.SpaceBetween) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun ColumnWithGaps( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
gap: CSSNumeric, | ||
fitContent: Boolean = true, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Column(attrs<HTMLDivElement> { | ||
style { | ||
gap(gap) | ||
} | ||
} + attrs, fitContent, content) | ||
|
||
@Composable | ||
fun RowWithGaps( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
gap: CSSNumeric, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Row(attrs<HTMLDivElement> { | ||
style { | ||
gap(gap) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun Centered( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Flexbox(attrs<HTMLDivElement> { | ||
style { | ||
alignItems(AlignItems.Center) | ||
justifyContent(JustifyContent.Center) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun CenteredInViewport( | ||
attrs: AttrBuilderContext<HTMLDivElement>? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
Centered(attrs<HTMLDivElement> { | ||
style { | ||
minHeight(100.vh) | ||
} | ||
} + attrs, content) | ||
|
||
@Composable | ||
fun FrGrid( | ||
numColumns: Int, | ||
gap: CSSNumeric, | ||
content: HTMLElementContent | ||
) = | ||
Div({ | ||
style { | ||
display(DisplayStyle.Grid) | ||
gridTemplateColumns("repeat($numColumns, 1fr)") | ||
gap(gap) | ||
} | ||
}, content) | ||
|
||
@Composable | ||
fun Spacer(numPxs: Int) = | ||
TODO() as Unit |
File renamed without changes.
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
18 changes: 18 additions & 0 deletions
18
...eb-common/src/jsMain/kotlin/com/huanshankeji/compose/web/attributes/AttrBuilderContext.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,18 @@ | ||
package com.huanshankeji.compose.web.attributes | ||
|
||
import org.jetbrains.compose.web.dom.AttrBuilderContext | ||
import org.w3c.dom.Element | ||
|
||
operator fun <TElement : Element> AttrBuilderContext<TElement>.plus(other: AttrBuilderContext<TElement>?): AttrBuilderContext<TElement> = | ||
if (other === null) this | ||
else { | ||
{ | ||
this@plus() | ||
other() | ||
} | ||
} | ||
|
||
/** A helper function to create [AttrBuilderContext]s where type inference doesn't work */ | ||
@Suppress("NOTHING_TO_INLINE") | ||
inline fun <TElement : Element> attrs(noinline attrs: AttrBuilderContext<TElement>) = | ||
attrs |
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
compose-web-common/src/jsMain/kotlin/com/huanshankeji/compose/web/css/StyleScope.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.web.css | ||
|
||
import org.jetbrains.compose.web.css.StyleScope | ||
|
||
fun StyleScope.width(value: String) = | ||
property("width", value) | ||
|
||
fun StyleScope.height(value: String) = | ||
property("height", value) | ||
|
||
const val FIT_CONTENT = "fit-content" |
10 changes: 10 additions & 0 deletions
10
compose-web-common/src/jsMain/kotlin/com/huanshankeji/compose/web/css/Styles.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.web.css | ||
|
||
import org.jetbrains.compose.web.css.StyleScope | ||
import org.jetbrains.compose.web.dom.AttrBuilderContext | ||
import org.w3c.dom.Element | ||
|
||
typealias Styles = StyleScope.() -> Unit | ||
|
||
fun <TElement : Element> Styles?.wrapInAttrs(): AttrBuilderContext<TElement>? = | ||
this?.let { { style { it() } } } |
File renamed without changes.
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 @@ | ||
import com.huanshankeji.team.`Shreck Ye` | ||
import com.huanshankeji.team.pomForTeamDefaultOpenSource | ||
|
||
plugins { | ||
`lib-conventions` | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val jsMain by getting { | ||
dependencies { | ||
implementation(compose.web.core) | ||
implementation(compose.runtime) | ||
implementation(project(":compose-web-common")) | ||
|
||
implementation(npm("@webcomponents/webcomponentsjs", DependencyVersions.webcomponents)) | ||
|
||
fun mwcImplementation(module: String) = | ||
implementation(npm("@material/mwc-$module", DependencyVersions.mwc)) | ||
|
||
fun mwcImplementations(vararg modules: String) { | ||
for (module in modules) mwcImplementation(module) | ||
} | ||
|
||
mwcImplementations( | ||
"button", | ||
"textfield", | ||
"select", | ||
"icon-button", | ||
"snackbar", | ||
"circular-progress", | ||
"circular-progress-four-color" | ||
) | ||
|
||
implementation(npm("@material/card", DependencyVersions.mdc)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishing.publications.withType<MavenPublication> { | ||
pomForTeamDefaultOpenSource(project, "Compose for Web Material", "Some Material components for Compose for Web") { | ||
`Shreck Ye`() | ||
} | ||
} |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
compose-web-material/src/jsMain/kotlin/com/huanshankeji/compose/web/material/Layouts.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,18 @@ | ||
package com.huanshankeji.compose.web.material | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.huanshankeji.compose.web.CenteredInViewport | ||
import com.huanshankeji.compose.web.css.Styles | ||
import org.jetbrains.compose.web.attributes.AttrsScope | ||
import org.jetbrains.compose.web.dom.ContentBuilder | ||
import org.w3c.dom.HTMLDivElement | ||
|
||
@Composable | ||
fun CenteredCardInViewport( | ||
viewportDivStyles: Styles? = null, | ||
cardAttrs: (AttrsScope<HTMLDivElement>.() -> Unit)? = null, | ||
content: ContentBuilder<HTMLDivElement> | ||
) = | ||
CenteredInViewport({ viewportDivStyles?.let { style { it() } } }) { | ||
MdcCard(cardAttrs, content = content) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.