Skip to content

Commit

Permalink
Merge pull request #28 from gabrieldrn/catalog/g10-90-themes
Browse files Browse the repository at this point in the history
Add Grey 10 and Grey 90 themes
  • Loading branch information
gabrieldrn authored Nov 1, 2024
2 parents a479b1a + de9f5cf commit cfb4351
Showing 81 changed files with 3,568 additions and 2,869 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

![Carbon catalog pres](https://github.com/user-attachments/assets/d55e6893-ab18-498f-abec-1e2998dfe293)

[![Kotlin](https://img.shields.io/badge/2.0.0-blue?logo=kotlin&logoColor=white&color=7F52FF)](http://kotlinlang.org)
[![Compose Multiplatform](https://img.shields.io/badge/1.6.11-green?logo=jetpackcompose&logoColor=white&color=4284F3)](https://www.jetbrains.com/lp/compose-multiplatform)
[![Kotlin](https://img.shields.io/badge/2.0.20-blue?logo=kotlin&logoColor=white&color=7F52FF)](http://kotlinlang.org)
[![Compose Multiplatform](https://img.shields.io/badge/1.7.0-green?logo=jetpackcompose&logoColor=white&color=4284F3)](https://www.jetbrains.com/lp/compose-multiplatform)

[![CI | compile & tests](https://github.com/gabrieldrn/carbon-compose/actions/workflows/ci-lib-workflow.yml/badge.svg)](https://github.com/gabrieldrn/carbon-compose/actions/workflows/ci-lib-workflow.yml)

Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.gabrieldrn.carbon.buildlogic.Constants
import com.gabrieldrn.carbon.buildlogic.configureKotlinAndroidCommon
import com.gabrieldrn.carbon.buildlogic.getPlugin
import com.gabrieldrn.carbon.buildlogic.libs
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

/**
* Plugin to configure android application modules from this project.
*/
class CarbonApplicationConventionPlugin : Plugin<Project> {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
@OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalWasmDsl::class)
override fun apply(target: Project) = with(target) {
val libs = libs

Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

/**
* A plugin used by kmp libraries modules from Carbon to configure themselves. It
9 changes: 8 additions & 1 deletion carbon/api/android/carbon.api
Original file line number Diff line number Diff line change
@@ -1578,7 +1578,14 @@ public final class com/gabrieldrn/carbon/toggle/ToggleKt {
public static final fun Toggle (ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Ljava/lang/String;Ljava/lang/String;ZZLandroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/runtime/Composer;II)V
}

public final class com/gabrieldrn/carbon/uishell/ComposableSingletons$UIShellHeaderKt {
public static final field INSTANCE Lcom/gabrieldrn/carbon/uishell/ComposableSingletons$UIShellHeaderKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$carbon_release ()Lkotlin/jvm/functions/Function3;
}

public final class com/gabrieldrn/carbon/uishell/UIShellHeaderKt {
public static final fun UiShellHeader (Ljava/lang/String;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function0;Landroidx/compose/foundation/layout/WindowInsets;Lcom/gabrieldrn/carbon/foundation/color/Theme;Landroidx/compose/runtime/Composer;II)V
public static final fun UiShellHeader (Ljava/lang/String;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function0;Landroidx/compose/foundation/layout/WindowInsets;Lcom/gabrieldrn/carbon/foundation/color/Theme;Landroidx/compose/runtime/Composer;II)V
}

9 changes: 8 additions & 1 deletion carbon/api/desktop/carbon.api
Original file line number Diff line number Diff line change
@@ -1578,7 +1578,14 @@ public final class com/gabrieldrn/carbon/toggle/ToggleKt {
public static final fun Toggle (ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Ljava/lang/String;Ljava/lang/String;ZZLandroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/runtime/Composer;II)V
}

public final class com/gabrieldrn/carbon/uishell/ComposableSingletons$UIShellHeaderKt {
public static final field INSTANCE Lcom/gabrieldrn/carbon/uishell/ComposableSingletons$UIShellHeaderKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$carbon ()Lkotlin/jvm/functions/Function3;
}

public final class com/gabrieldrn/carbon/uishell/UIShellHeaderKt {
public static final fun UiShellHeader (Ljava/lang/String;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function0;Landroidx/compose/foundation/layout/WindowInsets;Lcom/gabrieldrn/carbon/foundation/color/Theme;Landroidx/compose/runtime/Composer;II)V
public static final fun UiShellHeader (Ljava/lang/String;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function0;Landroidx/compose/foundation/layout/WindowInsets;Lcom/gabrieldrn/carbon/foundation/color/Theme;Landroidx/compose/runtime/Composer;II)V
}

4 changes: 2 additions & 2 deletions carbon/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import com.gabrieldrn.carbon.Configuration
import org.jetbrains.compose.ExperimentalComposeLibrary
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
id("carbon.kmp.library")
@@ -19,7 +19,6 @@ buildscript {

apply(from = "${rootDir}/scripts/publishing.gradle.kts")

@OptIn(ExperimentalWasmDsl::class)
kotlin {
listOf(
iosX64(),
@@ -32,6 +31,7 @@ kotlin {
}
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@ import com.gabrieldrn.carbon.foundation.color.Theme
@Immutable
internal class ButtonColors private constructor(
private val theme: Theme,
private val buttonType: ButtonType
private val buttonType: ButtonType,
private val isIconButton: Boolean,
) {

val containerColor: Color = when (buttonType) {
@@ -112,32 +113,44 @@ internal class ButtonColors private constructor(
else -> theme.textOnColorDisabled
}

val iconColor: Color = when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
val iconColor: Color = if (isIconButton) {
theme.iconPrimary
} else {
when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
}
}

val iconActiveColor: Color = when (buttonType) {
ButtonType.Tertiary -> theme.iconInverse
ButtonType.Ghost -> theme.linkPrimary // ø
else -> theme.iconOnColor
val iconActiveColor: Color = if (isIconButton) {
theme.iconPrimary
} else {
when (buttonType) {
ButtonType.Tertiary -> theme.iconInverse
ButtonType.Ghost -> theme.linkPrimary // ø
else -> theme.iconOnColor
}
}

val iconHoverColor: Color = when (buttonType) {
ButtonType.Tertiary -> theme.iconInverse
ButtonType.Ghost -> theme.linkPrimaryHover
else -> theme.iconOnColor
val iconHoverColor: Color = if (isIconButton) {
theme.iconPrimary
} else {
when (buttonType) {
ButtonType.Tertiary -> theme.iconInverse
ButtonType.Ghost -> theme.linkPrimaryHover
else -> theme.iconOnColor
}
}

val iconDisabledColor: Color = when (buttonType) {
ButtonType.Primary,
ButtonType.Secondary,
ButtonType.PrimaryDanger -> theme.iconOnColorDisabled
else -> theme.iconDisabled // Issue in documentation for Ghost
else -> theme.iconDisabled // Issue in documentation for Ghost?
}

override fun equals(other: Any?): Boolean {
@@ -146,13 +159,15 @@ internal class ButtonColors private constructor(

if (theme != other.theme) return false
if (buttonType != other.buttonType) return false
if (isIconButton != other.isIconButton) return false

return true
}

override fun hashCode(): Int {
var result = theme.hashCode()
result = 31 * result + buttonType.hashCode()
result = 31 * result + isIconButton.hashCode()
return result
}

@@ -161,6 +176,7 @@ internal class ButtonColors private constructor(
@Composable
fun colors(
buttonType: ButtonType,
): ButtonColors = ButtonColors(Carbon.theme, buttonType)
isIconButton: Boolean,
): ButtonColors = ButtonColors(Carbon.theme, buttonType, isIconButton)
}
}
Original file line number Diff line number Diff line change
@@ -18,27 +18,23 @@ package com.gabrieldrn.carbon.button

import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.tween
import androidx.compose.foundation.IndicationInstance
import androidx.compose.foundation.interaction.FocusInteraction
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import com.gabrieldrn.carbon.foundation.color.LocalCarbonTheme
import androidx.compose.ui.node.DelegatableNode
import com.gabrieldrn.carbon.foundation.color.Theme
import com.gabrieldrn.carbon.foundation.interaction.FocusIndication
import com.gabrieldrn.carbon.foundation.motion.Motion
import kotlinx.coroutines.flow.filterIsInstance

internal class ButtonFocusIndication(
private val theme: Theme,
private val buttonType: ButtonType
) : FocusIndication() {
) : FocusIndication(theme) {

private class ButtonIndicationInstance(
interactionSource: InteractionSource,
theme: Theme,
buttonType: ButtonType
) : DefaultFocusIndicationInstance(theme) {
) : DefaultFocusIndicationInstance(interactionSource, theme) {

override val insetFocusColor = if (buttonType == ButtonType.Ghost) {
Color.Transparent
@@ -52,24 +48,24 @@ internal class ButtonFocusIndication(
)
}

@Composable
override fun rememberUpdatedInstance(
interactionSource: InteractionSource
): IndicationInstance {
val theme = LocalCarbonTheme.current
override fun create(interactionSource: InteractionSource): DelegatableNode =
ButtonIndicationInstance(interactionSource, theme, buttonType)

val instance = remember(theme) {
ButtonIndicationInstance(theme = theme, buttonType = buttonType)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is ButtonFocusIndication) return false
if (!super.equals(other)) return false

LaunchedEffect(interactionSource) {
interactionSource.interactions
.filterIsInstance<FocusInteraction>()
.collect { interaction ->
instance.animateFocus(this, interaction)
}
}
if (theme != other.theme) return false
if (buttonType != other.buttonType) return false

return true
}

return instance
override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + theme.hashCode()
result = 31 * result + buttonType.hashCode()
return result
}
}
Original file line number Diff line number Diff line change
@@ -78,9 +78,10 @@ internal fun ButtonRowImpl(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
content: @Composable RowScope.(ButtonScope) -> Unit,
) {
val colors = ButtonColors.colors(buttonType)
val theme = Carbon.theme
val colors = ButtonColors.colors(buttonType, isIconButton)
val containerColor = remember(colors) { Animatable(colors.containerColor) }
val indication = remember(buttonType) { ButtonFocusIndication(buttonType) }
val indication = remember(buttonType) { ButtonFocusIndication(theme, buttonType) }

LaunchedEffect(isEnabled, colors) {
containerColor.animateTo(
Original file line number Diff line number Diff line change
@@ -154,7 +154,10 @@ public fun Checkbox(
state = state,
modifier = Modifier.indication(
interactionSource = interactionSource,
indication = ToggleableFocusIndication(4.dp)
indication = ToggleableFocusIndication(
theme = Carbon.theme,
indicationCornerRadius = 4.dp
)
)
)
Text(
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ public fun <K : Any> Dropdown(
DropdownPlaceholderText(
placeholderText = fieldText,
colors = colors,
state = state,
state = state
)

DropdownStateIcon(state = state)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2024 Gabriel Derrien
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.gabrieldrn.carbon.dropdown
Original file line number Diff line number Diff line change
@@ -156,7 +156,7 @@ internal fun DropdownField(
modifier = modifier
.indication(
interactionSource = interactionSource,
indication = FocusIndication()
indication = FocusIndication(Carbon.theme)
)
.focusable(
enabled = state.isFocusable,
@@ -177,17 +177,6 @@ internal fun DropdownField(
)
}
}
.padding(horizontal = SpacingScale.spacing05)
.then(
if (state is DropdownInteractiveState.Error) {
Modifier.border(
width = SpacingScale.spacing01,
color = colors.fieldBorderErrorColor
)
} else {
Modifier
}
)
.then(
when (state) {
is DropdownInteractiveState.Disabled -> Modifier.semantics { disabled() }
@@ -202,6 +191,17 @@ internal fun DropdownField(
)
}
)
.then(
if (state is DropdownInteractiveState.Error) {
Modifier.border(
width = SpacingScale.spacing01,
color = colors.fieldBorderErrorColor
)
} else {
Modifier
}
)
.padding(horizontal = SpacingScale.spacing05)
.semantics(mergeDescendants = true) {
role = Role.DropdownList
state.helperText?.let { stateDescription = it }
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ private fun DropdownMenuOption(
.selectable(
selected = isSelected,
interactionSource = interactionSource,
indication = FocusIndication(),
indication = FocusIndication(Carbon.theme),
enabled = option.enabled,
onClick = onOptionClicked
)
Loading
Oops, something went wrong.

0 comments on commit cfb4351

Please sign in to comment.