All Projects → mpetuska → kmdc

mpetuska / kmdc

Licence: Apache-2.0 license
Kompose wrappers for material-components-web

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to kmdc

fluid-react
Highly experimental Kotlin wrapper for React
Stars: ✭ 12 (-81.82%)
Mutual labels:  kotlin-js, kotlin-js-wrappers
kotlin-js-wrappers
Kotlin JS wrappers for popular JavaScript libraries
Stars: ✭ 48 (-27.27%)
Mutual labels:  kotlin-js-wrappers
super-github
Enhance your GitHub experience 🚀
Stars: ✭ 18 (-72.73%)
Mutual labels:  kotlin-js
mui-kotlin
Kotlin/JS support for Material-UI
Stars: ✭ 25 (-62.12%)
Mutual labels:  kotlin-js
thelema-engine
Thelema - 3D graphics engine, written in Kotlin. Based on sources of libGDX.
Stars: ✭ 51 (-22.73%)
Mutual labels:  kotlin-js
KotlinMultiplatformAndoridParcelize
Use the Parcelize Annotation of the Kotlin Android Extensions in Kotin Multiplatform projects
Stars: ✭ 16 (-75.76%)
Mutual labels:  kotlin-js
hello-kotlin-multiplatform
Multiplatform Kotlin Hello World (Android/Java/JavaScript)
Stars: ✭ 64 (-3.03%)
Mutual labels:  kotlin-js
Sheasy
This an Android App that helps you share/manage your files on your Android Device through a WebInterface in the Browser - Built with Ktor and Kotlin-React
Stars: ✭ 34 (-48.48%)
Mutual labels:  kotlin-js
Lavalink.kt
Coroutine based client for Lavalink (Kotlin and Java)
Stars: ✭ 31 (-53.03%)
Mutual labels:  kotlin-js
patternfly-fritz2
Pure Kotlin implementation of PatternFly
Stars: ✭ 31 (-53.03%)
Mutual labels:  kotlin-js
KotlinReactNativeMpp
A ReactNative App written with Kotlin JS
Stars: ✭ 26 (-60.61%)
Mutual labels:  kotlin-js
three-kt-wrapper
Kotlin wrappers for Three.js
Stars: ✭ 46 (-30.3%)
Mutual labels:  kotlin-js
kotlin-js-D3js-example
A simple example of a D3 JavaScript program in Kotlin
Stars: ✭ 13 (-80.3%)
Mutual labels:  kotlin-js
kfc-plugins
Kotlin/JS Fast Configuration
Stars: ✭ 37 (-43.94%)
Mutual labels:  kotlin-js
kfsm
Finite State Machine in Kotlin
Stars: ✭ 76 (+15.15%)
Mutual labels:  kotlin-js
tmdb-api
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.
Stars: ✭ 31 (-53.03%)
Mutual labels:  kotlin-js
Maily-Form
Forms on any website
Stars: ✭ 29 (-56.06%)
Mutual labels:  kotlin-js
npm-publish
Gradle plugin for NPM package publishing. Allows for arbitrary publishing as well as seamless integration with Kotlin JS/MPP plugins.
Stars: ✭ 66 (+0%)
Mutual labels:  kotlin-js
ktcc
C Compiler that generates readable Kotlin and C# - Written in Kotlin + Small web-based Editor with autocompletion
Stars: ✭ 54 (-18.18%)
Mutual labels:  kotlin-js
kotlin-telegram
Repository with information about Kotlin chats on Telegram.
Stars: ✭ 21 (-68.18%)
Mutual labels:  kotlin-js

Slack chat Dokka docs Version maven-central

Kompose Material Design Components (KMDC)

The library is currently very experimental with no API stability guarantees. Breaking changes are being introduced each release.

A set of Kotlin wrappers over [email protected] library providing Jetbrains Compose DSL for building beautiful WEB UIs. The API surface is identical to JS version, except for few places where slight adjustments are made to make it more fluid for compose.

Setup

KMDC wraps each MDC module 1:1 and as such allows you to pick and choose which exact components you'd like to use. This is recommended approach as it helps in reducing bundle size. However, for the lazy ones out there, a "shortcut" module is also available, which brings in all KMDC modules as transitive dependencies under a single dependency.

Either approach can be installed by declaring relevant dependencies in your jsMain sourceSet.

Additionally, you need to enable SCSS support. This is done by adding required npm dev dependencies to your sourceSet and then enabling them via webpack.config.d/scss.js file.

plugins {
  kotlin("multiplatform")
  id("org.jetbrains.compose")
}
kotlin {
  sourceSets {
    named("jsMain") {
      dependencies {
        // Be lazy and use the shortcut
        implementation("dev.petuska:kmdc:_")
        implementation("dev.petuska:kmdcx:_")

        // Do some work and see dem gains
        implementation("dev.petuska:kmdc-button:_")
        implementation("dev.petuska:kmdc-radio:_")
        implementation("dev.petuska:kmdcx-icons:_")

        // SCSS dependencies
        implementation(devNpm("style-loader", "^3.3.1"))
        implementation(devNpm("css-loader", "^6.7.1"))
        implementation(devNpm("sass-loader", "^13.0.0"))
        implementation(devNpm("sass", "^1.52.1"))
      }
    }
  }
}

Usage

Most of the API maps closely to MDC JS API, making all examples there semi-valid. KMDC components follow a specific naming convention to make its components more discoverable as well. The convention is MDC[UpperCamelCaseMDCComponentName] (e.g. MDCTopAppBar) for the top-level component and UpperCamelCaseLogicalName for all subcomponents. Most of the components also follow the same argument order schema:

  1. ...requiredMdcOptions - MDC-specific options with no default values
  2. ...optionalMdcOptions - MDC-specific options with default values 3attrs: (AttrsBuilder<out HTMLElement>.() -> Unit)? = null - compose attributes builder for the underlying HTML element 4content: (ComposableBuilder<out HTMLElement>.() -> Unit)? = null - compose inner content builder for the underlying HTML element

Here's a quick peek how these things come together (more showcases can be found in the sandbox)

@Composable
fun Showcase() {
  var checked by remember { mutableStateOf(false) } // Declaring controlled state

  MDCFormField { // Using implicit `content` argument to wrap MDCCheckbox inside MDCFormField UI as recommended by the MDC docs
    MDCCheckbox(
      checked = checked,
      label = "Yes/No",
      attrs = { // Overriding underlying HTMLInput element attributes
        onInput { checked = !checked }
      }
    ) // MDCCheckbox doesn't allow for additional inner content
  }
}

Progress

Here's a tracker list of currently completed material-components-web modules:

  • kmdc-animation (SASS)
  • kmdc-auto-init (won't wrap)
  • kmdc-banner
  • kmdc-base (won't wrap)
  • kmdc-button
  • kmdc-card
  • kmdc-checkbox
  • kmdc-chips
  • kmdc-circular-progress
  • kmdc-data-table
  • kmdc-density (won't wrap)
  • kmdc-dialog
  • kmdc-dom (won't wrap)
  • kmdc-drawer
  • kmdc-elevation
  • kmdc-fab
  • kmdc-feature-targeting (won't wrap)
  • kmdc-floating-label
  • kmdc-form-field
  • kmdc-icon-button
  • kmdc-image-list
  • kmdc-layout-grid
  • kmdc-line-ripple
  • kmdc-linear-progress
  • kmdc-list
  • kmdc-menu-surface
  • kmdc-menu
  • kmdc-notched-outline
  • kmdc-progress-indicator (won't wrap)
  • kmdc-radio
  • kmdc-ripple
  • kmdc-rtl (SASS)
  • kmdc-segmented-button
  • kmdc-select
  • kmdc-shape (SASS)
  • kmdc-slider
  • kmdc-snackbar
  • kmdc-switch
  • kmdc-tab-bar
  • kmdc-tab-indicator
  • kmdc-tab-scroller
  • kmdc-tab
  • kmdc-textfield
  • kmdc-theme (SASS)
  • kmdc-tokens (won't wrap)
  • kmdc-tooltip
  • kmdc-top-app-bar
  • kmdc-touch-target
  • kmdc-typography

Other libraries and extensions:

  • kmdc-icons

Module Structure

KMDC project modules can be categorised into three groups:

  • Core MDC wrappers - grouped under ./kmdc meta-module
  • Extensions of core wrappers or relevant non-kmdc wrappers - grouped under ./kmdcx meta-module

Developer Setup

  • Install JDK 11+
  • Run ./gradlew assemble to build js binaries
  • Use ./sandbox/ to render components in browser (needs to be linked separately in IDEA)
    • ./gradlew jsBrowserRun -t to start development server
    • Visit http://localhost:3000 to see your content
    • If you're adding a new component, render it by creating Showcases file for it
    • Thanks to gradle continuous mode, any change in kmdc modules will trigger automatic refresh of sandbox and the browser. It takes a few seconds after you save your changes, so be patient.

Further details can be found in Contributing Guidelines

Contributing

All contributions are welcome. Have a look for a good first issue in the issue tracker, or open your own issue if you have some ideas. If you want to chat, either start a discussion or ping me on slack.

Further details can be found in Contributing Guidelines

Thanks to all the people who contributed to kmdc so far!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].