diff --git a/platform/jewel/buildSrc/src/main/kotlin/intellij-color-palette-generator.gradle.kts b/platform/jewel/buildSrc/src/main/kotlin/intellij-color-palette-generator.gradle.kts new file mode 100644 index 000000000000..1665a7d39055 --- /dev/null +++ b/platform/jewel/buildSrc/src/main/kotlin/intellij-color-palette-generator.gradle.kts @@ -0,0 +1,52 @@ +import com.ncorti.ktfmt.gradle.tasks.KtfmtBaseTask +import dev.detekt.gradle.Detekt +import org.jetbrains.dokka.gradle.DokkaTask +import org.jetbrains.dokka.gradle.tasks.DokkaGenerateModuleTask +import org.jetbrains.dokka.gradle.tasks.DokkaGeneratePublicationTask +import org.jetbrains.jewel.buildlogic.metalava.GenerateMetalavaApiTask +import org.jetbrains.jewel.buildlogic.theme.DefaultColorPaletteGeneratorTask +import org.jetbrains.jewel.buildlogic.theme.PaletteSource +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.tasks.BaseKotlinCompile + +class ColorPaletteGenerator(val name: String, project: Project) { + val themeFilePath = project.objects.property() + val themeFile: Provider = project.layout.file(themeFilePath.map { project.rootProject.file(it) }) + val propertyName = project.objects.property() + val isIslands = project.objects.property() +} + +val extension = container { ColorPaletteGenerator(it, project) } + +extensions.add("intelliJColorPaletteGenerator", extension) + +val targetDir: Provider = project.provider { project.layout.projectDirectory.dir("generated/theme") } + +val generateDefaultColorPalette = + tasks.register("generateDefaultColorPalette") { + sources.set( + extension.map { entry -> + project.objects.newInstance().apply { + themeFile.set(entry.themeFile) + propertyName.set(entry.propertyName) + islands.set(entry.isIslands) + } + } + ) + outputFile = targetDir.map { it.file("org/jetbrains/jewel/ui/theme/DefaultColorPalette.kt") } + } + +tasks { + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } + withType { dependsOn(generateDefaultColorPalette) } +} + +pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + the().sourceSets["main"].kotlin.srcDir(targetDir) +} diff --git a/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntUiThemeDescriptorReader.kt b/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntUiThemeDescriptorReader.kt index c1565bfb3d6b..0395b1cb06f7 100644 --- a/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntUiThemeDescriptorReader.kt +++ b/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntUiThemeDescriptorReader.kt @@ -1,5 +1,6 @@ package org.jetbrains.jewel.buildlogic.theme +import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec @@ -11,9 +12,6 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive internal object IntUiThemeDescriptorReader { - private val colorGroups = setOf("Gray", "Blue", "Green", "Red", "Yellow", "Orange", "Purple", "Teal") - private val colorClassName = ClassName("androidx.compose.ui.graphics", "Color") - fun readThemeFrom( themeDescriptor: IntellijThemeDescriptor, className: ClassName, @@ -27,8 +25,6 @@ internal object IntUiThemeDescriptorReader { addFileComment("*** DO NOT EDIT MANUALLY! Use generateThemes task to update. ***\n") addFileComment("Source: $sourcePath") - addImport(colorClassName.packageName, colorClassName.simpleName) - addType( TypeSpec.objectBuilder(className) .apply { @@ -48,7 +44,7 @@ internal object IntUiThemeDescriptorReader { .build() ) - readColors(themeDescriptor.colors) + addColorsProperty(themeDescriptor.dark) readIcons(themeDescriptor) } .build() @@ -56,39 +52,20 @@ internal object IntUiThemeDescriptorReader { } .build() + private val defaultColorPaletteClassName = ClassName("org.jetbrains.jewel.ui.theme", "DefaultColorPalette") private val colorPaletteClassName = ClassName.bestGuess("org.jetbrains.jewel.foundation.theme.ThemeColorPalette") private val iconDataClassName = ClassName.bestGuess("org.jetbrains.jewel.foundation.theme.ThemeIconData") + private val internalJewelApiClassName = ClassName.bestGuess("org.jetbrains.jewel.foundation.InternalJewelApi") - private fun TypeSpec.Builder.readColors(colors: Map) { - val colorGroups = - colors.entries - .groupBy { it.key.replace("""\d+""".toRegex(), "") } - .filterKeys { colorGroups.contains(it) } - .map { (groupName, colors) -> - // We assume color lists are in the same order as in colorGroups - colors - .map { (_, value) -> - val colorHexString = value.replace("#", "0xFF") - CodeBlock.of("Color(%L)", colorHexString) - } - .joinToCode( - prefix = "\n${groupName.lowercase()} = listOf(\n", - separator = ",\n", - suffix = "\n)", - ) - } - - val rawMap = - colors - .map { (key, value) -> - val colorHexString = value.replace("#", "0xFF") - CodeBlock.of("%S to Color(%L)", key, colorHexString) - } - .joinToCode(prefix = "\nrawMap = mapOf(\n", separator = ",\n", suffix = "\n)") - + private fun TypeSpec.Builder.addColorsProperty(isDark: Boolean) { addProperty( PropertySpec.builder("colors", colorPaletteClassName, KModifier.OVERRIDE) - .initializer("ThemeColorPalette(%L,\n%L,\nisIslands = false\n)", colorGroups.joinToCode(","), rawMap) + .addAnnotation( + AnnotationSpec.builder(ClassName("kotlin", "OptIn")) + .addMember("%T::class", internalJewelApiClassName) + .build() + ) + .initializer("%T.%L", defaultColorPaletteClassName, if (isDark) "Dark" else "Light") .build() ) } diff --git a/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntelliJColorPaletteGeneratorTask.kt b/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntelliJColorPaletteGeneratorTask.kt new file mode 100644 index 000000000000..631f4d2f3af9 --- /dev/null +++ b/platform/jewel/buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntelliJColorPaletteGeneratorTask.kt @@ -0,0 +1,157 @@ +package org.jetbrains.jewel.buildlogic.theme + +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.joinToCode +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.decodeFromStream +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction + +abstract class PaletteSource { + @get:InputFile + @get:PathSensitive(PathSensitivity.RELATIVE) + abstract val themeFile: RegularFileProperty + + @get:Input + abstract val propertyName: Property + + @get:Input + abstract val islands: Property +} + +abstract class DefaultColorPaletteGeneratorTask : DefaultTask() { + @get:Nested + abstract val sources: ListProperty + + @get:OutputFile + abstract val outputFile: RegularFileProperty + + @TaskAction + fun generate() { + val file = DefaultColorPaletteReader.readPaletteFrom(sources.get(), readIjpMajor()) + outputFile.get().asFile.bufferedWriter().use { file.writeTo(it) } + } + + private fun readIjpMajor(): String { + val buildNumberFile = project.rootDir.resolve("../../build.txt") + check(buildNumberFile.isFile) { "The build.txt file must exist in the community root" } + + val buildNumber = buildNumberFile.readText().trim() + check(validateBuildNumber(buildNumber)) { "The build number in build.txt does not seem valid: '$buildNumber'" } + + return buildNumber.substringBefore('.') + } + + private fun validateBuildNumber(buildNumber: String): Boolean { + // Examples: + // * 253.1234.567 + // * 241.SNAPSHOT + // * 253.28294.SNAPSHOT + if (buildNumber.isBlank()) return false + if (buildNumber.length < 5) return false + if (buildNumber.take(3).toIntOrNull()?.takeIf { it > 240 } == null) return false + if (buildNumber[3] != '.') return false + + val afterDot = buildNumber.drop(4) + return afterDot == "SNAPSHOT" || + afterDot.all { it.isDigit() || it == '.' } || + (afterDot.endsWith(".SNAPSHOT") && afterDot.removeSuffix(".SNAPSHOT").all { it.isDigit() || it == '.' }) + } +} + +internal object DefaultColorPaletteReader { + private val json = Json { ignoreUnknownKeys = true } + private val colorClassName = ClassName("androidx.compose.ui.graphics", "Color") + private val colorPaletteClassName = ClassName.bestGuess("org.jetbrains.jewel.foundation.theme.ThemeColorPalette") + private val defaultColorPaletteClassName = ClassName("org.jetbrains.jewel.ui.theme", "DefaultColorPalette") + private val internalJewelApiClassName = ClassName.bestGuess("org.jetbrains.jewel.foundation.InternalJewelApi") + private val apiStatusInternalClassName = ClassName("org.jetbrains.annotations", "ApiStatus", "Internal") + private val colorGroups = setOf("Gray", "Blue", "Green", "Red", "Yellow", "Orange", "Purple", "Teal") + + fun readPaletteFrom(sources: List, ijpMajor: String): FileSpec = + FileSpec.builder(defaultColorPaletteClassName) + .apply { + addFileComment("Generated by the Jewel Int UI Color Palette Generator for IJP $ijpMajor\n") + addFileComment("*** DO NOT EDIT MANUALLY! Use intelliJColorPaletteGenerator task to update. ***\n") + + addImport(colorClassName.packageName, colorClassName.simpleName) + + addType( + TypeSpec.objectBuilder(defaultColorPaletteClassName) + .addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("%S", "LargeClass").build() + ) + .addAnnotation(apiStatusInternalClassName) + .addAnnotation(internalJewelApiClassName) + .apply { sources.forEach { source -> addPaletteProperty(source) } } + .build() + ) + } + .build() + + private fun TypeSpec.Builder.addPaletteProperty(source: PaletteSource) { + val colors = + source.themeFile.get().asFile.inputStream().use { json.decodeFromStream(it) }.colors + + addProperty( + PropertySpec.builder(source.propertyName.get(), colorPaletteClassName) + .initializer( + "ThemeColorPalette(%L,\n%L,\nisIslands = %L\n)", + buildColorGroupBlocks(colors).joinToCode(","), + buildRawMapBlock(colors), + source.islands.get(), + ) + .build() + ) + } + + /** Groups colors by family (e.g. "Gray1"/"gray-160" both group under "Gray"), sorted ascending by index. */ + private fun buildColorGroupBlocks(colors: Map): List = + colors.entries + .groupBy { it.key.replace("""-?\d+$""".toRegex(), "").replaceFirstChar { c -> c.uppercase() } } + .filterKeys { colorGroups.contains(it) } + .mapValues { (_, entries) -> entries.sortedBy { it.key.takeLastWhile(Char::isDigit).toInt() } } + .map { (groupName, entries) -> + entries + .map { (_, value) -> CodeBlock.of("Color(%L)", resolveHex(value, colors).replace("#", "0xFF")) } + .joinToCode(prefix = "\n${groupName.lowercase()} = listOf(\n", separator = ",\n", suffix = "\n)") + } + + private fun buildRawMapBlock(colors: Map): CodeBlock = + colors.entries + .map { (key, value) -> CodeBlock.of("%S to Color(%L)", key, resolveHex(value, colors).replace("#", "0xFF")) } + .joinToCode(prefix = "\nrawMap = mapOf(\n", separator = ",\n", suffix = "\n)") + + /** + * Some theme JSONs (notably the Islands ones) define colors as aliases pointing at another key instead of a + * literal hex value (e.g. "toggle-off-bg": "gray-160"), sometimes several levels deep. Follows the chain down to + * an actual hex value. + */ + private fun resolveHex(value: String, colors: Map, depth: Int = 0): String { + if (value.startsWith("#")) return value + check(depth < 10) { "Color alias chain too deep (possible cycle) resolving '$value'" } + + val aliased = colors[value] ?: error("Unresolved color alias '$value'") + return resolveHex(aliased, colors, depth + 1) + } +} + +@Serializable +data class IntelliJColors( + val colors: Map = emptyMap(), +) diff --git a/platform/jewel/foundation/api-dump.txt b/platform/jewel/foundation/api-dump.txt index 7a28eceeddc6..6f8518739be7 100644 --- a/platform/jewel/foundation/api-dump.txt +++ b/platform/jewel/foundation/api-dump.txt @@ -788,6 +788,7 @@ f:org.jetbrains.jewel.foundation.theme.ThemeColorPalette - f:green-vNxB06k(I):J - f:greenOrNull-ijrfgN4(I):androidx.compose.ui.graphics.Color - hashCode():I +- f:isIslands():Z - f:lookup-ijrfgN4(java.lang.String):androidx.compose.ui.graphics.Color - f:orange-vNxB06k(I):J - f:orangeOrNull-ijrfgN4(I):androidx.compose.ui.graphics.Color diff --git a/platform/jewel/foundation/metalava/foundation-api-0.41.0.txt b/platform/jewel/foundation/metalava/foundation-api-0.41.0.txt index 9daf071410ad..b642cbc9ed5f 100644 --- a/platform/jewel/foundation/metalava/foundation-api-0.41.0.txt +++ b/platform/jewel/foundation/metalava/foundation-api-0.41.0.txt @@ -987,6 +987,7 @@ package org.jetbrains.jewel.foundation.theme { method public androidx.compose.ui.graphics.Color? grayOrNull(int index); method @Deprecated public long green(int index); method public androidx.compose.ui.graphics.Color? greenOrNull(int index); + method public boolean isIslands(); method public androidx.compose.ui.graphics.Color? lookup(String colorKey); method @Deprecated public long orange(int index); method public androidx.compose.ui.graphics.Color? orangeOrNull(int index); @@ -1001,6 +1002,7 @@ package org.jetbrains.jewel.foundation.theme { property public java.util.List blue; property public java.util.List gray; property public java.util.List green; + property public boolean isIslands; property public java.util.List orange; property public java.util.List purple; property public java.util.Map rawMap; diff --git a/platform/jewel/foundation/metalava/foundation-api-stable-0.41.0.txt b/platform/jewel/foundation/metalava/foundation-api-stable-0.41.0.txt index 0e52ed2ad63c..c7ca1de17645 100644 --- a/platform/jewel/foundation/metalava/foundation-api-stable-0.41.0.txt +++ b/platform/jewel/foundation/metalava/foundation-api-stable-0.41.0.txt @@ -955,6 +955,7 @@ package org.jetbrains.jewel.foundation.theme { method public androidx.compose.ui.graphics.Color? grayOrNull(int index); method @Deprecated public long green(int index); method public androidx.compose.ui.graphics.Color? greenOrNull(int index); + method public boolean isIslands(); method public androidx.compose.ui.graphics.Color? lookup(String colorKey); method @Deprecated public long orange(int index); method public androidx.compose.ui.graphics.Color? orangeOrNull(int index); @@ -969,6 +970,7 @@ package org.jetbrains.jewel.foundation.theme { property public java.util.List blue; property public java.util.List gray; property public java.util.List green; + property public boolean isIslands; property public java.util.List orange; property public java.util.List purple; property public java.util.Map rawMap; diff --git a/platform/jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPalette.kt b/platform/jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPalette.kt index 4fc33969398e..5ddff8165bc2 100644 --- a/platform/jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPalette.kt +++ b/platform/jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPalette.kt @@ -2,6 +2,7 @@ package org.jetbrains.jewel.foundation.theme import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.isSpecified import org.jetbrains.jewel.foundation.GenerateDataFunctions private val nonIslandsColorKeyRegex: Regex @@ -28,6 +29,7 @@ private val islandsColorKeyRegex: Regex * @property purple A list of purple colors. * @property teal A list of teal colors. * @property rawMap A map of all colors in the palette, with their original keys. + * @property isIslands Whether the palette uses the Islands theme color key format (e.g., `gray-10` instead of `gray1`). */ @Suppress("MemberVisibilityCanBePrivate", "KDocUnresolvedReference") @Immutable @@ -42,7 +44,7 @@ public class ThemeColorPalette( public val purple: List, public val teal: List, public val rawMap: Map, - private val isIslands: Boolean, + public val isIslands: Boolean, ) { @Suppress("DEPRECATION") @Deprecated("Use the constructor with isIslands parameter", level = DeprecationLevel.HIDDEN) @@ -325,12 +327,16 @@ public class ThemeColorPalette( */ public fun tealOrNull(index: Int): Color? = getByIndexOrNull(teal, index) - private fun getByIndexOrNull(list: List, index: Int): Color? = - if (isIslands) { - if (index % 10 != 0) null else list.getOrNull(index / 10 - 1) - } else { - list.getOrNull(index - 1) - } + // Treat Color.Unspecified as null in index gaps in a sparse palette + private fun getByIndexOrNull(list: List, index: Int): Color? { + val resolved = + if (isIslands) { + if (index % 10 != 0) return null else list.getOrNull(index / 10 - 1) + } else { + list.getOrNull(index - 1) + } + return resolved?.takeIf { it.isSpecified } + } /** * Looks up a color in the palette by its key. The key can be in the format "colorNameN" (e.g., "gray1", "blue12"), diff --git a/platform/jewel/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPaletteTest.kt b/platform/jewel/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPaletteTest.kt new file mode 100644 index 000000000000..7f0c78748477 --- /dev/null +++ b/platform/jewel/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/theme/ThemeColorPaletteTest.kt @@ -0,0 +1,58 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.jewel.foundation.theme + +import androidx.compose.ui.graphics.Color +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +public class ThemeColorPaletteTest { + @Test + public fun `grayOrNull returns the color at the given index`() { + val palette = palette(gray = listOf(Color.Red, Color.Green, Color.Blue)) + + assertEquals(Color.Red, palette.grayOrNull(1)!!) + assertEquals(Color.Blue, palette.grayOrNull(3)!!) + } + + @Test + public fun `grayOrNull returns null when the index is out of bounds`() { + val palette = palette(gray = listOf(Color.Red)) + + assertNull(palette.grayOrNull(2)) + } + + @Test + public fun `grayOrNull treats an index gap as absent, not the next real color`() { + // Simulates a partial 3rd-party LaF that declares Gray1 and Gray3 but not Gray2 — the gap must be padded + // with Color.Unspecified (see BridgeThemeColorPalette.readFromLaF), not simply omitted from the list. + val palette = palette(gray = listOf(Color.Red, Color.Unspecified, Color.Blue)) + + assertEquals(Color.Red, palette.grayOrNull(1)!!) + assertNull(palette.grayOrNull(2)) + assertEquals(Color.Blue, palette.grayOrNull(3)!!) + } + + @Test + public fun `grayOrNull treats an index gap as absent for Islands indexing too`() { + val palette = palette(gray = listOf(Color.Red, Color.Unspecified, Color.Blue), isIslands = true) + + assertEquals(Color.Red, palette.grayOrNull(10)!!) + assertNull(palette.grayOrNull(20)) + assertEquals(Color.Blue, palette.grayOrNull(30)!!) + } + + private fun palette(gray: List = emptyList(), isIslands: Boolean = false): ThemeColorPalette = + ThemeColorPalette( + gray = gray, + blue = emptyList(), + green = emptyList(), + red = emptyList(), + yellow = emptyList(), + orange = emptyList(), + purple = emptyList(), + teal = emptyList(), + rawMap = emptyMap(), + isIslands = isIslands, + ) +} diff --git a/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeThemeColorPalette.kt b/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeThemeColorPalette.kt index 51d05563f844..a378270d423c 100644 --- a/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeThemeColorPalette.kt +++ b/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeThemeColorPalette.kt @@ -4,7 +4,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.isSpecified import com.intellij.openapi.diagnostic.Logger import com.intellij.ui.IslandsState -import java.util.TreeMap import javax.swing.UIDefaults import org.jetbrains.jewel.bridge.toComposeColor import org.jetbrains.jewel.foundation.theme.ThemeColorPalette @@ -27,32 +26,38 @@ public fun ThemeColorPalette.Companion.readFromLaF(): ThemeColorPalette { val windowsPopupBorder = readPaletteColor("windowsPopupBorder") val rawMap = buildMap { - putAll(gray) - putAll(blue) - putAll(green) - putAll(red) - putAll(yellow) - putAll(orange) - putAll(purple) - putAll(teal) + putAll(gray.presentEntries) + putAll(blue.presentEntries) + putAll(green.presentEntries) + putAll(red.presentEntries) + putAll(yellow.presentEntries) + putAll(orange.presentEntries) + putAll(purple.presentEntries) + putAll(teal.presentEntries) if (windowsPopupBorder.isSpecified) put("windowsPopupBorder", windowsPopupBorder) } return ThemeColorPalette( - gray = gray.values.toList(), - blue = blue.values.toList(), - green = green.values.toList(), - red = red.values.toList(), - yellow = yellow.values.toList(), - orange = orange.values.toList(), - purple = purple.values.toList(), - teal = teal.values.toList(), + gray = gray.list, + blue = blue.list, + green = green.list, + red = red.list, + yellow = yellow.list, + orange = orange.list, + purple = purple.list, + teal = teal.list, rawMap = rawMap, isIslands = isIslands, ) } -private fun readPaletteColors(colorName: String, isIslands: Boolean): Map { +/** + * [list] is dense (gaps padded with [Color.Unspecified]) while [presentEntries] holds only keys the LaF actually + * declared. + */ +private class FamilyColors(val list: List, val presentEntries: Map) + +private fun readPaletteColors(colorName: String, isIslands: Boolean): FamilyColors { val defaults: UIDefaults = uiDefaults val allKeys: Set = defaults.keys val colorNameKeyPrefix = if (isIslands) "ColorPalette.${colorName.lowercase()}-" else "ColorPalette.$colorName" @@ -66,8 +71,7 @@ private fun readPaletteColors(colorName: String, isIslands: Boolean): Map() + val list = + indices.map { i -> val key = "$colorNameKeyPrefix$i" val value = defaults[key] as? java.awt.Color if (value == null) { logger.error("Unable to find color value for palette key '$colorNameKeyPrefix$i'") - continue + Color.Unspecified + } else { + value.toComposeColor().also { presentEntries[key] = it } } - - put(key, value.toComposeColor()) } - } + + return FamilyColors(list, presentEntries) } private fun readPaletteColor(colorName: String): Color { diff --git a/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiDarkTheme.kt b/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiDarkTheme.kt index cd58c3b16d54..afc6397b820e 100644 --- a/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiDarkTheme.kt +++ b/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiDarkTheme.kt @@ -3,243 +3,21 @@ // Source: ../../platform/platform-resources/src/themes/expUI/expUI_dark.theme.json package org.jetbrains.jewel.intui.core.theme -import androidx.compose.ui.graphics.Color import kotlin.Boolean +import kotlin.OptIn import kotlin.String +import org.jetbrains.jewel.foundation.InternalJewelApi import org.jetbrains.jewel.foundation.theme.ThemeColorPalette import org.jetbrains.jewel.foundation.theme.ThemeDescriptor import org.jetbrains.jewel.foundation.theme.ThemeIconData +import org.jetbrains.jewel.ui.theme.DefaultColorPalette public object IntUiDarkTheme : ThemeDescriptor { override val isDark: Boolean = true override val name: String = "Dark (Int UI)" - override val colors: ThemeColorPalette = - ThemeColorPalette( - gray = - listOf( - Color(0xFF1E1F22), - Color(0xFF2B2D30), - Color(0xFF393B40), - Color(0xFF43454A), - Color(0xFF4E5157), - Color(0xFF5A5D63), - Color(0xFF6F737A), - Color(0xFF868A91), - Color(0xFF9DA0A8), - Color(0xFFB4B8BF), - Color(0xFFCED0D6), - Color(0xFFDFE1E5), - Color(0xFFF0F1F2), - Color(0xFFFFFFFF), - ), - blue = - listOf( - Color(0xFF25324D), - Color(0xFF2E436E), - Color(0xFF35538F), - Color(0xFF375FAD), - Color(0xFF366ACE), - Color(0xFF3574F0), - Color(0xFF467FF2), - Color(0xFF548AF7), - Color(0xFF6B9BFA), - Color(0xFF83ACFC), - Color(0xFF99BBFF), - Color(0xFFB5CEFF), - Color(0xFFD1E0FF), - ), - green = - listOf( - Color(0xFF253627), - Color(0xFF273828), - Color(0xFF375239), - Color(0xFF436946), - Color(0xFF4E8052), - Color(0xFF57965C), - Color(0xFF5FAD65), - Color(0xFF73BD79), - Color(0xFF89CC8E), - Color(0xFFA0DBA5), - Color(0xFFB9EBBD), - Color(0xFFD4FAD7), - ), - yellow = - listOf( - Color(0xFF3D3223), - Color(0xFF5E4D33), - Color(0xFF826A41), - Color(0xFF9E814A), - Color(0xFFBA9752), - Color(0xFFD6AE58), - Color(0xFFF2C55C), - Color(0xFFF5D273), - Color(0xFFF7DE8B), - Color(0xFFFCEBA4), - Color(0xFFFFF6BD), - ), - red = - listOf( - Color(0xFF402929), - Color(0xFF472B2B), - Color(0xFF5E3838), - Color(0xFF7A4343), - Color(0xFF9C4E4E), - Color(0xFFBD5757), - Color(0xFFDB5C5C), - Color(0xFFE37774), - Color(0xFFEB938D), - Color(0xFFF2B1AA), - Color(0xFFF7CCC6), - Color(0xFFFAE3DE), - ), - orange = - listOf( - Color(0xFF45322B), - Color(0xFF614438), - Color(0xFF825845), - Color(0xFFA36B4E), - Color(0xFFC27A53), - Color(0xFFE08855), - Color(0xFFE5986C), - Color(0xFFF0AC81), - Color(0xFFF5BD98), - Color(0xFFFACEAF), - Color(0xFFFFDFC7), - ), - purple = - listOf( - Color(0xFF2F2936), - Color(0xFF3B3147), - Color(0xFF433358), - Color(0xFF583D7A), - Color(0xFF6C469C), - Color(0xFF8150BE), - Color(0xFF955AE0), - Color(0xFFA571E6), - Color(0xFFB589EC), - Color(0xFFC4A0F3), - Color(0xFFD4B8F9), - Color(0xFFE4CEFF), - ), - teal = - listOf( - Color(0xFF1D3838), - Color(0xFF1D3D3B), - Color(0xFF1E4D4A), - Color(0xFF20635D), - Color(0xFF21786F), - Color(0xFF238E82), - Color(0xFF24A394), - Color(0xFF42B1A4), - Color(0xFF60C0B5), - Color(0xFF7DCEC5), - Color(0xFF9BDDD6), - Color(0xFFB9EBE6), - ), - rawMap = - mapOf( - "Gray1" to Color(0xFF1E1F22), - "Gray2" to Color(0xFF2B2D30), - "Gray3" to Color(0xFF393B40), - "Gray4" to Color(0xFF43454A), - "Gray5" to Color(0xFF4E5157), - "Gray6" to Color(0xFF5A5D63), - "Gray7" to Color(0xFF6F737A), - "Gray8" to Color(0xFF868A91), - "Gray9" to Color(0xFF9DA0A8), - "Gray10" to Color(0xFFB4B8BF), - "Gray11" to Color(0xFFCED0D6), - "Gray12" to Color(0xFFDFE1E5), - "Gray13" to Color(0xFFF0F1F2), - "Gray14" to Color(0xFFFFFFFF), - "Blue1" to Color(0xFF25324D), - "Blue2" to Color(0xFF2E436E), - "Blue3" to Color(0xFF35538F), - "Blue4" to Color(0xFF375FAD), - "Blue5" to Color(0xFF366ACE), - "Blue6" to Color(0xFF3574F0), - "Blue7" to Color(0xFF467FF2), - "Blue8" to Color(0xFF548AF7), - "Blue9" to Color(0xFF6B9BFA), - "Blue10" to Color(0xFF83ACFC), - "Blue11" to Color(0xFF99BBFF), - "Blue12" to Color(0xFFB5CEFF), - "Blue13" to Color(0xFFD1E0FF), - "Green1" to Color(0xFF253627), - "Green2" to Color(0xFF273828), - "Green3" to Color(0xFF375239), - "Green4" to Color(0xFF436946), - "Green5" to Color(0xFF4E8052), - "Green6" to Color(0xFF57965C), - "Green7" to Color(0xFF5FAD65), - "Green8" to Color(0xFF73BD79), - "Green9" to Color(0xFF89CC8E), - "Green10" to Color(0xFFA0DBA5), - "Green11" to Color(0xFFB9EBBD), - "Green12" to Color(0xFFD4FAD7), - "Yellow1" to Color(0xFF3D3223), - "Yellow2" to Color(0xFF5E4D33), - "Yellow3" to Color(0xFF826A41), - "Yellow4" to Color(0xFF9E814A), - "Yellow5" to Color(0xFFBA9752), - "Yellow6" to Color(0xFFD6AE58), - "Yellow7" to Color(0xFFF2C55C), - "Yellow8" to Color(0xFFF5D273), - "Yellow9" to Color(0xFFF7DE8B), - "Yellow10" to Color(0xFFFCEBA4), - "Yellow11" to Color(0xFFFFF6BD), - "Red1" to Color(0xFF402929), - "Red2" to Color(0xFF472B2B), - "Red3" to Color(0xFF5E3838), - "Red4" to Color(0xFF7A4343), - "Red5" to Color(0xFF9C4E4E), - "Red6" to Color(0xFFBD5757), - "Red7" to Color(0xFFDB5C5C), - "Red8" to Color(0xFFE37774), - "Red9" to Color(0xFFEB938D), - "Red10" to Color(0xFFF2B1AA), - "Red11" to Color(0xFFF7CCC6), - "Red12" to Color(0xFFFAE3DE), - "Orange1" to Color(0xFF45322B), - "Orange2" to Color(0xFF614438), - "Orange3" to Color(0xFF825845), - "Orange4" to Color(0xFFA36B4E), - "Orange5" to Color(0xFFC27A53), - "Orange6" to Color(0xFFE08855), - "Orange7" to Color(0xFFE5986C), - "Orange8" to Color(0xFFF0AC81), - "Orange9" to Color(0xFFF5BD98), - "Orange10" to Color(0xFFFACEAF), - "Orange11" to Color(0xFFFFDFC7), - "Purple1" to Color(0xFF2F2936), - "Purple2" to Color(0xFF3B3147), - "Purple3" to Color(0xFF433358), - "Purple4" to Color(0xFF583D7A), - "Purple5" to Color(0xFF6C469C), - "Purple6" to Color(0xFF8150BE), - "Purple7" to Color(0xFF955AE0), - "Purple8" to Color(0xFFA571E6), - "Purple9" to Color(0xFFB589EC), - "Purple10" to Color(0xFFC4A0F3), - "Purple11" to Color(0xFFD4B8F9), - "Purple12" to Color(0xFFE4CEFF), - "Teal1" to Color(0xFF1D3838), - "Teal2" to Color(0xFF1D3D3B), - "Teal3" to Color(0xFF1E4D4A), - "Teal4" to Color(0xFF20635D), - "Teal5" to Color(0xFF21786F), - "Teal6" to Color(0xFF238E82), - "Teal7" to Color(0xFF24A394), - "Teal8" to Color(0xFF42B1A4), - "Teal9" to Color(0xFF60C0B5), - "Teal10" to Color(0xFF7DCEC5), - "Teal11" to Color(0xFF9BDDD6), - "Teal12" to Color(0xFFB9EBE6), - ), - isIslands = false, - ) + @OptIn(InternalJewelApi::class) override val colors: ThemeColorPalette = DefaultColorPalette.Dark override val iconData: ThemeIconData = ThemeIconData( diff --git a/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiLightTheme.kt b/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiLightTheme.kt index 83e4830f8e7d..da0ae1c3e137 100644 --- a/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiLightTheme.kt +++ b/platform/jewel/int-ui/int-ui-standalone/generated/theme/org/jetbrains/jewel/intui/core/theme/IntUiLightTheme.kt @@ -3,226 +3,21 @@ // Source: ../../platform/platform-resources/src/themes/expUI/expUI_light.theme.json package org.jetbrains.jewel.intui.core.theme -import androidx.compose.ui.graphics.Color import kotlin.Boolean +import kotlin.OptIn import kotlin.String +import org.jetbrains.jewel.foundation.InternalJewelApi import org.jetbrains.jewel.foundation.theme.ThemeColorPalette import org.jetbrains.jewel.foundation.theme.ThemeDescriptor import org.jetbrains.jewel.foundation.theme.ThemeIconData +import org.jetbrains.jewel.ui.theme.DefaultColorPalette public object IntUiLightTheme : ThemeDescriptor { override val isDark: Boolean = false override val name: String = "Light (Int UI)" - override val colors: ThemeColorPalette = - ThemeColorPalette( - gray = - listOf( - Color(0xFF000000), - Color(0xFF27282E), - Color(0xFF383A42), - Color(0xFF494B57), - Color(0xFF5A5D6B), - Color(0xFF6C707E), - Color(0xFF818594), - Color(0xFFA8ADBD), - Color(0xFFC9CCD6), - Color(0xFFD3D5DB), - Color(0xFFDFE1E5), - Color(0xFFEBECF0), - Color(0xFFF7F8FA), - Color(0xFFFFFFFF), - ), - blue = - listOf( - Color(0xFF2E55A3), - Color(0xFF315FBD), - Color(0xFF3369D6), - Color(0xFF3574F0), - Color(0xFF4682FA), - Color(0xFF588CF3), - Color(0xFF709CF5), - Color(0xFF88ADF7), - Color(0xFFA0BDF8), - Color(0xFFC2D6FC), - Color(0xFFD4E2FF), - Color(0xFFEDF3FF), - Color(0xFFF5F8FE), - ), - green = - listOf( - Color(0xFF1E6B33), - Color(0xFF1F7536), - Color(0xFF1F8039), - Color(0xFF208A3C), - Color(0xFF369650), - Color(0xFF55A76A), - Color(0xFF89C398), - Color(0xFFAFDBB8), - Color(0xFFC5E5CC), - Color(0xFFE3F7E7), - Color(0xFFF2FCF3), - ), - yellow = - listOf( - Color(0xFFA46704), - Color(0xFFC27D04), - Color(0xFFDF9303), - Color(0xFFFFAF0F), - Color(0xFFFDBD3D), - Color(0xFFFED277), - Color(0xFFFEE6B1), - Color(0xFFFFF1D1), - Color(0xFFFFF5DB), - Color(0xFFFFFAEB), - ), - red = - listOf( - Color(0xFFAD2B38), - Color(0xFFBC303E), - Color(0xFFCC3645), - Color(0xFFDB3B4B), - Color(0xFFE55765), - Color(0xFFE46A76), - Color(0xFFED99A1), - Color(0xFFF2B6BB), - Color(0xFFFAD4D8), - Color(0xFFFFEBEC), - Color(0xFFFFF2F3), - Color(0xFFFFF7F7), - ), - orange = - listOf( - Color(0xFFA14916), - Color(0xFFB85516), - Color(0xFFCE6117), - Color(0xFFE56D17), - Color(0xFFEC8F4C), - Color(0xFFF2B181), - Color(0xFFF9D2B6), - Color(0xFFFFEFE3), - Color(0xFFFFF4EB), - ), - teal = - listOf( - Color(0xFF096A6E), - Color(0xFF077A7F), - Color(0xFF058B90), - Color(0xFF039BA1), - Color(0xFF3FB3B8), - Color(0xFF7BCCCF), - Color(0xFFB6E4E5), - Color(0xFFDAF4F5), - Color(0xFFF2FCFC), - ), - purple = - listOf( - Color(0xFF55339C), - Color(0xFF643CB8), - Color(0xFF7444D4), - Color(0xFF834DF0), - Color(0xFFA177F4), - Color(0xFFBFA1F8), - Color(0xFFDCCBFB), - Color(0xFFEFE5FF), - Color(0xFFF5EDFF), - Color(0xFFFAF5FF), - ), - rawMap = - mapOf( - "Gray1" to Color(0xFF000000), - "Gray2" to Color(0xFF27282E), - "Gray3" to Color(0xFF383A42), - "Gray4" to Color(0xFF494B57), - "Gray5" to Color(0xFF5A5D6B), - "Gray6" to Color(0xFF6C707E), - "Gray7" to Color(0xFF818594), - "Gray8" to Color(0xFFA8ADBD), - "Gray9" to Color(0xFFC9CCD6), - "Gray10" to Color(0xFFD3D5DB), - "Gray11" to Color(0xFFDFE1E5), - "Gray12" to Color(0xFFEBECF0), - "Gray13" to Color(0xFFF7F8FA), - "Gray14" to Color(0xFFFFFFFF), - "windowsPopupBorder" to Color(0xFFB9BDC9), - "Blue1" to Color(0xFF2E55A3), - "Blue2" to Color(0xFF315FBD), - "Blue3" to Color(0xFF3369D6), - "Blue4" to Color(0xFF3574F0), - "Blue5" to Color(0xFF4682FA), - "Blue6" to Color(0xFF588CF3), - "Blue7" to Color(0xFF709CF5), - "Blue8" to Color(0xFF88ADF7), - "Blue9" to Color(0xFFA0BDF8), - "Blue10" to Color(0xFFC2D6FC), - "Blue11" to Color(0xFFD4E2FF), - "Blue12" to Color(0xFFEDF3FF), - "Blue13" to Color(0xFFF5F8FE), - "Green1" to Color(0xFF1E6B33), - "Green2" to Color(0xFF1F7536), - "Green3" to Color(0xFF1F8039), - "Green4" to Color(0xFF208A3C), - "Green5" to Color(0xFF369650), - "Green6" to Color(0xFF55A76A), - "Green7" to Color(0xFF89C398), - "Green8" to Color(0xFFAFDBB8), - "Green9" to Color(0xFFC5E5CC), - "Green10" to Color(0xFFE3F7E7), - "Green11" to Color(0xFFF2FCF3), - "Yellow1" to Color(0xFFA46704), - "Yellow2" to Color(0xFFC27D04), - "Yellow3" to Color(0xFFDF9303), - "Yellow4" to Color(0xFFFFAF0F), - "Yellow5" to Color(0xFFFDBD3D), - "Yellow6" to Color(0xFFFED277), - "Yellow7" to Color(0xFFFEE6B1), - "Yellow8" to Color(0xFFFFF1D1), - "Yellow9" to Color(0xFFFFF5DB), - "Yellow10" to Color(0xFFFFFAEB), - "Red1" to Color(0xFFAD2B38), - "Red2" to Color(0xFFBC303E), - "Red3" to Color(0xFFCC3645), - "Red4" to Color(0xFFDB3B4B), - "Red5" to Color(0xFFE55765), - "Red6" to Color(0xFFE46A76), - "Red7" to Color(0xFFED99A1), - "Red8" to Color(0xFFF2B6BB), - "Red9" to Color(0xFFFAD4D8), - "Red10" to Color(0xFFFFEBEC), - "Red11" to Color(0xFFFFF2F3), - "Red12" to Color(0xFFFFF7F7), - "Orange1" to Color(0xFFA14916), - "Orange2" to Color(0xFFB85516), - "Orange3" to Color(0xFFCE6117), - "Orange4" to Color(0xFFE56D17), - "Orange5" to Color(0xFFEC8F4C), - "Orange6" to Color(0xFFF2B181), - "Orange7" to Color(0xFFF9D2B6), - "Orange8" to Color(0xFFFFEFE3), - "Orange9" to Color(0xFFFFF4EB), - "Teal1" to Color(0xFF096A6E), - "Teal2" to Color(0xFF077A7F), - "Teal3" to Color(0xFF058B90), - "Teal4" to Color(0xFF039BA1), - "Teal5" to Color(0xFF3FB3B8), - "Teal6" to Color(0xFF7BCCCF), - "Teal7" to Color(0xFFB6E4E5), - "Teal8" to Color(0xFFDAF4F5), - "Teal9" to Color(0xFFF2FCFC), - "Purple1" to Color(0xFF55339C), - "Purple2" to Color(0xFF643CB8), - "Purple3" to Color(0xFF7444D4), - "Purple4" to Color(0xFF834DF0), - "Purple5" to Color(0xFFA177F4), - "Purple6" to Color(0xFFBFA1F8), - "Purple7" to Color(0xFFDCCBFB), - "Purple8" to Color(0xFFEFE5FF), - "Purple9" to Color(0xFFF5EDFF), - "Purple10" to Color(0xFFFAF5FF), - ), - isIslands = false, - ) + @OptIn(InternalJewelApi::class) override val colors: ThemeColorPalette = DefaultColorPalette.Light override val iconData: ThemeIconData = ThemeIconData( diff --git a/platform/jewel/ui-tests/src/test/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPaletteOrDefaultTest.kt b/platform/jewel/ui-tests/src/test/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPaletteOrDefaultTest.kt new file mode 100644 index 000000000000..43a9084448f8 --- /dev/null +++ b/platform/jewel/ui-tests/src/test/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPaletteOrDefaultTest.kt @@ -0,0 +1,91 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.jewel.ui.theme + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.test.junit4.v2.createComposeRule +import org.jetbrains.jewel.foundation.InternalJewelApi +import org.jetbrains.jewel.foundation.theme.ThemeColorPalette +import org.jetbrains.jewel.intui.standalone.theme.IntUiTheme +import org.junit.Assert.assertEquals +import org.junit.Rule +import org.junit.Test + +@OptIn(InternalJewelApi::class) +class ThemeColorPaletteOrDefaultTest { + @get:Rule val rule = createComposeRule() + + @Test + fun `grayOrDefault returns the palette's own value when present`() { + val ownValue = Color(0xFF123456) + val palette = palette(gray = listOf(ownValue)) + var result: Color? = null + + rule.setContent { IntUiTheme { result = palette.grayOrDefault(1) } } + + assertEquals(ownValue, result!!) + } + + @Test + fun `grayOrDefault falls back to the light default table when missing`() { + val palette = palette(gray = emptyList()) + var result: Color? = null + + rule.setContent { IntUiTheme(isDark = false) { result = palette.grayOrDefault(1) } } + + assertEquals(DefaultColorPalette.Light.grayOrNull(1), result) + } + + @Test + fun `grayOrDefault falls back to the dark default table when missing`() { + val palette = palette(gray = emptyList()) + var result: Color? = null + + rule.setContent { IntUiTheme(isDark = true) { result = palette.grayOrDefault(1) } } + + assertEquals(DefaultColorPalette.Dark.grayOrNull(1), result) + } + + @Test + fun `grayOrDefault falls back to the Islands light default table when missing`() { + val palette = palette(gray = emptyList(), isIslands = true) + var result: Color? = null + + rule.setContent { IntUiTheme(isDark = false) { result = palette.grayOrDefault(10) } } + + assertEquals(DefaultColorPalette.IslandsLight.grayOrNull(10), result) + } + + @Test + fun `grayOrDefault falls back to the Islands dark default table when missing`() { + val palette = palette(gray = emptyList(), isIslands = true) + var result: Color? = null + + rule.setContent { IntUiTheme(isDark = true) { result = palette.grayOrDefault(10) } } + + assertEquals(DefaultColorPalette.IslandsDark.grayOrNull(10), result) + } + + @Test + fun `grayOrDefault returns Unspecified when the index is out of bounds everywhere`() { + val palette = palette(gray = emptyList()) + var result: Color? = null + + rule.setContent { IntUiTheme { result = palette.grayOrDefault(9999) } } + + assertEquals(Color.Unspecified, result!!) + } + + private fun palette(gray: List, isIslands: Boolean = false): ThemeColorPalette = + ThemeColorPalette( + gray = gray, + blue = emptyList(), + green = emptyList(), + red = emptyList(), + yellow = emptyList(), + orange = emptyList(), + purple = emptyList(), + teal = emptyList(), + rawMap = emptyMap(), + isIslands = isIslands, + ) +} diff --git a/platform/jewel/ui/BUILD.bazel b/platform/jewel/ui/BUILD.bazel index 51e6ee0ac68f..9e96ae511da6 100644 --- a/platform/jewel/ui/BUILD.bazel +++ b/platform/jewel/ui/BUILD.bazel @@ -23,8 +23,10 @@ jvm_library( "src/main/kotlin/**/*.kt", "src/main/kotlin/**/*.java", "src/main/kotlin/**/*.form", - "generated/**/*.kt", - "generated/**/*.java", + "generated/icons/**/*.kt", + "generated/icons/**/*.java", + "generated/theme/**/*.kt", + "generated/theme/**/*.java", ], allow_empty = True, ), diff --git a/platform/jewel/ui/api-dump.txt b/platform/jewel/ui/api-dump.txt index 966b8ecdee0e..13107cbf6591 100644 --- a/platform/jewel/ui/api-dump.txt +++ b/platform/jewel/ui/api-dump.txt @@ -4206,6 +4206,15 @@ f:org.jetbrains.jewel.ui.theme.JewelThemeKt - sf:getTextFieldStyle(org.jetbrains.jewel.foundation.theme.JewelTheme$Companion,androidx.compose.runtime.Composer,I):org.jetbrains.jewel.ui.component.styling.TextFieldStyle - sf:getTooltipStyle(org.jetbrains.jewel.foundation.theme.JewelTheme$Companion,androidx.compose.runtime.Composer,I):org.jetbrains.jewel.ui.component.styling.TooltipStyle - sf:getTreeStyle(org.jetbrains.jewel.foundation.theme.JewelTheme$Companion,androidx.compose.runtime.Composer,I):org.jetbrains.jewel.ui.component.styling.LazyTreeStyle +f:org.jetbrains.jewel.ui.theme.ThemeColorPaletteKt +- sf:blueOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:grayOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:greenOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:orangeOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:purpleOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:redOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:tealOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J +- sf:yellowOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette,I,androidx.compose.runtime.Composer,I):J f:org.jetbrains.jewel.ui.util.ColorExtensionsKt - sf:fromArgbHexStringOrNull(androidx.compose.ui.graphics.Color$Companion,java.lang.String):androidx.compose.ui.graphics.Color - sf:fromRgbaHexStringOrNull(androidx.compose.ui.graphics.Color$Companion,java.lang.String):androidx.compose.ui.graphics.Color diff --git a/platform/jewel/ui/build.gradle.kts b/platform/jewel/ui/build.gradle.kts index 87569ff73407..784f6fbbdb53 100644 --- a/platform/jewel/ui/build.gradle.kts +++ b/platform/jewel/ui/build.gradle.kts @@ -1,11 +1,13 @@ import org.jetbrains.jewel.buildlogic.icons.IconKeysGeneratorTask import org.jetbrains.jewel.buildlogic.metalava.GenerateMetalavaApiTask +import org.jetbrains.jewel.buildlogic.theme.DefaultColorPaletteGeneratorTask import org.jmailen.gradle.kotlinter.tasks.FormatTask import org.jmailen.gradle.kotlinter.tasks.LintTask plugins { jewel `jewel-check-public-api` + `intellij-color-palette-generator` alias(libs.plugins.composeDesktop) alias(libs.plugins.compose.compiler) alias(libs.plugins.kotlinx.serialization) @@ -21,7 +23,7 @@ dependencies { testImplementation(compose.desktop.currentOs) { exclude(group = "org.jetbrains.compose.material") } } -sourceSets.main { java.srcDir(project.file("generated")) } +sourceSets.main { java.srcDir(project.file("generated/icons")) } tasks { withType { @@ -34,4 +36,45 @@ tasks { val iconGeneratorTasks = withType() withType { dependsOn(iconGeneratorTasks) } + + // Same pattern as int-ui-standalone/build.gradle.kts for its own generated theme files. + val paletteGeneratorTasks = withType() + paletteGeneratorTasks.configureEach { finalizedBy(ktfmtFormatMain) } + + ktfmtFormatMain { + // Ensure the ktfmtFormatMain task is not considered UP-TO-DATE when we've regenerated + // DefaultColorPalette.kt (it doesn't always pick it up for some reason) + outputs.upToDateWhen { paletteGeneratorTasks.none { it.state.executed } } + } + + ktfmtCheckMain { + mustRunAfter(paletteGeneratorTasks) + mustRunAfter(ktfmtFormatMain) + } +} + +intelliJColorPaletteGenerator { + register("Light") { + themeFilePath = "../../platform/platform-resources/src/themes/expUI/expUI_light.theme.json" + propertyName = "Light" + isIslands = false + } + + register("Dark") { + themeFilePath = "../../platform/platform-resources/src/themes/expUI/expUI_dark.theme.json" + propertyName = "Dark" + isIslands = false + } + + register("IslandsLight") { + themeFilePath = "../../platform/platform-resources/src/themes/islands/ManyIslandsLight.theme.json" + propertyName = "IslandsLight" + isIslands = true + } + + register("IslandsDark") { + themeFilePath = "../../platform/platform-resources/src/themes/islands/ManyIslandsDark.theme.json" + propertyName = "IslandsDark" + isIslands = true + } } diff --git a/platform/jewel/ui/generated/org/jetbrains/jewel/ui/icons/AllIconsKeys.java b/platform/jewel/ui/generated/icons/org/jetbrains/jewel/ui/icons/AllIconsKeys.java similarity index 100% rename from platform/jewel/ui/generated/org/jetbrains/jewel/ui/icons/AllIconsKeys.java rename to platform/jewel/ui/generated/icons/org/jetbrains/jewel/ui/icons/AllIconsKeys.java diff --git a/platform/jewel/ui/generated/theme/org/jetbrains/jewel/ui/theme/DefaultColorPalette.kt b/platform/jewel/ui/generated/theme/org/jetbrains/jewel/ui/theme/DefaultColorPalette.kt new file mode 100644 index 000000000000..a80342aa6153 --- /dev/null +++ b/platform/jewel/ui/generated/theme/org/jetbrains/jewel/ui/theme/DefaultColorPalette.kt @@ -0,0 +1,1429 @@ +// Generated by the Jewel Int UI Color Palette Generator for IJP 263 +// *** DO NOT EDIT MANUALLY! Use intelliJColorPaletteGenerator task to update. *** +// +package org.jetbrains.jewel.ui.theme + +import androidx.compose.ui.graphics.Color +import kotlin.Suppress +import org.jetbrains.annotations.ApiStatus +import org.jetbrains.jewel.foundation.InternalJewelApi +import org.jetbrains.jewel.foundation.theme.ThemeColorPalette + +@Suppress("LargeClass") +@ApiStatus.Internal +@InternalJewelApi +public object DefaultColorPalette { + public val Dark: ThemeColorPalette = + ThemeColorPalette( + gray = + listOf( + Color(0xFF1E1F22), + Color(0xFF2B2D30), + Color(0xFF393B40), + Color(0xFF43454A), + Color(0xFF4E5157), + Color(0xFF5A5D63), + Color(0xFF6F737A), + Color(0xFF868A91), + Color(0xFF9DA0A8), + Color(0xFFB4B8BF), + Color(0xFFCED0D6), + Color(0xFFDFE1E5), + Color(0xFFF0F1F2), + Color(0xFFFFFFFF), + ), + blue = + listOf( + Color(0xFF25324D), + Color(0xFF2E436E), + Color(0xFF35538F), + Color(0xFF375FAD), + Color(0xFF366ACE), + Color(0xFF3574F0), + Color(0xFF467FF2), + Color(0xFF548AF7), + Color(0xFF6B9BFA), + Color(0xFF83ACFC), + Color(0xFF99BBFF), + Color(0xFFB5CEFF), + Color(0xFFD1E0FF), + ), + green = + listOf( + Color(0xFF253627), + Color(0xFF273828), + Color(0xFF375239), + Color(0xFF436946), + Color(0xFF4E8052), + Color(0xFF57965C), + Color(0xFF5FAD65), + Color(0xFF73BD79), + Color(0xFF89CC8E), + Color(0xFFA0DBA5), + Color(0xFFB9EBBD), + Color(0xFFD4FAD7), + ), + yellow = + listOf( + Color(0xFF3D3223), + Color(0xFF5E4D33), + Color(0xFF826A41), + Color(0xFF9E814A), + Color(0xFFBA9752), + Color(0xFFD6AE58), + Color(0xFFF2C55C), + Color(0xFFF5D273), + Color(0xFFF7DE8B), + Color(0xFFFCEBA4), + Color(0xFFFFF6BD), + ), + red = + listOf( + Color(0xFF402929), + Color(0xFF472B2B), + Color(0xFF5E3838), + Color(0xFF7A4343), + Color(0xFF9C4E4E), + Color(0xFFBD5757), + Color(0xFFDB5C5C), + Color(0xFFE37774), + Color(0xFFEB938D), + Color(0xFFF2B1AA), + Color(0xFFF7CCC6), + Color(0xFFFAE3DE), + ), + orange = + listOf( + Color(0xFF45322B), + Color(0xFF614438), + Color(0xFF825845), + Color(0xFFA36B4E), + Color(0xFFC27A53), + Color(0xFFE08855), + Color(0xFFE5986C), + Color(0xFFF0AC81), + Color(0xFFF5BD98), + Color(0xFFFACEAF), + Color(0xFFFFDFC7), + ), + purple = + listOf( + Color(0xFF2F2936), + Color(0xFF3B3147), + Color(0xFF433358), + Color(0xFF583D7A), + Color(0xFF6C469C), + Color(0xFF8150BE), + Color(0xFF955AE0), + Color(0xFFA571E6), + Color(0xFFB589EC), + Color(0xFFC4A0F3), + Color(0xFFD4B8F9), + Color(0xFFE4CEFF), + ), + teal = + listOf( + Color(0xFF1D3838), + Color(0xFF1D3D3B), + Color(0xFF1E4D4A), + Color(0xFF20635D), + Color(0xFF21786F), + Color(0xFF238E82), + Color(0xFF24A394), + Color(0xFF42B1A4), + Color(0xFF60C0B5), + Color(0xFF7DCEC5), + Color(0xFF9BDDD6), + Color(0xFFB9EBE6), + ), + rawMap = + mapOf( + "Gray1" to Color(0xFF1E1F22), + "Gray2" to Color(0xFF2B2D30), + "Gray3" to Color(0xFF393B40), + "Gray4" to Color(0xFF43454A), + "Gray5" to Color(0xFF4E5157), + "Gray6" to Color(0xFF5A5D63), + "Gray7" to Color(0xFF6F737A), + "Gray8" to Color(0xFF868A91), + "Gray9" to Color(0xFF9DA0A8), + "Gray10" to Color(0xFFB4B8BF), + "Gray11" to Color(0xFFCED0D6), + "Gray12" to Color(0xFFDFE1E5), + "Gray13" to Color(0xFFF0F1F2), + "Gray14" to Color(0xFFFFFFFF), + "Blue1" to Color(0xFF25324D), + "Blue2" to Color(0xFF2E436E), + "Blue3" to Color(0xFF35538F), + "Blue4" to Color(0xFF375FAD), + "Blue5" to Color(0xFF366ACE), + "Blue6" to Color(0xFF3574F0), + "Blue7" to Color(0xFF467FF2), + "Blue8" to Color(0xFF548AF7), + "Blue9" to Color(0xFF6B9BFA), + "Blue10" to Color(0xFF83ACFC), + "Blue11" to Color(0xFF99BBFF), + "Blue12" to Color(0xFFB5CEFF), + "Blue13" to Color(0xFFD1E0FF), + "Green1" to Color(0xFF253627), + "Green2" to Color(0xFF273828), + "Green3" to Color(0xFF375239), + "Green4" to Color(0xFF436946), + "Green5" to Color(0xFF4E8052), + "Green6" to Color(0xFF57965C), + "Green7" to Color(0xFF5FAD65), + "Green8" to Color(0xFF73BD79), + "Green9" to Color(0xFF89CC8E), + "Green10" to Color(0xFFA0DBA5), + "Green11" to Color(0xFFB9EBBD), + "Green12" to Color(0xFFD4FAD7), + "Yellow1" to Color(0xFF3D3223), + "Yellow2" to Color(0xFF5E4D33), + "Yellow3" to Color(0xFF826A41), + "Yellow4" to Color(0xFF9E814A), + "Yellow5" to Color(0xFFBA9752), + "Yellow6" to Color(0xFFD6AE58), + "Yellow7" to Color(0xFFF2C55C), + "Yellow8" to Color(0xFFF5D273), + "Yellow9" to Color(0xFFF7DE8B), + "Yellow10" to Color(0xFFFCEBA4), + "Yellow11" to Color(0xFFFFF6BD), + "Red1" to Color(0xFF402929), + "Red2" to Color(0xFF472B2B), + "Red3" to Color(0xFF5E3838), + "Red4" to Color(0xFF7A4343), + "Red5" to Color(0xFF9C4E4E), + "Red6" to Color(0xFFBD5757), + "Red7" to Color(0xFFDB5C5C), + "Red8" to Color(0xFFE37774), + "Red9" to Color(0xFFEB938D), + "Red10" to Color(0xFFF2B1AA), + "Red11" to Color(0xFFF7CCC6), + "Red12" to Color(0xFFFAE3DE), + "Orange1" to Color(0xFF45322B), + "Orange2" to Color(0xFF614438), + "Orange3" to Color(0xFF825845), + "Orange4" to Color(0xFFA36B4E), + "Orange5" to Color(0xFFC27A53), + "Orange6" to Color(0xFFE08855), + "Orange7" to Color(0xFFE5986C), + "Orange8" to Color(0xFFF0AC81), + "Orange9" to Color(0xFFF5BD98), + "Orange10" to Color(0xFFFACEAF), + "Orange11" to Color(0xFFFFDFC7), + "Purple1" to Color(0xFF2F2936), + "Purple2" to Color(0xFF3B3147), + "Purple3" to Color(0xFF433358), + "Purple4" to Color(0xFF583D7A), + "Purple5" to Color(0xFF6C469C), + "Purple6" to Color(0xFF8150BE), + "Purple7" to Color(0xFF955AE0), + "Purple8" to Color(0xFFA571E6), + "Purple9" to Color(0xFFB589EC), + "Purple10" to Color(0xFFC4A0F3), + "Purple11" to Color(0xFFD4B8F9), + "Purple12" to Color(0xFFE4CEFF), + "Teal1" to Color(0xFF1D3838), + "Teal2" to Color(0xFF1D3D3B), + "Teal3" to Color(0xFF1E4D4A), + "Teal4" to Color(0xFF20635D), + "Teal5" to Color(0xFF21786F), + "Teal6" to Color(0xFF238E82), + "Teal7" to Color(0xFF24A394), + "Teal8" to Color(0xFF42B1A4), + "Teal9" to Color(0xFF60C0B5), + "Teal10" to Color(0xFF7DCEC5), + "Teal11" to Color(0xFF9BDDD6), + "Teal12" to Color(0xFFB9EBE6), + ), + isIslands = false, + ) + + public val IslandsDark: ThemeColorPalette = + ThemeColorPalette( + gray = + listOf( + Color(0xFF191A1C), + Color(0xFF212326), + Color(0xFF26282C), + Color(0xFF33353B), + Color(0xFF40434A), + Color(0xFF4C4F56), + Color(0xFF5F6269), + Color(0xFF73767C), + Color(0xFF8B8E94), + Color(0xFF9FA2A8), + Color(0xFFB5B7BD), + Color(0xFFC3C5CB), + Color(0xFFD1D3D9), + Color(0xFFDDDFE4), + Color(0xFFE9EAEE), + Color(0xFFF7F8F9), + ), + blue = + listOf( + Color(0xFF131A28), + Color(0xFF182337), + Color(0xFF1B283F), + Color(0xFF233558), + Color(0xFF2A4371), + Color(0xFF2E4D89), + Color(0xFF2F5EB9), + Color(0xFF3871E1), + Color(0xFF538AF9), + Color(0xFF71A1FE), + Color(0xFF92B7FF), + Color(0xFFA7C5FF), + Color(0xFFBDD3FF), + Color(0xFFD0DFFE), + Color(0xFFE3EBFE), + Color(0xFFF7F8FF), + ), + green = + listOf( + Color(0xFF111C15), + Color(0xFF16261C), + Color(0xFF192C20), + Color(0xFF203B2A), + Color(0xFF274B34), + Color(0xFF29583C), + Color(0xFF2A6E47), + Color(0xFF338555), + Color(0xFF4E9D6C), + Color(0xFF6DB083), + Color(0xFF8EC39D), + Color(0xFFA3CFAE), + Color(0xFFBBDBC2), + Color(0xFFCDE5D1), + Color(0xFFE2EFE2), + Color(0xFFF5FAF3), + ), + red = + listOf( + Color(0xFF291416), + Color(0xFF371B1C), + Color(0xFF3F1E21), + Color(0xFF56272B), + Color(0xFF6D3136), + Color(0xFF80383E), + Color(0xFFA4414A), + Color(0xFFC54E58), + Color(0xFFE4656E), + Color(0xFFF57E84), + Color(0xFFFF9B9F), + Color(0xFFFFB0B2), + Color(0xFFFFC4C5), + Color(0xFFFFD6D6), + Color(0xFFFFE5E5), + Color(0xFFFFF6F5), + ), + yellow = + listOf( + Color(0xFF201810), + Color(0xFF2C2115), + Color(0xFF322517), + Color(0xFF44321D), + Color(0xFF583E21), + Color(0xFF694820), + Color(0xFF875817), + Color(0xFFA56906), + Color(0xFFC28013), + Color(0xFFD59637), + Color(0xFFE4AD5F), + Color(0xFFECBC7B), + Color(0xFFF4CD9A), + Color(0xFFFADBB3), + Color(0xFFFDE7C9), + Color(0xFFFFF6E9), + ), + orange = + listOf( + Color(0xFF261611), + Color(0xFF331D16), + Color(0xFF3B2119), + Color(0xFF4F2C21), + Color(0xFF643829), + Color(0xFF77402F), + Color(0xFF964E37), + Color(0xFFB45E43), + Color(0xFFCF7659), + Color(0xFFE18C71), + Color(0xFFEEA58E), + Color(0xFFF5B6A1), + Color(0xFFFBC7B7), + Color(0xFFFED6CA), + Color(0xFFFFE6DD), + Color(0xFFFFF6F3), + ), + purple = + listOf( + Color(0xFF1C172B), + Color(0xFF261E3C), + Color(0xFF2B2245), + Color(0xFF3A2D5F), + Color(0xFF4A387B), + Color(0xFF574092), + Color(0xFF6C4EBB), + Color(0xFF8060DB), + Color(0xFF967BEF), + Color(0xFFA894F6), + Color(0xFFBBACF9), + Color(0xFFC9BDFA), + Color(0xFFD6CDFB), + Color(0xFFE2DBFC), + Color(0xFFEDE8FD), + Color(0xFFFAF6FE), + ), + teal = + listOf( + Color(0xFF111C1B), + Color(0xFF152624), + Color(0xFF182B2A), + Color(0xFF1E3A38), + Color(0xFF244A46), + Color(0xFF285653), + Color(0xFF2A6C67), + Color(0xFF31827B), + Color(0xFF4B9B93), + Color(0xFF6AAEA6), + Color(0xFF8CC1BA), + Color(0xFFA2CDC7), + Color(0xFFB9D9D4), + Color(0xFFCDE4E0), + Color(0xFFE1EEEC), + Color(0xFFF5F9F8), + ), + rawMap = + mapOf( + "white" to Color(0xFFFFFFFF), + "black" to Color(0xFF000000), + "gray-160" to Color(0xFFF7F8F9), + "gray-150" to Color(0xFFE9EAEE), + "gray-140" to Color(0xFFDDDFE4), + "gray-130" to Color(0xFFD1D3D9), + "gray-120" to Color(0xFFC3C5CB), + "gray-110" to Color(0xFFB5B7BD), + "gray-100" to Color(0xFF9FA2A8), + "gray-90" to Color(0xFF8B8E94), + "gray-80" to Color(0xFF73767C), + "gray-70" to Color(0xFF5F6269), + "gray-60" to Color(0xFF4C4F56), + "gray-50" to Color(0xFF40434A), + "gray-40" to Color(0xFF33353B), + "gray-30" to Color(0xFF26282C), + "gray-20" to Color(0xFF212326), + "gray-10" to Color(0xFF191A1C), + "blue-160" to Color(0xFFF7F8FF), + "blue-150" to Color(0xFFE3EBFE), + "blue-140" to Color(0xFFD0DFFE), + "blue-130" to Color(0xFFBDD3FF), + "blue-120" to Color(0xFFA7C5FF), + "blue-110" to Color(0xFF92B7FF), + "blue-100" to Color(0xFF71A1FE), + "blue-90" to Color(0xFF538AF9), + "blue-80" to Color(0xFF3871E1), + "blue-70" to Color(0xFF2F5EB9), + "blue-60" to Color(0xFF2E4D89), + "blue-50" to Color(0xFF2A4371), + "blue-40" to Color(0xFF233558), + "blue-30" to Color(0xFF1B283F), + "blue-20" to Color(0xFF182337), + "blue-10" to Color(0xFF131A28), + "green-160" to Color(0xFFF5FAF3), + "green-150" to Color(0xFFE2EFE2), + "green-140" to Color(0xFFCDE5D1), + "green-130" to Color(0xFFBBDBC2), + "green-120" to Color(0xFFA3CFAE), + "green-110" to Color(0xFF8EC39D), + "green-100" to Color(0xFF6DB083), + "green-90" to Color(0xFF4E9D6C), + "green-80" to Color(0xFF338555), + "green-70" to Color(0xFF2A6E47), + "green-60" to Color(0xFF29583C), + "green-50" to Color(0xFF274B34), + "green-40" to Color(0xFF203B2A), + "green-30" to Color(0xFF192C20), + "green-20" to Color(0xFF16261C), + "green-10" to Color(0xFF111C15), + "red-160" to Color(0xFFFFF6F5), + "red-150" to Color(0xFFFFE5E5), + "red-140" to Color(0xFFFFD6D6), + "red-130" to Color(0xFFFFC4C5), + "red-120" to Color(0xFFFFB0B2), + "red-110" to Color(0xFFFF9B9F), + "red-100" to Color(0xFFF57E84), + "red-90" to Color(0xFFE4656E), + "red-80" to Color(0xFFC54E58), + "red-70" to Color(0xFFA4414A), + "red-60" to Color(0xFF80383E), + "red-50" to Color(0xFF6D3136), + "red-40" to Color(0xFF56272B), + "red-30" to Color(0xFF3F1E21), + "red-20" to Color(0xFF371B1C), + "red-10" to Color(0xFF291416), + "yellow-160" to Color(0xFFFFF6E9), + "yellow-150" to Color(0xFFFDE7C9), + "yellow-140" to Color(0xFFFADBB3), + "yellow-130" to Color(0xFFF4CD9A), + "yellow-120" to Color(0xFFECBC7B), + "yellow-110" to Color(0xFFE4AD5F), + "yellow-100" to Color(0xFFD59637), + "yellow-90" to Color(0xFFC28013), + "yellow-80" to Color(0xFFA56906), + "yellow-70" to Color(0xFF875817), + "yellow-60" to Color(0xFF694820), + "yellow-50" to Color(0xFF583E21), + "yellow-40" to Color(0xFF44321D), + "yellow-30" to Color(0xFF322517), + "yellow-20" to Color(0xFF2C2115), + "yellow-10" to Color(0xFF201810), + "orange-160" to Color(0xFFFFF6F3), + "orange-150" to Color(0xFFFFE6DD), + "orange-140" to Color(0xFFFED6CA), + "orange-130" to Color(0xFFFBC7B7), + "orange-120" to Color(0xFFF5B6A1), + "orange-110" to Color(0xFFEEA58E), + "orange-100" to Color(0xFFE18C71), + "orange-90" to Color(0xFFCF7659), + "orange-80" to Color(0xFFB45E43), + "orange-70" to Color(0xFF964E37), + "orange-60" to Color(0xFF77402F), + "orange-50" to Color(0xFF643829), + "orange-40" to Color(0xFF4F2C21), + "orange-30" to Color(0xFF3B2119), + "orange-20" to Color(0xFF331D16), + "orange-10" to Color(0xFF261611), + "purple-160" to Color(0xFFFAF6FE), + "purple-150" to Color(0xFFEDE8FD), + "purple-140" to Color(0xFFE2DBFC), + "purple-130" to Color(0xFFD6CDFB), + "purple-120" to Color(0xFFC9BDFA), + "purple-110" to Color(0xFFBBACF9), + "purple-100" to Color(0xFFA894F6), + "purple-90" to Color(0xFF967BEF), + "purple-80" to Color(0xFF8060DB), + "purple-70" to Color(0xFF6C4EBB), + "purple-60" to Color(0xFF574092), + "purple-50" to Color(0xFF4A387B), + "purple-40" to Color(0xFF3A2D5F), + "purple-30" to Color(0xFF2B2245), + "purple-20" to Color(0xFF261E3C), + "purple-10" to Color(0xFF1C172B), + "teal-160" to Color(0xFFF5F9F8), + "teal-150" to Color(0xFFE1EEEC), + "teal-140" to Color(0xFFCDE4E0), + "teal-130" to Color(0xFFB9D9D4), + "teal-120" to Color(0xFFA2CDC7), + "teal-110" to Color(0xFF8CC1BA), + "teal-100" to Color(0xFF6AAEA6), + "teal-90" to Color(0xFF4B9B93), + "teal-80" to Color(0xFF31827B), + "teal-70" to Color(0xFF2A6C67), + "teal-60" to Color(0xFF285653), + "teal-50" to Color(0xFF244A46), + "teal-40" to Color(0xFF1E3A38), + "teal-30" to Color(0xFF182B2A), + "teal-20" to Color(0xFF152624), + "teal-10" to Color(0xFF111C1B), + "transparent-white-10" to Color(0xFFFFFFFF10), + "transparent-white-20" to Color(0xFFFFFFFF17), + "transparent-white-30" to Color(0xFFFFFFFF21), + "transparent-white-40" to Color(0xFFFFFFFF29), + "transparent-white-50" to Color(0xFFFFFFFF3B), + "transparent-black-10" to Color(0xFF00000008), + "transparent-black-20" to Color(0xFF00000012), + "transparent-black-30" to Color(0xFF00000020), + "transparent-black-40" to Color(0xFF00000030), + "transparent-black-50" to Color(0xFF00000045), + "transparent" to Color(0xFF191A1C00), + "text-default" to Color(0xFFD1D3D9), + "text-muted" to Color(0xFF9FA2A8), + "text-secondary" to Color(0xFF73767C), + "text-disabled" to Color(0xFF4C4F56), + "text-over-accent" to Color(0xFFFFFFFF), + "text-over-accent-inverted" to Color(0xFF000000), + "text-link" to Color(0xFF71A1FE), + "text-error" to Color(0xFFF57E84), + "text-warning" to Color(0xFFD59637), + "text-success" to Color(0xFF6DB083), + "editor-text" to Color(0xFFBCBEC4), + "layer-0-bg" to Color(0xFF191A1C), + "layer-0-border" to Color(0xFF26282C), + "layer-0-bg-inline" to Color(0xFF212326), + "layer-0-border-inline" to Color(0xFF26282C), + "layer-1-bg" to Color(0xFF26282C), + "layer-1-border" to Color(0xFF33353B), + "layer-1-bg-inline" to Color(0xFF33353B), + "layer-1-border-inline" to Color(0xFF40434A), + "layer-2-bg" to Color(0xFF33353B), + "layer-2-bg-inline" to Color(0xFF40434A), + "layer-2-border" to Color(0xFF40434A), + "layer-2-border-inline" to Color(0xFF4C4F56), + "accent-brand-bg" to Color(0xFF3871E1), + "accent-brand-border" to Color(0xFF3871E1), + "accent-brand-bg-secondary" to Color(0xFF233558), + "accent-brand-border-secondary" to Color(0xFF2E4D89), + "accent-error-bg" to Color(0xFFC54E58), + "accent-error-border" to Color(0xFFC54E58), + "accent-error-bg-secondary" to Color(0xFF56272B), + "accent-error-border-secondary" to Color(0xFF80383E), + "accent-warning-bg" to Color(0xFFA56906), + "accent-warning-border" to Color(0xFFA56906), + "accent-warning-bg-secondary" to Color(0xFF44321D), + "accent-warning-border-secondary" to Color(0xFF694820), + "accent-success-bg" to Color(0xFF338555), + "accent-success-border" to Color(0xFF338555), + "accent-success-bg-secondary" to Color(0xFF203B2A), + "accent-success-border-secondary" to Color(0xFF29583C), + "accent-neutral-bg" to Color(0xFF73767C), + "accent-ai-bg" to Color(0xFF261E3C), + "accent-ai-border" to Color(0xFF4A387B), + "core-bg-transparent-hovered" to Color(0xFFFFFFFF17), + "core-bg-transparent-pressed" to Color(0xFFFFFFFF29), + "core-border-transparent" to Color(0xFFFFFFFF21), + "dialog-bg" to Color(0xFF191A1C), + "dialog-bg-inline" to Color(0xFF212326), + "dialog-border" to Color(0xFF26282C), + "popup-bg" to Color(0xFF26282C), + "popup-bg-inline" to Color(0xFF26282C), + "popup-border" to Color(0xFF33353B), + "popup-border-inline" to Color(0xFF33353B), + "editor-bg" to Color(0xFF191A1C), + "editor-bg-inline" to Color(0xFF212326), + "editor-border" to Color(0xFF26282C), + "editor-border-inline" to Color(0xFF26282C), + "editor-border-alt" to Color(0xFF33353B), + "tool-window-bg" to Color(0xFF191A1C), + "tool-window-bg-inline" to Color(0xFF212326), + "tool-window-bg-alt" to Color(0xFF212326), + "tool-window-border" to Color(0xFF26282C), + "tool-window-border-inline" to Color(0xFF26282C), + "main-window-bg" to Color(0xFF26282C), + "main-window-bg-alt" to Color(0xFF33353B), + "main-window-border" to Color(0xFF40434A), + "control-bg" to Color(0xFF191A1C), + "control-bg-disabled" to Color(0xFF191A1C), + "control-bg-raised" to Color(0xFF26282C), + "control-border" to Color(0xFF40434A), + "control-border-disabled" to Color(0xFF33353B), + "control-border-raised" to Color(0xFF5F6269), + "control-border-over-accent" to Color(0xFFFFFFFF3B), + "control-bg-small" to Color(0xFF40434A), + "control-bg-small-disabled" to Color(0xFF33353B), + "control-border-small" to Color(0xFF5F6269), + "control-brand-bg" to Color(0xFF3871E1), + "control-brand-border" to Color(0xFF3871E1), + "control-error-bg" to Color(0xFFC54E58), + "control-error-border" to Color(0xFFC54E58), + "control-error-border-secondary" to Color(0xFF6D3136), + "control-warning-bg" to Color(0xFFA56906), + "control-warning-border" to Color(0xFFA56906), + "control-warning-border-secondary" to Color(0xFF583E21), + "control-success-bg" to Color(0xFF338555), + "control-success-border" to Color(0xFF338555), + "toolbar-bg-hovered" to Color(0xFFFFFFFF17), + "toolbar-bg-pressed" to Color(0xFFFFFFFF29), + "toolbar-border" to Color(0xFFFFFFFF21), + "toolbar-selected-bg" to Color(0xFF2E4D89), + "toolbar-selected-bg-hovered" to Color(0xFF2F5EB9), + "toolbar-selected-bg-active" to Color(0xFF3871E1), + "toolbar-run-bg" to Color(0xFF338555), + "toolbar-run-bg-hovered" to Color(0xFF2A6E47), + "toolbar-stop-bg" to Color(0xFFC54E58), + "toolbar-stop-bg-hovered" to Color(0xFFA4414A), + "feedback-bg" to Color(0xFF33353B), + "feedback-border" to Color(0xFF33353B), + "feedback-bg-inline" to Color(0xFF191A1C), + "feedback-brand-bg" to Color(0xFF233558), + "feedback-brand-border" to Color(0xFF2E4D89), + "feedback-success-bg" to Color(0xFF203B2A), + "feedback-success-border" to Color(0xFF29583C), + "feedback-warning-bg" to Color(0xFF44321D), + "feedback-warning-border" to Color(0xFF694820), + "feedback-error-bg" to Color(0xFF56272B), + "feedback-error-border" to Color(0xFF80383E), + "feedback-control-border" to Color(0xFFFFFFFF3B), + "feedback-ai-bg" to Color(0xFF261E3C), + "feedback-ai-border" to Color(0xFF4A387B), + "selection-bg-active" to Color(0xFF2A4371), + "selection-bg-active-muted" to Color(0xFF233558), + "selection-bg-inactive" to Color(0xFF33353B), + "selection-bg-hovered" to Color(0xFFFFFFFF10), + "tab-selected-bg-active" to Color(0xFF233558), + "tab-selected-bg-inactive" to Color(0xFF26282C), + "tab-selected-border-active" to Color(0xFF2E4D89), + "tab-selected-border-inactive" to Color(0xFF40434A), + "tab-bg-hovered" to Color(0xFFFFFFFF17), + "tab-file-color-mask-bg" to Color(0xFF1E1F2280), + "got-it-bg" to Color(0xFF2E4D89), + "got-it-border" to Color(0xFF2E4D89), + "got-it-text-link" to Color(0xFF92B7FF), + "got-it-text-step" to Color(0xFF8B8E94), + "got-it-shortcut-bg" to Color(0xFF233558), + "got-it-code-border" to Color(0xFFFFFFFF70), + "got-it-contrast-button-bg" to Color(0xFF233558), + "inlay-bg" to Color(0xFFFFFFFF21), + "inlay-border" to Color(0xFFFFFFFF3B), + "toggle-off-bg" to Color(0xFF191A1C), + "toggle-button-bg" to Color(0xFF5F6269), + "toggle-border" to Color(0xFF5F6269), + "editor-floating-toolbar-bg" to Color(0xFF33353B), + "popup-completion-match-text" to Color(0xFF538AF9), + "presentation-assistant-bg" to Color(0xFF2E4D89), + "search-match-bg" to Color(0xFFBA9752), + "tree-indent-guide-border" to Color(0xFF33353B), + "icon-default-stroke" to Color(0xFFC3C5CB), + "icon-over-accent" to Color(0xFFFFFFFF), + "icon-green-stroke" to Color(0xFF4E9D6C), + "grad-hor-left" to Color(0xFF2B2C3133), + "grad-hor-right" to Color(0xFF2B2C314D), + "grad-ver-top" to Color(0xFF2B2C311A), + "grad-ver-bottom" to Color(0xFF2B2C3180), + "grad-g1-amber-a1" to Color(0xFF724037FF), + "grad-g1-amber-a1-transparent" to Color(0xFF72403700), + "grad-g1-amber-a1-secondary" to Color(0xFF311C2B), + "grad-g1-amber-a2" to Color(0xFF36212B), + "grad-g1-amber-bg" to Color(0xFF291D19), + "grad-g2-rust-a1" to Color(0xFF5F461CFF), + "grad-g2-rust-a1-transparent" to Color(0xFF5F461C00), + "grad-g2-rust-a1-secondary" to Color(0xFF25220E), + "grad-g2-rust-a2" to Color(0xFF2E250F), + "grad-g2-rust-bg" to Color(0xFF21240F), + "grad-g3-olive-a1" to Color(0xFF4F4F1Cff), + "grad-g3-olive-a1-transparent" to Color(0xFF4F4F1C00), + "grad-g3-olive-a1-secondary" to Color(0xFF162226), + "grad-g3-olive-a2" to Color(0xFF212B16), + "grad-g3-olive-bg" to Color(0xFF172623), + "grad-g4-sky-a1" to Color(0xFF254D6FFF), + "grad-g4-sky-a1-transparent" to Color(0xFF254D6F00), + "grad-g4-sky-a1-secondary" to Color(0xFF1A2033), + "grad-g4-sky-a2" to Color(0xFF202341), + "grad-g4-sky-bg" to Color(0xFF1D1F2F), + "grad-g5-cobalt-a1" to Color(0xFF3F448DFF), + "grad-g5-cobalt-a1-transparent" to Color(0xFF3F448D00), + "grad-g5-cobalt-a1-secondary" to Color(0xFF182230), + "grad-g5-cobalt-a2" to Color(0xFF2D213B), + "grad-g5-cobalt-bg" to Color(0xFF1A232D), + "grad-g6-plum-a1" to Color(0xFF723B56FF), + "grad-g6-plum-a1-transparent" to Color(0xFF723B5600), + "grad-g6-plum-a1-secondary" to Color(0xFF271E29), + "grad-g6-plum-a2" to Color(0xFF30223A), + "grad-g6-plum-bg" to Color(0xFF272026), + "grad-g7-violet-a1" to Color(0xFF633D75FF), + "grad-g7-violet-a1-transparent" to Color(0xFF633D7500), + "grad-g7-violet-a1-secondary" to Color(0xFF21213B), + "grad-g7-violet-a2" to Color(0xFF202441), + "grad-g7-violet-bg" to Color(0xFF1C2235), + "grad-g8-ocean-a1" to Color(0xFF22534BFF), + "grad-g8-ocean-a1-transparent" to Color(0xFF22534B00), + "grad-g8-ocean-a1-secondary" to Color(0xFF162522), + "grad-g8-ocean-a2" to Color(0xFF162737), + "grad-g8-ocean-bg" to Color(0xFF1A222E), + "grad-g9-grass-a1" to Color(0xFF2D522EFF), + "grad-g9-grass-a1-transparent" to Color(0xFF2D522E00), + "grad-g9-grass-a1-secondary" to Color(0xFF1E2315), + "grad-g9-grass-a2" to Color(0xFF1B2921), + "grad-g9-grass-bg" to Color(0xFF22231A), + ), + isIslands = true, + ) + + public val IslandsLight: ThemeColorPalette = + ThemeColorPalette( + gray = + listOf( + Color(0xFF191A1C), + Color(0xFF212326), + Color(0xFF26282C), + Color(0xFF33353B), + Color(0xFF40434A), + Color(0xFF4C4F56), + Color(0xFF5F6269), + Color(0xFF73767C), + Color(0xFF8B8E94), + Color(0xFF9FA2A8), + Color(0xFFB5B7BD), + Color(0xFFC3C5CB), + Color(0xFFD1D3D9), + Color(0xFFDDDFE4), + Color(0xFFE9EAEE), + Color(0xFFF7F8F9), + ), + blue = + listOf( + Color(0xFF131A28), + Color(0xFF182337), + Color(0xFF1B283F), + Color(0xFF233558), + Color(0xFF2A4371), + Color(0xFF2E4D89), + Color(0xFF2F5EB9), + Color(0xFF3871E1), + Color(0xFF538AF9), + Color(0xFF71A1FE), + Color(0xFF92B7FF), + Color(0xFFA7C5FF), + Color(0xFFBDD3FF), + Color(0xFFD0DFFE), + Color(0xFFE3EBFE), + Color(0xFFF7F8FF), + ), + green = + listOf( + Color(0xFF111C15), + Color(0xFF16261C), + Color(0xFF192C20), + Color(0xFF203B2A), + Color(0xFF274B34), + Color(0xFF29583C), + Color(0xFF2A6E47), + Color(0xFF338555), + Color(0xFF4E9D6C), + Color(0xFF6DB083), + Color(0xFF8EC39D), + Color(0xFFA3CFAE), + Color(0xFFBBDBC2), + Color(0xFFCDE5D1), + Color(0xFFE2EFE2), + Color(0xFFF5FAF3), + ), + red = + listOf( + Color(0xFF291416), + Color(0xFF371B1C), + Color(0xFF3F1E21), + Color(0xFF56272B), + Color(0xFF6D3136), + Color(0xFF80383E), + Color(0xFFA4414A), + Color(0xFFC54E58), + Color(0xFFE4656E), + Color(0xFFF57E84), + Color(0xFFFF9B9F), + Color(0xFFFFB0B2), + Color(0xFFFFC4C5), + Color(0xFFFFD6D6), + Color(0xFFFFE5E5), + Color(0xFFFFF6F5), + ), + yellow = + listOf( + Color(0xFF201810), + Color(0xFF2C2115), + Color(0xFF322517), + Color(0xFF44321D), + Color(0xFF583E21), + Color(0xFF694820), + Color(0xFF875817), + Color(0xFFA56906), + Color(0xFFC28013), + Color(0xFFD59637), + Color(0xFFE4AD5F), + Color(0xFFECBC7B), + Color(0xFFF4CD9A), + Color(0xFFFADBB3), + Color(0xFFFDE7C9), + Color(0xFFFFF6E9), + ), + orange = + listOf( + Color(0xFF261611), + Color(0xFF331D16), + Color(0xFF3B2119), + Color(0xFF4F2C21), + Color(0xFF643829), + Color(0xFF77402F), + Color(0xFF964E37), + Color(0xFFB45E43), + Color(0xFFCF7659), + Color(0xFFE18C71), + Color(0xFFEEA58E), + Color(0xFFF5B6A1), + Color(0xFFFBC7B7), + Color(0xFFFED6CA), + Color(0xFFFFE6DD), + Color(0xFFFFF6F3), + ), + purple = + listOf( + Color(0xFF1C172B), + Color(0xFF261E3C), + Color(0xFF2B2245), + Color(0xFF3A2D5F), + Color(0xFF4A387B), + Color(0xFF574092), + Color(0xFF6C4EBB), + Color(0xFF8060DB), + Color(0xFF967BEF), + Color(0xFFA894F6), + Color(0xFFBBACF9), + Color(0xFFC9BDFA), + Color(0xFFD6CDFB), + Color(0xFFE2DBFC), + Color(0xFFEDE8FD), + Color(0xFFFAF6FE), + ), + teal = + listOf( + Color(0xFF111C1B), + Color(0xFF152624), + Color(0xFF182B2A), + Color(0xFF1E3A38), + Color(0xFF244A46), + Color(0xFF285653), + Color(0xFF2A6C67), + Color(0xFF31827B), + Color(0xFF4B9B93), + Color(0xFF6AAEA6), + Color(0xFF8CC1BA), + Color(0xFFA2CDC7), + Color(0xFFB9D9D4), + Color(0xFFCDE4E0), + Color(0xFFE1EEEC), + Color(0xFFF5F9F8), + ), + rawMap = + mapOf( + "white" to Color(0xFFFFFFFF), + "black" to Color(0xFF000000), + "gray-160" to Color(0xFFF7F8F9), + "gray-150" to Color(0xFFE9EAEE), + "gray-140" to Color(0xFFDDDFE4), + "gray-130" to Color(0xFFD1D3D9), + "gray-120" to Color(0xFFC3C5CB), + "gray-110" to Color(0xFFB5B7BD), + "gray-100" to Color(0xFF9FA2A8), + "gray-90" to Color(0xFF8B8E94), + "gray-80" to Color(0xFF73767C), + "gray-70" to Color(0xFF5F6269), + "gray-60" to Color(0xFF4C4F56), + "gray-50" to Color(0xFF40434A), + "gray-40" to Color(0xFF33353B), + "gray-30" to Color(0xFF26282C), + "gray-20" to Color(0xFF212326), + "gray-10" to Color(0xFF191A1C), + "blue-160" to Color(0xFFF7F8FF), + "blue-150" to Color(0xFFE3EBFE), + "blue-140" to Color(0xFFD0DFFE), + "blue-130" to Color(0xFFBDD3FF), + "blue-120" to Color(0xFFA7C5FF), + "blue-110" to Color(0xFF92B7FF), + "blue-100" to Color(0xFF71A1FE), + "blue-90" to Color(0xFF538AF9), + "blue-80" to Color(0xFF3871E1), + "blue-70" to Color(0xFF2F5EB9), + "blue-60" to Color(0xFF2E4D89), + "blue-50" to Color(0xFF2A4371), + "blue-40" to Color(0xFF233558), + "blue-30" to Color(0xFF1B283F), + "blue-20" to Color(0xFF182337), + "blue-10" to Color(0xFF131A28), + "green-160" to Color(0xFFF5FAF3), + "green-150" to Color(0xFFE2EFE2), + "green-140" to Color(0xFFCDE5D1), + "green-130" to Color(0xFFBBDBC2), + "green-120" to Color(0xFFA3CFAE), + "green-110" to Color(0xFF8EC39D), + "green-100" to Color(0xFF6DB083), + "green-90" to Color(0xFF4E9D6C), + "green-80" to Color(0xFF338555), + "green-70" to Color(0xFF2A6E47), + "green-60" to Color(0xFF29583C), + "green-50" to Color(0xFF274B34), + "green-40" to Color(0xFF203B2A), + "green-30" to Color(0xFF192C20), + "green-20" to Color(0xFF16261C), + "green-10" to Color(0xFF111C15), + "red-160" to Color(0xFFFFF6F5), + "red-150" to Color(0xFFFFE5E5), + "red-140" to Color(0xFFFFD6D6), + "red-130" to Color(0xFFFFC4C5), + "red-120" to Color(0xFFFFB0B2), + "red-110" to Color(0xFFFF9B9F), + "red-100" to Color(0xFFF57E84), + "red-90" to Color(0xFFE4656E), + "red-80" to Color(0xFFC54E58), + "red-70" to Color(0xFFA4414A), + "red-60" to Color(0xFF80383E), + "red-50" to Color(0xFF6D3136), + "red-40" to Color(0xFF56272B), + "red-30" to Color(0xFF3F1E21), + "red-20" to Color(0xFF371B1C), + "red-10" to Color(0xFF291416), + "yellow-160" to Color(0xFFFFF6E9), + "yellow-150" to Color(0xFFFDE7C9), + "yellow-140" to Color(0xFFFADBB3), + "yellow-130" to Color(0xFFF4CD9A), + "yellow-120" to Color(0xFFECBC7B), + "yellow-110" to Color(0xFFE4AD5F), + "yellow-100" to Color(0xFFD59637), + "yellow-90" to Color(0xFFC28013), + "yellow-80" to Color(0xFFA56906), + "yellow-70" to Color(0xFF875817), + "yellow-60" to Color(0xFF694820), + "yellow-50" to Color(0xFF583E21), + "yellow-40" to Color(0xFF44321D), + "yellow-30" to Color(0xFF322517), + "yellow-20" to Color(0xFF2C2115), + "yellow-10" to Color(0xFF201810), + "orange-160" to Color(0xFFFFF6F3), + "orange-150" to Color(0xFFFFE6DD), + "orange-140" to Color(0xFFFED6CA), + "orange-130" to Color(0xFFFBC7B7), + "orange-120" to Color(0xFFF5B6A1), + "orange-110" to Color(0xFFEEA58E), + "orange-100" to Color(0xFFE18C71), + "orange-90" to Color(0xFFCF7659), + "orange-80" to Color(0xFFB45E43), + "orange-70" to Color(0xFF964E37), + "orange-60" to Color(0xFF77402F), + "orange-50" to Color(0xFF643829), + "orange-40" to Color(0xFF4F2C21), + "orange-30" to Color(0xFF3B2119), + "orange-20" to Color(0xFF331D16), + "orange-10" to Color(0xFF261611), + "purple-160" to Color(0xFFFAF6FE), + "purple-150" to Color(0xFFEDE8FD), + "purple-140" to Color(0xFFE2DBFC), + "purple-130" to Color(0xFFD6CDFB), + "purple-120" to Color(0xFFC9BDFA), + "purple-110" to Color(0xFFBBACF9), + "purple-100" to Color(0xFFA894F6), + "purple-90" to Color(0xFF967BEF), + "purple-80" to Color(0xFF8060DB), + "purple-70" to Color(0xFF6C4EBB), + "purple-60" to Color(0xFF574092), + "purple-50" to Color(0xFF4A387B), + "purple-40" to Color(0xFF3A2D5F), + "purple-30" to Color(0xFF2B2245), + "purple-20" to Color(0xFF261E3C), + "purple-10" to Color(0xFF1C172B), + "teal-160" to Color(0xFFF5F9F8), + "teal-150" to Color(0xFFE1EEEC), + "teal-140" to Color(0xFFCDE4E0), + "teal-130" to Color(0xFFB9D9D4), + "teal-120" to Color(0xFFA2CDC7), + "teal-110" to Color(0xFF8CC1BA), + "teal-100" to Color(0xFF6AAEA6), + "teal-90" to Color(0xFF4B9B93), + "teal-80" to Color(0xFF31827B), + "teal-70" to Color(0xFF2A6C67), + "teal-60" to Color(0xFF285653), + "teal-50" to Color(0xFF244A46), + "teal-40" to Color(0xFF1E3A38), + "teal-30" to Color(0xFF182B2A), + "teal-20" to Color(0xFF152624), + "teal-10" to Color(0xFF111C1B), + "transparent-white-10" to Color(0xFFFFFFFF10), + "transparent-white-20" to Color(0xFFFFFFFF17), + "transparent-white-30" to Color(0xFFFFFFFF21), + "transparent-white-40" to Color(0xFFFFFFFF29), + "transparent-white-50" to Color(0xFFFFFFFF45), + "transparent-black-10" to Color(0xFF00000008), + "transparent-black-20" to Color(0xFF00000012), + "transparent-black-30" to Color(0xFF00000020), + "transparent-black-40" to Color(0xFF00000030), + "transparent-black-50" to Color(0xFF00000045), + "transparent" to Color(0xFFFFFFFF00), + "text-default" to Color(0xFF000000), + "text-muted" to Color(0xFF5F6269), + "text-secondary" to Color(0xFF73767C), + "text-disabled" to Color(0xFF9FA2A8), + "text-over-accent" to Color(0xFFFFFFFF), + "text-over-accent-inverted" to Color(0xFF000000), + "text-link" to Color(0xFF2F5EB9), + "text-error" to Color(0xFFC54E58), + "text-warning" to Color(0xFFA56906), + "text-success" to Color(0xFF338555), + "editor-text" to Color(0xFF080808), + "layer-0-bg" to Color(0xFFE9EAEE), + "layer-0-bg-inline" to Color(0xFFF7F8F9), + "layer-0-border" to Color(0xFFD1D3D9), + "layer-0-border-inline" to Color(0xFFE9EAEE), + "layer-1-bg" to Color(0xFFF7F8F9), + "layer-1-bg-inline" to Color(0xFFFFFFFF), + "layer-1-border" to Color(0xFFDDDFE4), + "layer-1-border-inline" to Color(0xFFE9EAEE), + "layer-2-bg" to Color(0xFFFFFFFF), + "layer-2-bg-inline" to Color(0xFFF7F8F9), + "layer-2-border" to Color(0xFFE9EAEE), + "layer-2-border-inline" to Color(0xFFE9EAEE), + "accent-brand-bg" to Color(0xFF3871E1), + "accent-brand-border" to Color(0xFF3871E1), + "accent-brand-bg-secondary" to Color(0xFFF7F8FF), + "accent-brand-border-secondary" to Color(0xFFBDD3FF), + "accent-error-bg" to Color(0xFFE4656E), + "accent-error-border" to Color(0xFFE4656E), + "accent-error-bg-secondary" to Color(0xFFFFF6F5), + "accent-error-border-secondary" to Color(0xFFFFC4C5), + "accent-warning-bg" to Color(0xFFC28013), + "accent-warning-border" to Color(0xFFC28013), + "accent-warning-bg-secondary" to Color(0xFFFFF6E9), + "accent-warning-border-secondary" to Color(0xFFF4CD9A), + "accent-success-bg" to Color(0xFF4E9D6C), + "accent-success-border" to Color(0xFF4E9D6C), + "accent-success-bg-secondary" to Color(0xFFF5FAF3), + "accent-success-border-secondary" to Color(0xFFBBDBC2), + "accent-neutral-bg" to Color(0xFF8B8E94), + "accent-ai-bg" to Color(0xFFEDE8FD), + "accent-ai-border" to Color(0xFFA894F6), + "core-bg-transparent-hovered" to Color(0xFF00000012), + "core-bg-transparent-pressed" to Color(0xFF00000020), + "core-border-transparent" to Color(0xFF00000020), + "dialog-bg" to Color(0xFFF7F8F9), + "dialog-bg-inline" to Color(0xFFFFFFFF), + "dialog-border" to Color(0xFFE9EAEE), + "popup-bg" to Color(0xFFFFFFFF), + "popup-bg-inline" to Color(0xFFF7F8F9), + "popup-border" to Color(0xFFE9EAEE), + "popup-border-inline" to Color(0xFFE9EAEE), + "editor-bg" to Color(0xFFFFFFFF), + "editor-bg-inline" to Color(0xFFF7F8F9), + "editor-border" to Color(0xFFE9EAEE), + "editor-border-inline" to Color(0xFFE9EAEE), + "editor-border-alt" to Color(0xFFE8E9ED), + "tool-window-bg" to Color(0xFFFFFFFF), + "tool-window-bg-inline" to Color(0xFFF7F8F9), + "tool-window-bg-alt" to Color(0xFFF7F6F8), + "tool-window-border" to Color(0xFFE9EAEE), + "tool-window-border-inline" to Color(0xFFE9EAEE), + "main-window-bg" to Color(0xFFE9EAEE), + "main-window-bg-alt" to Color(0xFFE8E8EB), + "main-window-border" to Color(0xFFD1D3D9), + "control-bg" to Color(0xFFFFFFFF), + "control-bg-disabled" to Color(0xFFF7F8F9), + "control-bg-raised" to Color(0xFFFFFFFF), + "control-border" to Color(0xFFD1D3D9), + "control-border-disabled" to Color(0xFFDDDFE4), + "control-border-raised" to Color(0xFFB5B7BD), + "control-border-over-accent" to Color(0xFFFFFFFF45), + "control-bg-small" to Color(0xFFDDDFE4), + "control-bg-small-disabled" to Color(0xFFF7F8F9), + "control-border-small" to Color(0xFFB5B7BD), + "control-brand-bg" to Color(0xFF3871E1), + "control-brand-border" to Color(0xFF3871E1), + "control-error-bg" to Color(0xFFE4656E), + "control-error-border" to Color(0xFFE4656E), + "control-error-border-secondary" to Color(0xFFFFC4C5), + "control-warning-bg" to Color(0xFFC28013), + "control-warning-border" to Color(0xFFC28013), + "control-warning-border-secondary" to Color(0xFFF4CD9A), + "control-success-bg" to Color(0xFF4E9D6C), + "control-success-border" to Color(0xFF4E9D6C), + "toolbar-bg-hovered" to Color(0xFF00000012), + "toolbar-bg-pressed" to Color(0xFF00000020), + "toolbar-border" to Color(0xFF00000020), + "toolbar-selected-bg" to Color(0xFFD0DFFE), + "toolbar-selected-bg-hovered" to Color(0xFFBDD3FF), + "toolbar-selected-bg-active" to Color(0xFF3871E1), + "toolbar-run-bg" to Color(0xFF4E9D6C), + "toolbar-run-bg-hovered" to Color(0xFF338555), + "toolbar-stop-bg" to Color(0xFFE4656E), + "toolbar-stop-bg-hovered" to Color(0xFFC54E58), + "feedback-bg" to Color(0xFFFFFFFF), + "feedback-border" to Color(0xFFD1D3D9), + "feedback-bg-inline" to Color(0xFFF7F8F9), + "feedback-brand-bg" to Color(0xFFF7F8FF), + "feedback-brand-border" to Color(0xFFBDD3FF), + "feedback-success-bg" to Color(0xFFF5FAF3), + "feedback-success-border" to Color(0xFFBBDBC2), + "feedback-warning-bg" to Color(0xFFFFF6E9), + "feedback-warning-border" to Color(0xFFF4CD9A), + "feedback-error-bg" to Color(0xFFFFF6F5), + "feedback-error-border" to Color(0xFFFFC4C5), + "feedback-control-border" to Color(0xFFD1D3D9), + "feedback-ai-bg" to Color(0xFFEDE8FD), + "feedback-ai-border" to Color(0xFFA894F6), + "selection-bg-active" to Color(0xFFD0DFFE), + "selection-bg-active-muted" to Color(0xFFE3EBFE), + "selection-bg-inactive" to Color(0xFFE9EAEE), + "selection-bg-hovered" to Color(0xFF00000008), + "tab-selected-bg-active" to Color(0xFFE3EBFE), + "tab-selected-bg-inactive" to Color(0xFFE9EAEE), + "tab-selected-border-active" to Color(0xFFA7C5FF), + "tab-selected-border-inactive" to Color(0xFFD1D3D9), + "tab-bg-hovered" to Color(0xFF00000012), + "tab-file-color-mask-bg" to Color(0xFFFFFFFF80), + "got-it-bg" to Color(0xFFFFFFFF), + "got-it-border" to Color(0xFFD1D3D9), + "got-it-text-link" to Color(0xFF2F5EB9), + "got-it-text-step" to Color(0xFF8B8E94), + "got-it-shortcut-bg" to Color(0xFFDDDFE4), + "got-it-code-border" to Color(0xFF00000045), + "got-it-contrast-button-bg" to Color(0xFF3871E1), + "inlay-bg" to Color(0xFF00000012), + "inlay-border" to Color(0xFF00000045), + "toggle-off-bg" to Color(0xFFF7F8F9), + "toggle-button-bg" to Color(0xFFC3C5CB), + "toggle-border" to Color(0xFFC3C5CB), + "editor-floating-toolbar-bg" to Color(0xFFE9EAEE), + "popup-completion-match-text" to Color(0xFF2F5EB9), + "presentation-assistant-bg" to Color(0xFF26282C), + "search-match-bg" to Color(0xFFFEE6B1), + "tree-indent-guide-border" to Color(0xFFE9EAEE), + "icon-default-stroke" to Color(0xFF73767C), + "icon-over-accent" to Color(0xFFFFFFFF), + "icon-green-stroke" to Color(0xFF338555), + "grad-hor-left" to Color(0xFFEBEBED33), + "grad-hor-right" to Color(0xFFEBEBED4D), + "grad-ver-top" to Color(0xFFEBEBED1A), + "grad-ver-bottom" to Color(0xFFEBEBED80), + "grad-g1-amber-a1" to Color(0xFFFCDFDAFF), + "grad-g1-amber-a1-transparent" to Color(0xFFFCDFDA00), + "grad-g1-amber-a1-secondary" to Color(0xFFF8E1D6), + "grad-g1-amber-a2" to Color(0xFFF8E2E7), + "grad-g1-amber-bg" to Color(0xFFF4E8DC), + "grad-g2-rust-a1" to Color(0xFFF5E5D1FF), + "grad-g2-rust-a1-transparent" to Color(0xFFF5E5D100), + "grad-g2-rust-a1-secondary" to Color(0xFFF3E5D3), + "grad-g2-rust-a2" to Color(0xFFF8E6E3), + "grad-g2-rust-bg" to Color(0xFFF7E3DA), + "grad-g3-olive-a1" to Color(0xFFE6F0C7ff), + "grad-g3-olive-a1-transparent" to Color(0xFFE6F0C700), + "grad-g3-olive-a1-secondary" to Color(0xFFDFEBD7), + "grad-g3-olive-a2" to Color(0xFFD1EAD8), + "grad-g3-olive-bg" to Color(0xFFDAE4D2), + "grad-g4-sky-a1" to Color(0xFFC7E5FEFF), + "grad-g4-sky-a1-transparent" to Color(0xFFC7E5FE00), + "grad-g4-sky-a1-secondary" to Color(0xFFC9DCF2), + "grad-g4-sky-a2" to Color(0xFFD9DFF2), + "grad-g4-sky-bg" to Color(0xFFC9DAF3), + "grad-g5-cobalt-a1" to Color(0xFFD6DFFFFF), + "grad-g5-cobalt-a1-transparent" to Color(0xFFD6DFFF00), + "grad-g5-cobalt-a1-secondary" to Color(0xFFCBDEF6), + "grad-g5-cobalt-a2" to Color(0xFFCDE2F9), + "grad-g5-cobalt-bg" to Color(0xFFCCD8F0), + "grad-g6-plum-a1" to Color(0xFFF1DAE3FF), + "grad-g6-plum-a1-transparent" to Color(0xFFF1DAE300), + "grad-g6-plum-a1-secondary" to Color(0xFFEADCE4), + "grad-g6-plum-a2" to Color(0xFFE5DDF4), + "grad-g6-plum-bg" to Color(0xFFE7D9E1), + "grad-g7-violet-a1" to Color(0xFFE9DBF0FF), + "grad-g7-violet-a1-transparent" to Color(0xFFE9DBF000), + "grad-g7-violet-a1-secondary" to Color(0xFFE4DCEA), + "grad-g7-violet-a2" to Color(0xFFDCDCF4), + "grad-g7-violet-bg" to Color(0xFFD5D5F1), + "grad-g8-ocean-a1" to Color(0xFFC5EDEDFF), + "grad-g8-ocean-a1-transparent" to Color(0xFFC5EDED00), + "grad-g8-ocean-a1-secondary" to Color(0xFFCDE7EF), + "grad-g8-ocean-a2" to Color(0xFFCEE5F3), + "grad-g8-ocean-bg" to Color(0xFFDADEEC), + "grad-g9-grass-a1" to Color(0xFFCCF0DAFF), + "grad-g9-grass-a1-transparent" to Color(0xFFCCF0DA00), + "grad-g9-grass-a1-secondary" to Color(0xFFDCE4D3), + "grad-g9-grass-a2" to Color(0xFFE0E8D4), + "grad-g9-grass-bg" to Color(0xFFCBE7D2), + "popup-border-windows" to Color(0xFFD1D3D9), + ), + isIslands = true, + ) + + public val Light: ThemeColorPalette = + ThemeColorPalette( + gray = + listOf( + Color(0xFF000000), + Color(0xFF27282E), + Color(0xFF383A42), + Color(0xFF494B57), + Color(0xFF5A5D6B), + Color(0xFF6C707E), + Color(0xFF818594), + Color(0xFFA8ADBD), + Color(0xFFC9CCD6), + Color(0xFFD3D5DB), + Color(0xFFDFE1E5), + Color(0xFFEBECF0), + Color(0xFFF7F8FA), + Color(0xFFFFFFFF), + ), + blue = + listOf( + Color(0xFF2E55A3), + Color(0xFF315FBD), + Color(0xFF3369D6), + Color(0xFF3574F0), + Color(0xFF4682FA), + Color(0xFF588CF3), + Color(0xFF709CF5), + Color(0xFF88ADF7), + Color(0xFFA0BDF8), + Color(0xFFC2D6FC), + Color(0xFFD4E2FF), + Color(0xFFEDF3FF), + Color(0xFFF5F8FE), + ), + green = + listOf( + Color(0xFF1E6B33), + Color(0xFF1F7536), + Color(0xFF1F8039), + Color(0xFF208A3C), + Color(0xFF369650), + Color(0xFF55A76A), + Color(0xFF89C398), + Color(0xFFAFDBB8), + Color(0xFFC5E5CC), + Color(0xFFE3F7E7), + Color(0xFFF2FCF3), + ), + yellow = + listOf( + Color(0xFFA46704), + Color(0xFFC27D04), + Color(0xFFDF9303), + Color(0xFFFFAF0F), + Color(0xFFFDBD3D), + Color(0xFFFED277), + Color(0xFFFEE6B1), + Color(0xFFFFF1D1), + Color(0xFFFFF5DB), + Color(0xFFFFFAEB), + ), + red = + listOf( + Color(0xFFAD2B38), + Color(0xFFBC303E), + Color(0xFFCC3645), + Color(0xFFDB3B4B), + Color(0xFFE55765), + Color(0xFFE46A76), + Color(0xFFED99A1), + Color(0xFFF2B6BB), + Color(0xFFFAD4D8), + Color(0xFFFFEBEC), + Color(0xFFFFF2F3), + Color(0xFFFFF7F7), + ), + orange = + listOf( + Color(0xFFA14916), + Color(0xFFB85516), + Color(0xFFCE6117), + Color(0xFFE56D17), + Color(0xFFEC8F4C), + Color(0xFFF2B181), + Color(0xFFF9D2B6), + Color(0xFFFFEFE3), + Color(0xFFFFF4EB), + ), + teal = + listOf( + Color(0xFF096A6E), + Color(0xFF077A7F), + Color(0xFF058B90), + Color(0xFF039BA1), + Color(0xFF3FB3B8), + Color(0xFF7BCCCF), + Color(0xFFB6E4E5), + Color(0xFFDAF4F5), + Color(0xFFF2FCFC), + ), + purple = + listOf( + Color(0xFF55339C), + Color(0xFF643CB8), + Color(0xFF7444D4), + Color(0xFF834DF0), + Color(0xFFA177F4), + Color(0xFFBFA1F8), + Color(0xFFDCCBFB), + Color(0xFFEFE5FF), + Color(0xFFF5EDFF), + Color(0xFFFAF5FF), + ), + rawMap = + mapOf( + "Gray1" to Color(0xFF000000), + "Gray2" to Color(0xFF27282E), + "Gray3" to Color(0xFF383A42), + "Gray4" to Color(0xFF494B57), + "Gray5" to Color(0xFF5A5D6B), + "Gray6" to Color(0xFF6C707E), + "Gray7" to Color(0xFF818594), + "Gray8" to Color(0xFFA8ADBD), + "Gray9" to Color(0xFFC9CCD6), + "Gray10" to Color(0xFFD3D5DB), + "Gray11" to Color(0xFFDFE1E5), + "Gray12" to Color(0xFFEBECF0), + "Gray13" to Color(0xFFF7F8FA), + "Gray14" to Color(0xFFFFFFFF), + "windowsPopupBorder" to Color(0xFFB9BDC9), + "Blue1" to Color(0xFF2E55A3), + "Blue2" to Color(0xFF315FBD), + "Blue3" to Color(0xFF3369D6), + "Blue4" to Color(0xFF3574F0), + "Blue5" to Color(0xFF4682FA), + "Blue6" to Color(0xFF588CF3), + "Blue7" to Color(0xFF709CF5), + "Blue8" to Color(0xFF88ADF7), + "Blue9" to Color(0xFFA0BDF8), + "Blue10" to Color(0xFFC2D6FC), + "Blue11" to Color(0xFFD4E2FF), + "Blue12" to Color(0xFFEDF3FF), + "Blue13" to Color(0xFFF5F8FE), + "Green1" to Color(0xFF1E6B33), + "Green2" to Color(0xFF1F7536), + "Green3" to Color(0xFF1F8039), + "Green4" to Color(0xFF208A3C), + "Green5" to Color(0xFF369650), + "Green6" to Color(0xFF55A76A), + "Green7" to Color(0xFF89C398), + "Green8" to Color(0xFFAFDBB8), + "Green9" to Color(0xFFC5E5CC), + "Green10" to Color(0xFFE3F7E7), + "Green11" to Color(0xFFF2FCF3), + "Yellow1" to Color(0xFFA46704), + "Yellow2" to Color(0xFFC27D04), + "Yellow3" to Color(0xFFDF9303), + "Yellow4" to Color(0xFFFFAF0F), + "Yellow5" to Color(0xFFFDBD3D), + "Yellow6" to Color(0xFFFED277), + "Yellow7" to Color(0xFFFEE6B1), + "Yellow8" to Color(0xFFFFF1D1), + "Yellow9" to Color(0xFFFFF5DB), + "Yellow10" to Color(0xFFFFFAEB), + "Red1" to Color(0xFFAD2B38), + "Red2" to Color(0xFFBC303E), + "Red3" to Color(0xFFCC3645), + "Red4" to Color(0xFFDB3B4B), + "Red5" to Color(0xFFE55765), + "Red6" to Color(0xFFE46A76), + "Red7" to Color(0xFFED99A1), + "Red8" to Color(0xFFF2B6BB), + "Red9" to Color(0xFFFAD4D8), + "Red10" to Color(0xFFFFEBEC), + "Red11" to Color(0xFFFFF2F3), + "Red12" to Color(0xFFFFF7F7), + "Orange1" to Color(0xFFA14916), + "Orange2" to Color(0xFFB85516), + "Orange3" to Color(0xFFCE6117), + "Orange4" to Color(0xFFE56D17), + "Orange5" to Color(0xFFEC8F4C), + "Orange6" to Color(0xFFF2B181), + "Orange7" to Color(0xFFF9D2B6), + "Orange8" to Color(0xFFFFEFE3), + "Orange9" to Color(0xFFFFF4EB), + "Teal1" to Color(0xFF096A6E), + "Teal2" to Color(0xFF077A7F), + "Teal3" to Color(0xFF058B90), + "Teal4" to Color(0xFF039BA1), + "Teal5" to Color(0xFF3FB3B8), + "Teal6" to Color(0xFF7BCCCF), + "Teal7" to Color(0xFFB6E4E5), + "Teal8" to Color(0xFFDAF4F5), + "Teal9" to Color(0xFFF2FCFC), + "Purple1" to Color(0xFF55339C), + "Purple2" to Color(0xFF643CB8), + "Purple3" to Color(0xFF7444D4), + "Purple4" to Color(0xFF834DF0), + "Purple5" to Color(0xFFA177F4), + "Purple6" to Color(0xFFBFA1F8), + "Purple7" to Color(0xFFDCCBFB), + "Purple8" to Color(0xFFEFE5FF), + "Purple9" to Color(0xFFF5EDFF), + "Purple10" to Color(0xFFFAF5FF), + ), + isIslands = false, + ) +} diff --git a/platform/jewel/ui/intellij.platform.jewel.ui.iml b/platform/jewel/ui/intellij.platform.jewel.ui.iml index 0130b85ebd99..1c45a98ff8b3 100644 --- a/platform/jewel/ui/intellij.platform.jewel.ui.iml +++ b/platform/jewel/ui/intellij.platform.jewel.ui.iml @@ -28,7 +28,8 @@ - + + diff --git a/platform/jewel/ui/metalava/ui-api-0.41.0.txt b/platform/jewel/ui/metalava/ui-api-0.41.0.txt index 97aef190c865..97b72a2019a5 100644 --- a/platform/jewel/ui/metalava/ui-api-0.41.0.txt +++ b/platform/jewel/ui/metalava/ui-api-0.41.0.txt @@ -5114,6 +5114,17 @@ package org.jetbrains.jewel.ui.theme { property @androidx.compose.runtime.Composable @androidx.compose.runtime.ReadOnlyComposable public static org.jetbrains.jewel.ui.component.styling.LazyTreeStyle org.jetbrains.jewel.foundation.theme.JewelTheme.Companion.treeStyle; } + public final class ThemeColorPaletteKt { + method @androidx.compose.runtime.Composable public static long blueOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long grayOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long greenOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long orangeOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long purpleOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long redOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long tealOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long yellowOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + } + } package org.jetbrains.jewel.ui.util { diff --git a/platform/jewel/ui/metalava/ui-api-stable-0.41.0.txt b/platform/jewel/ui/metalava/ui-api-stable-0.41.0.txt index 31bec546ada9..edbf28e4a7b9 100644 --- a/platform/jewel/ui/metalava/ui-api-stable-0.41.0.txt +++ b/platform/jewel/ui/metalava/ui-api-stable-0.41.0.txt @@ -4973,6 +4973,17 @@ package org.jetbrains.jewel.ui.theme { property @androidx.compose.runtime.Composable @androidx.compose.runtime.ReadOnlyComposable public static org.jetbrains.jewel.ui.component.styling.LazyTreeStyle org.jetbrains.jewel.foundation.theme.JewelTheme.Companion.treeStyle; } + public final class ThemeColorPaletteKt { + method @androidx.compose.runtime.Composable public static long blueOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long grayOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long greenOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long orangeOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long purpleOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long redOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long tealOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + method @androidx.compose.runtime.Composable public static long yellowOrDefault(org.jetbrains.jewel.foundation.theme.ThemeColorPalette, int index); + } + } package org.jetbrains.jewel.ui.util { diff --git a/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPalette.kt b/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPalette.kt new file mode 100644 index 000000000000..ed99d42a27ee --- /dev/null +++ b/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/theme/ThemeColorPalette.kt @@ -0,0 +1,166 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.jewel.ui.theme + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import org.jetbrains.jewel.foundation.InternalJewelApi +import org.jetbrains.jewel.foundation.theme.JewelTheme +import org.jetbrains.jewel.foundation.theme.ThemeColorPalette + +@OptIn(InternalJewelApi::class) +@Composable +private fun ThemeColorPalette.defaultTable(): ThemeColorPalette = + when { + isIslands && JewelTheme.isDark -> DefaultColorPalette.IslandsDark + isIslands && !JewelTheme.isDark -> DefaultColorPalette.IslandsLight + !isIslands && JewelTheme.isDark -> DefaultColorPalette.Dark + else -> DefaultColorPalette.Light + } + +@Composable +private fun ThemeColorPalette.orDefault(index: Int, accessor: ThemeColorPalette.(Int) -> Color?): Color = + accessor(index) ?: defaultTable().accessor(index) ?: Color.Unspecified + +/** + * Retrieves a gray color from the palette by its index, falling back to Jewel's built-in default palette if the current + * Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.grayOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::grayOrNull) + +/** + * Retrieves a blue color from the palette by its index, falling back to Jewel's built-in default palette if the current + * Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.blueOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::blueOrNull) + +/** + * Retrieves a green color from the palette by its index, falling back to Jewel's built-in default palette if the + * current Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.greenOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::greenOrNull) + +/** + * Retrieves a red color from the palette by its index, falling back to Jewel's built-in default palette if the current + * Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.redOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::redOrNull) + +/** + * Retrieves a yellow color from the palette by its index, falling back to Jewel's built-in default palette if the + * current Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.yellowOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::yellowOrNull) + +/** + * Retrieves an orange color from the palette by its index, falling back to Jewel's built-in default palette if the + * current Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.orangeOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::orangeOrNull) + +/** + * Retrieves a purple color from the palette by its index, falling back to Jewel's built-in default palette if the + * current Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.purpleOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::purpleOrNull) + +/** + * Retrieves a teal color from the palette by its index, falling back to Jewel's built-in default palette if the current + * Look and Feel does not provide a color for the requested index. + * + * This spares callers from having to keep their own copy of the default palette values around just to have a sensible + * fallback for incomplete or missing LaF palettes (e.g. most 3rd-party themes). + * + * Palette indices start at 1 (or 10 for Islands themes); how many entries exist for a color depends on the Look and + * Feel. Some LaFs may only have a partial palette, or none at all. + * + * @param index The 1-based (or 10-based for Islands themes) index of the color to retrieve. Only values of 1 and above + * are valid. + * @return The [Color] at the specified index from this palette if available, otherwise the corresponding color from + * Jewel's default palette, or [Color.Unspecified] if the index is out of bounds even there. + */ +@Composable +public fun ThemeColorPalette.tealOrDefault(index: Int): Color = orDefault(index, ThemeColorPalette::tealOrNull)