Skip to content

Commit

Permalink
Merge pull request #34 from NeoUtils/web-target
Browse files Browse the repository at this point in the history
Release v2.2.0 - Web target
  • Loading branch information
Irineu333 authored Nov 22, 2024
2 parents 1b5aa0d + 0253630 commit df9e198
Show file tree
Hide file tree
Showing 33 changed files with 3,262 additions and 67 deletions.
8 changes: 8 additions & 0 deletions .idea/artifacts/compose_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/compose_jvm.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/core_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/core_jvm.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/web_1_0_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Facilitate the creation of dynamic highlights using regular expressions, ideal f
| Android with Jetpack Compose ||
| Android with View ||
| Compose for Desktop ||
| Compose for Web | |
| Compose for Web | |
| Compose for iOS ||

## Quick Start
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.SonatypeHost
import extension.config
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.vanniktech.maven.publish")
id("com.android.library")
kotlin("multiplatform")
}

kotlin {
sourceSets {
androidTarget {
compilerOptions {
jvmTarget.set(
JvmTarget.JVM_1_8
)
}
}
}
}

android {
compileSdk = config.android.compileSdk

Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/extension/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import model.Config
val config = Config(
version = Config.Version(
major = 2,
minor = 1,
minor = 2,
patch = 0,
release = Config.Release.Definitive
),
Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
plugins {
// android
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false

// kotlin
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.js) apply false

// compose
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.jetbrains.compose) apply false

// publish
alias(libs.plugins.mavenPublish) apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ import com.neoutils.highlight.compose.remember.rememberTextFieldValue
import com.neoutils.highlight.core.extension.textColor
import com.neoutils.highlight.core.util.UiColor
import com.neoutils.highlight.example.compose.R
import org.intellij.lang.annotations.Language

@Language("kotlin")
private val code = """
fun main() {
print("Hello, World!")
}
""".trimIndent()

@Composable
fun CodeHighlightExample(modifier: Modifier = Modifier) {
Expand Down Expand Up @@ -58,7 +50,15 @@ fun CodeHighlightExample(modifier: Modifier = Modifier) {
val textFieldValue = rememberSaveable(
stateSaver = TextFieldValue.Saver
) {
mutableStateOf(TextFieldValue(code))
mutableStateOf(
TextFieldValue(
"""
fun main() {
print("Hello, World!")
}
""".trimIndent()
)
)
}

BasicTextField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.material3.*
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.neoutils.highlight.compose.remember.rememberHighlight
import com.neoutils.highlight.core.extension.textColor
import com.neoutils.highlight.example.compose.R
import com.neoutils.highlight.example.compose.example.CodeHighlightExample
import com.neoutils.highlight.example.compose.theme.ExampleTheme
Expand Down
39 changes: 28 additions & 11 deletions example/desktop/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.neoutils.highlight.compose.extension.spanStyle
import com.neoutils.highlight.compose.remember.rememberHighlight
import com.neoutils.highlight.compose.remember.rememberTextFieldValue
import com.neoutils.highlight.core.extension.textColor
import com.neoutils.highlight.core.utils.UiColor
import com.neoutils.highlight.core.util.Match
import com.neoutils.highlight.core.util.UiColor

@Composable
@Preview
fun App() {
var textFieldValue by remember {
mutableStateOf(TextFieldValue("Hello, World!"))
mutableStateOf(TextFieldValue("name = Highlight"))
}

BasicTextField(
value = rememberHighlight {
textColor {
fully(
regex = "[A-Z][a-z]+",
UiColor.Blue
match(
regex = "(\\w+)\\s*=\\s*(\\w+)".toRegex(),
match = Match.groups(
UiColor.Blue,
UiColor.Red
)
)
fully(
regex = "\\W",
UiColor.Red
}

spanStyle {
match(
regex = "\\bHighlight\\b".toRegex(),
match = Match.fully(
SpanStyle(
fontStyle = FontStyle.Italic
)
)
)
}
}.rememberTextFieldValue(
Expand All @@ -43,7 +58,9 @@ fun App() {
textStyle = TextStyle(
fontSize = 16.sp
),
modifier = Modifier.fillMaxSize()
modifier = Modifier
.padding(8.dp)
.fillMaxSize()
)
}

Expand All @@ -52,8 +69,8 @@ fun main() = application {
title = "Desktop example",
onCloseRequest = ::exitApplication,
state = rememberWindowState(
width = 400.dp,
height = 300.dp
width = 600.dp,
height = 400.dp
)
) {
App()
Expand Down
1 change: 1 addition & 0 deletions example/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions example/web/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
alias(libs.plugins.kotlin.js)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.compose.compiler)
}

group = "com.neoutils.highlight.example"
version = "1.0.0"

kotlin {
js(IR) {

moduleName = "app"

browser {
commonWebpackConfig {
outputFileName = "app.js"
}
}

binaries.executable()
}
}

dependencies {

implementation(project(":highlight:compose"))

implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.ui)
implementation(compose.material3)
}

repositories {

google()
mavenCentral()

maven {
url = uri("https://central.sonatype.com/api/v1/publisher/deployments/download/")

credentials(HttpHeaderCredentials::class) {
name = "Authorization"
value = "Bearer ${findProperty("mavenCentralToken")}"
}

authentication {
create<HttpHeaderAuthentication>("header")
}
}
}
Loading

0 comments on commit df9e198

Please sign in to comment.