Skip to content

Commit

Permalink
Merge branch 'main' into renovate/kotlin-ksp-and-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
twyatt authored Feb 17, 2024
2 parents f8927a7 + d7853c6 commit 811e143
Show file tree
Hide file tree
Showing 46 changed files with 2,539 additions and 101 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ ktlint_standard_property-naming = disabled
# `string-template-indent` is disabled because it depends on `multiline-expression-wrapping`.
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_string-template-indent = disabled

[sample/**/*.{kt,kts}]
ktlint_standard_no-multi-spaces = disabled

# `if-else-wrapping` is disabled because it depends on `discouraged-comment-location`.
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_if-else-wrapping = disabled
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ jobs:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/wrapper-validation-action@v2

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: assemble
uses: gradle/gradle-build-action@v2
with:
Expand All @@ -33,7 +39,7 @@ jobs:
junit_files: '**/build/test-results/**/*.xml'
report_individual_runs: 'true'

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4

- name: publishToMavenLocal
if: github.repository_owner == 'JuulLabs'
Expand All @@ -44,3 +50,8 @@ jobs:
-PsigningInMemoryKey=${{ secrets.SIGNING_KEY }}
-PsigningInMemoryKeyPassword=${{ secrets.SIGNING_PASSWORD }}
publishToMavenLocal
- name: Website
uses: gradle/gradle-build-action@v2
with:
arguments: :website:browserBuild
27 changes: 22 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,43 @@ on:
branches:
- main

permissions:
contents: write
pages: write
id-token: write

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
JEKYLL_ENV: production

jobs:
deploy:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/wrapper-validation-action@v2

- uses: actions/configure-pages@v4
id: pages

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: dokkaHtmlMultiModule
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Website
uses: gradle/gradle-build-action@v2
with:
cache-read-only: true
arguments: dokkaHtmlMultiModule
arguments: |
-Pbaseurl=${{ steps.pages.outputs.base_path }}
:website:browserBuild
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/gh-pages
folder: website/_site
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 2 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![badge][badge-android]
![badge][badge-ios]
![badge][badge-js]
![badge][badge-jvm]
[![codecov](https://codecov.io/gh/JuulLabs/krayon/branch/main/graph/badge.svg?token=y8btx3pTlr)](https://codecov.io/gh/JuulLabs/krayon)
Expand All @@ -7,42 +8,7 @@

Multiplatform drawing library. Provides a multiplatform canvas and chart rendering framework.

## Modules

### Aggregate Modules

| Module | Description |
|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`box`](box) | Module exporting all other published modules (except `compose`). Useful for getting started quickly if your builds include dead-code elimination. Also includes some cross-module extensions. |
| [`sample`](sample) (unpublished) | Sample application showing use of the library with common drawing code and logic across Android and JS targets. |

### Low Level Modules

These modules provide an unopinionated multiplatform experience with simple, low-level primitives. Drawing with a Krayon
`Kanvas` should feel very similar to drawing directly to an Android `Canvas` or HTML/JS `CanvasRenderingContext2D`.

| Module | Description |
|--------------------|----------------------------------------------------------------------------------------------------|
| [`color`](color) | Multiplatform color representation and operations. |
| [`kanvas`](kanvas) | `Kanvas` interface with platform specific (Android, HTML) and multiplatform (SVG) implementations. |

### High Level Modules

These modules provide functionality heavily inspired by, and often directly translated from, D3. Many of the modules aim
to provide a 1-to-1 mapping with a D3 library, such as `axis` or `selection`. Other modules, like `element`, attempt to
fill in gaps required to support this, like `Element` being used instead of the DOM to enable non-web targets.

| Module | Description |
|--------------------------------|----------------------------------------------------------------------------------------------|
| [`axis`](axis) | Component for rendering reference marks as part of a chart. |
| [`color`](color) | Multiplatform color representation and operations. |
| [`compose`](compose) | Compose Multiplatform `Kanvas` and `ElementView` composables. Not included in `box`. |
| [`element`](element) | `Element` class used to provide an mutable object-tree of drawing operation. |
| [`element-view`](element-view) | Android specific `View` for rendering an `Element` off the main thread. |
| [`interpolate`](interpolate) | Functionality for blending/picking values between start and stop values. |
| [`kanvas`](kanvas) | Unopinionated canvas with platform specific (Android, HTML) and multiplatform (SVG) targets. |
| [`selection`](selection) | Data-driven transformation of the `Element`-tree. |
| [`shape`](shape) | Visualization support for generating complex shapes from data, such as line charts. |
See the [project website](https://juullabs.github.io/krayon/) for documentation and APIs.

# License

Expand Down
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ allprojects {
}
}

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(buildDir.resolve("gh-pages"))
}

// Remove this when we can update Kotlin/Compose to something that doesn't need the M1 workaround.
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[versions]
agp = "8.2.0" # 7.4.1 is the maximum version supported by IDEA 2023.1
agp = "8.2.2" # 7.4.1 is the maximum version supported by IDEA 2023.1
android-compile = "34"
android-min = "21"
android-target = "32"
compose = "1.5.11"
coroutines = "1.7.3"
compose = "1.5.12"
coroutines = "1.8.0"
jacoco = "0.8.7"
jvm-toolchain = "11"
kotlin = "1.9.22"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.8.2" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.6.2" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.7.0" }
androidx-test = { module = "androidx.test:core", version = "1.5.0" }
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
Expand All @@ -29,6 +29,6 @@ atomicfu = { id = "kotlinx-atomicfu", version = "0.21.0" }
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.10" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version = "4.1.0" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.25.3" }
kotlinter = { id = "org.jmailen.kotlinter", version = "4.1.1" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.27.0" }
validator = { id = "binary-compatibility-validator", version = "0.13.0" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.juul.krayon.compose.ElementView
import com.juul.krayon.sample.data.movingSineWave
import com.juul.krayon.sample.updaters.lineChart

class ComposeLineActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.juul.krayon.sample
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.juul.krayon.element.view.ElementViewAdapter
import com.juul.krayon.sample.data.movingSineWave
import com.juul.krayon.sample.databinding.ActivityLineBinding
import com.juul.krayon.sample.updaters.lineChart

class LineActivity : AppCompatActivity() {

Expand Down
2 changes: 1 addition & 1 deletion sample/src/commonMain/kotlin/Point.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.juul.krayon.sample

internal data class Point(
data class Point(
val x: Float,
val y: Float,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.juul.krayon.sample
package com.juul.krayon.sample.data

import com.juul.krayon.sample.Point
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
Expand All @@ -8,11 +9,9 @@ import kotlin.math.PI
import kotlin.math.sin
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource

/** A flow that emits data for a continuously rolling sine wave. By default, completes a full cycle in 10 seconds. */
@OptIn(ExperimentalTime::class)
internal fun movingSineWave(
period: Duration = 10.seconds,
samples: Int = 50,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.juul.krayon.sample
package com.juul.krayon.sample.updaters

import com.juul.krayon.axis.axisBottom
import com.juul.krayon.axis.axisLeft
Expand All @@ -14,6 +14,7 @@ import com.juul.krayon.element.TransformElement
import com.juul.krayon.element.withKind
import com.juul.krayon.kanvas.Paint
import com.juul.krayon.kanvas.Transform
import com.juul.krayon.sample.Point
import com.juul.krayon.scale.domain
import com.juul.krayon.scale.extent
import com.juul.krayon.scale.range
Expand Down
4 changes: 2 additions & 2 deletions sample/src/desktopMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.singleWindowApplication
import com.juul.krayon.compose.ElementView
import com.juul.krayon.sample.PieChart
import com.juul.krayon.sample.data.movingSineWave
import com.juul.krayon.sample.interactiveTreeChart
import com.juul.krayon.sample.lineChart
import com.juul.krayon.sample.movingSineWave
import com.juul.krayon.sample.pieChart
import com.juul.krayon.sample.updaters.lineChart
import kotlin.math.PI

fun main() = singleWindowApplication {
Expand Down
10 changes: 10 additions & 0 deletions sample/src/jsMain/kotlin/SetupInteractiveChart.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import com.juul.krayon.element.view.ElementViewAdapter
import com.juul.krayon.element.view.attachAdapter
import com.juul.krayon.sample.interactiveTreeChart
import org.w3c.dom.HTMLCanvasElement

@JsExport
fun setupInteractiveChart(element: HTMLCanvasElement) {
val (flow, update) = interactiveTreeChart()
element.attachAdapter(ElementViewAdapter(flow, update))
}
15 changes: 15 additions & 0 deletions sample/src/jsMain/kotlin/SetupMovingSineWave.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import com.juul.krayon.element.view.ElementViewAdapter
import com.juul.krayon.element.view.attachAdapter
import com.juul.krayon.sample.data.movingSineWave
import com.juul.krayon.sample.updaters.lineChart
import org.w3c.dom.HTMLCanvasElement

@JsExport
fun setupMovingSineWave(element: HTMLCanvasElement) {
element.attachAdapter(
ElementViewAdapter(
dataSource = movingSineWave(),
updater = ::lineChart,
),
)
}
Loading

0 comments on commit 811e143

Please sign in to comment.