Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
v0.4.0 release
  • Loading branch information
ShreckYe committed Oct 19, 2024
2 parents 066bcf0 + 9b17a39 commit 46f233c
Show file tree
Hide file tree
Showing 23 changed files with 627 additions and 252 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.gradle
.kotlin
build
.idea
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Material 3 wrapper components for Compose HTML based on [Material Web](https://github.com/material-components/material-web)

For unified multiplatform APIs which are more akin to those in `androidx.compose`, check out [Compose Multiplatform Material](https://github.com/huanshankeji/compose-multiplatform-material).
For unified multiplatform APIs which are more akin to those in `androidx.compose`, check out [Compose Multiplatform Material](https://github.com/huanshankeji/compose-multiplatform-material) which also depends on this library.

For Material 2 support, you are recommended to check out [KMDC](https://github.com/mpetuska/kmdc) instead. For information on our obsolete work on legacy Material 2 components, check out [the legacy README](/legacy/README.md).

Expand All @@ -20,6 +20,8 @@ Here is a list of supported compoent APIs:
- `MdIcon`
- `MdIconButton`, `MdFilledIconButton`, `MdFilledTonalIconButton`, `MdOutlinedIconButton`
- `MdList`, `MdListItem`
- `MdMenu`, `MdMenuItem`, `MdSubMenu`
- `MdLinearProgress`, `MdCircularProgress`
- `MdSwitch`, `LabelWithMdSwitch`
- `MdFilledTextField`, `MdOutlinedTextField`

Expand Down Expand Up @@ -52,6 +54,15 @@ kotlin {
}
```

This project depends on [Kobweb](https://github.com/varabyte/kobweb) which is not published to Maven Central yet, so you have to add the following Maven repository:

```kotlin
repositories {
mavenCentral()
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public")
}
```

### Material Symbols & Icons

The Material 3 module uses [Material Symbols & Icons](https://fonts.google.com/icons), but doesn't depend on the stylesheet directly. For Material Icons to work properly, you may need to configure your project following the quick instructions below or [the developer guide](https://developers.google.com/fonts/docs/material_symbols).
Expand Down
14 changes: 8 additions & 6 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ plugins {
`kotlin-dsl`
}
repositories {
//mavenLocal()
mavenLocal() // TODO comment out when not needed
gradlePluginPortal()
//maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

val huanshankejiGradlePluginsVersion = "0.5.1"

dependencies {
implementation(kotlin("gradle-plugin", "1.9.23"))
implementation("org.jetbrains.compose:compose-gradle-plugin:1.6.2")
// With Kotlin 2.0.20, a "Could not parse POM" build error occurs in the JVM projects of some dependent projects.
val kotlinVersion = "2.0.10"
implementation(kotlin("gradle-plugin", kotlinVersion))
implementation("org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.compose:compose-gradle-plugin:1.7.0")
val huanshankejiGradlePluginsVersion = "0.6.0" // don't use a snapshot version in a main branch
implementation("com.huanshankeji:kotlin-common-gradle-plugins:$huanshankejiGradlePluginsVersion")
implementation("com.huanshankeji.team:gradle-plugins:$huanshankejiGradlePluginsVersion")
implementation("com.huanshankeji:common-gradle-dependencies:0.7.1-20240314")
implementation("com.huanshankeji:common-gradle-dependencies:0.8.0-20241016") // don't use a snapshot version in a main branch
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/VersionsAndDependencies.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import com.huanshankeji.CommonDependencies

const val projectVersion = "0.3.0"
const val projectVersion = "0.4.0"

object DependencyVersions {
val kobweb = "0.17.3"
val materialWeb = "1.4.1"
val kobweb = "0.19.2"
val materialWeb = "2.2.0"


// legacy versions that don't need to be updated
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
id("com.huanshankeji.kotlin-multiplatform-js-browser-conventions")
kotlin("plugin.compose")
id("org.jetbrains.compose")
id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions")
}

repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb
}

group = "com.huanshankeji"
version = projectVersion
13 changes: 2 additions & 11 deletions buildSrc/src/main/kotlin/lib-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
plugins {
id("com.huanshankeji.kotlin-multiplatform-js-browser-conventions")
id("org.jetbrains.compose")
id("lib-conventions-without-publishing")
id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions")
}

repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb
}

group = "com.huanshankeji"
version = projectVersion
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ fun AttrsScope<*>.attr(attr: String, value: Boolean = true) =
fun AttrsScope<*>.attr(attr: String, value: Int) =
attr(attr, value.toString())

fun AttrsScope<*>.attr(attr: String, value: Number) =
attr(attr, value.toString())

/**
* Adds an attribute that has an explicit [Boolean] value unlike [attr].
*/
Expand All @@ -34,6 +37,10 @@ fun AttrsScope<*>.attrIfNotNull(attr: String, value: Int?) {
value?.let { attr(attr, it) }
}

fun AttrsScope<*>.attrIfNotNull(attr: String, value: Number?) {
value?.let { attr(attr, it) }
}


// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/slot
fun AttrsScope<*>.slot(value: String) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ fun AttrsScope<*>.ariaLabel(value: String) =

// https://www.w3schools.com/tags/att_disabled.asp
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
fun AttrsScope<*>.disabled(disabled: Boolean?) {
disabled?.let { disabled(it) }
}
fun AttrsScope<*>.disabled(value: Boolean?) =
attrIfNotNull("disabled", value)

// https://www.w3schools.com/tags/att_href.asp
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href
Expand Down Expand Up @@ -140,5 +139,6 @@ fun AttrsScope<*>.enterKeyHintIfValid(value: String) {
}


// https://www.w3schools.com/tags/att_selected.asp
fun AttrsScope<*>.selected(value: Boolean?) =
attrIfNotNull("selected", value)
2 changes: 1 addition & 1 deletion compose-html-material-legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.huanshankeji.team.`Shreck Ye`
import com.huanshankeji.team.pomForTeamDefaultOpenSource

plugins {
`lib-conventions`
`lib-conventions-without-publishing`
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.huanshankeji.compose.html.material3

import androidx.compose.runtime.Composable
import com.huanshankeji.compose.html.material3.attributes.indeterminate
import com.huanshankeji.compose.web.attributes.Attrs
import com.huanshankeji.compose.web.attributes.attr
import com.huanshankeji.compose.web.attributes.ext.*
Expand Down Expand Up @@ -29,7 +30,7 @@ fun MdCheckbox(
attr("touch-target", "wrapper")
checked?.let { attr("checked", it) }
disabled(disabled)
indeterminate?.let { attr("indeterminate", it) }
indeterminate(indeterminate)
required(required)
value(value)
name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ https://material-web.dev/components/fab/
https://material-web.dev/components/fab/stories/
*/

// a workaround for probably a bug, needed since Kotlin 2.0.0 because of "Cannot infer type for this parameter. Please specify it explicitly."
private fun (@Composable MdFabScope.() -> Unit).toHTMLElementContent(): @Composable ElementScope<HTMLElement>.() -> Unit =
{ MdFabScope(this).this@toHTMLElementContent() }

@Composable
private fun CommonMdFab(
tagName: String,
Expand All @@ -33,9 +37,7 @@ private fun CommonMdFab(
lowered?.let { attr("lowered", it) }

attrs?.invoke(this)
}, content?.let {
{ MdFabScope(this).it() }
})
}, content?.toHTMLElementContent())

@Composable
fun MdFab(
Expand Down
Loading

0 comments on commit 46f233c

Please sign in to comment.