Skip to content

Commit

Permalink
[Temp] Add OudsColorKeyToken.Raw
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmaitre committed Dec 13, 2024
1 parent a158a75 commit 68fc72d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,42 +367,42 @@ private fun containerColor(hierarchy: OudsButton.Hierarchy, state: OudsButton.St
return with(OudsTheme.componentsTokens.button) {
when (hierarchy) {
OudsButton.Hierarchy.Default -> when (state) {
OudsButton.State.Enabled -> colorBgDefaultEnabled.value
OudsButton.State.Focused -> colorBgDefaultFocus.value
OudsButton.State.Hovered -> colorBgDefaultHover.value
OudsButton.State.Pressed -> colorBgDefaultPressed.value
OudsButton.State.Loading -> colorBgDefaultLoading.value
OudsButton.State.Disabled -> colorBgDefaultDisabled.value
OudsButton.State.Enabled -> colorBgDefaultEnabled
OudsButton.State.Focused -> colorBgDefaultFocus
OudsButton.State.Hovered -> colorBgDefaultHover
OudsButton.State.Pressed -> colorBgDefaultPressed
OudsButton.State.Loading -> colorBgDefaultLoading
OudsButton.State.Disabled -> colorBgDefaultDisabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Minimal -> when (state) {
OudsButton.State.Enabled -> colorBgMinimalEnabled.value
OudsButton.State.Focused -> colorBgMinimalFocus.value
OudsButton.State.Hovered -> colorBgMinimalHover.value
OudsButton.State.Pressed -> colorBgMinimalPressed.value
OudsButton.State.Loading -> colorBgMinimalLoading.value
OudsButton.State.Disabled -> colorBgMinimalDisabled.value
OudsButton.State.Enabled -> colorBgMinimalEnabled
OudsButton.State.Focused -> colorBgMinimalFocus
OudsButton.State.Hovered -> colorBgMinimalHover
OudsButton.State.Pressed -> colorBgMinimalPressed
OudsButton.State.Loading -> colorBgMinimalLoading
OudsButton.State.Disabled -> colorBgMinimalDisabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Strong -> when (state) {
OudsButton.State.Enabled -> OudsColorKeyToken.Action.Enabled.value
OudsButton.State.Focused -> OudsColorKeyToken.Action.Focus.value
OudsButton.State.Hovered -> OudsColorKeyToken.Action.Hover.value
OudsButton.State.Pressed -> OudsColorKeyToken.Action.Pressed.value
OudsButton.State.Loading -> OudsColorKeyToken.Action.Loading.value
OudsButton.State.Disabled -> OudsColorKeyToken.Action.Disabled.value
OudsButton.State.Enabled -> OudsColorKeyToken.Action.Enabled
OudsButton.State.Focused -> OudsColorKeyToken.Action.Focus
OudsButton.State.Hovered -> OudsColorKeyToken.Action.Hover
OudsButton.State.Pressed -> OudsColorKeyToken.Action.Pressed
OudsButton.State.Loading -> OudsColorKeyToken.Action.Loading
OudsButton.State.Disabled -> OudsColorKeyToken.Action.Disabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Negative -> when (state) {
OudsButton.State.Enabled -> OudsColorKeyToken.Action.Negative.Enabled.value
OudsButton.State.Focused -> OudsColorKeyToken.Action.Negative.Focus.value
OudsButton.State.Hovered -> OudsColorKeyToken.Action.Negative.Hover.value
OudsButton.State.Pressed -> OudsColorKeyToken.Action.Negative.Pressed.value
OudsButton.State.Loading -> OudsColorKeyToken.Action.Negative.Loading.value
OudsButton.State.Disabled -> OudsColorKeyToken.Action.Disabled.value
OudsButton.State.Enabled -> OudsColorKeyToken.Action.Negative.Enabled
OudsButton.State.Focused -> OudsColorKeyToken.Action.Negative.Focus
OudsButton.State.Hovered -> OudsColorKeyToken.Action.Negative.Hover
OudsButton.State.Pressed -> OudsColorKeyToken.Action.Negative.Pressed
OudsButton.State.Loading -> OudsColorKeyToken.Action.Negative.Loading
OudsButton.State.Disabled -> OudsColorKeyToken.Action.Disabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
}
}.value
}
}

Expand All @@ -411,42 +411,42 @@ private fun contentColor(hierarchy: OudsButton.Hierarchy, state: OudsButton.Stat
return with(OudsTheme.componentsTokens.button) {
when (hierarchy) {
OudsButton.Hierarchy.Default -> when (state) {
OudsButton.State.Enabled -> colorContentDefaultEnabled.value
OudsButton.State.Focused -> colorContentDefaultFocus.value
OudsButton.State.Hovered -> colorContentDefaultHover.value
OudsButton.State.Pressed -> colorContentDefaultPressed.value
OudsButton.State.Loading -> colorContentDefaultLoading.value
OudsButton.State.Disabled -> colorContentDefaultDisabled.value
OudsButton.State.Enabled -> colorContentDefaultEnabled
OudsButton.State.Focused -> colorContentDefaultFocus
OudsButton.State.Hovered -> colorContentDefaultHover
OudsButton.State.Pressed -> colorContentDefaultPressed
OudsButton.State.Loading -> colorContentDefaultLoading
OudsButton.State.Disabled -> colorContentDefaultDisabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Minimal -> when (state) {
OudsButton.State.Enabled -> colorContentMinimalEnabled.value
OudsButton.State.Focused -> colorContentMinimalFocus.value
OudsButton.State.Hovered -> colorContentMinimalHover.value
OudsButton.State.Pressed -> colorContentMinimalPressed.value
OudsButton.State.Loading -> colorContentMinimalLoading.value
OudsButton.State.Disabled -> colorContentMinimalDisabled.value
OudsButton.State.Enabled -> colorContentMinimalEnabled
OudsButton.State.Focused -> colorContentMinimalFocus
OudsButton.State.Hovered -> colorContentMinimalHover
OudsButton.State.Pressed -> colorContentMinimalPressed
OudsButton.State.Loading -> colorContentMinimalLoading
OudsButton.State.Disabled -> colorContentMinimalDisabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Strong -> when (state) {
OudsButton.State.Enabled -> OudsColorKeyToken.Content.OnAction.Enabled.value
OudsButton.State.Focused -> OudsColorKeyToken.Content.OnAction.Focus.value
OudsButton.State.Hovered -> OudsColorKeyToken.Content.OnAction.Hover.value
OudsButton.State.Pressed -> OudsColorKeyToken.Content.OnAction.Pressed.value
OudsButton.State.Loading -> OudsColorKeyToken.Content.OnAction.Loading.value
OudsButton.State.Disabled -> OudsColorKeyToken.Content.OnAction.Disabled.value
OudsButton.State.Enabled -> OudsColorKeyToken.Content.OnAction.Enabled
OudsButton.State.Focused -> OudsColorKeyToken.Content.OnAction.Focus
OudsButton.State.Hovered -> OudsColorKeyToken.Content.OnAction.Hover
OudsButton.State.Pressed -> OudsColorKeyToken.Content.OnAction.Pressed
OudsButton.State.Loading -> OudsColorKeyToken.Content.OnAction.Loading
OudsButton.State.Disabled -> OudsColorKeyToken.Content.OnAction.Disabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
}
OudsButton.Hierarchy.Negative -> when (state) {
OudsButton.State.Enabled,
OudsButton.State.Hovered,
OudsButton.State.Pressed,
OudsButton.State.Loading,
OudsButton.State.Focused -> OudsColorKeyToken.Content.OnAction.Negative.value
OudsButton.State.Disabled -> OudsColorKeyToken.Content.OnAction.Disabled.value
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorBg
OudsButton.State.Focused -> OudsColorKeyToken.Content.OnAction.Negative
OudsButton.State.Disabled -> OudsColorKeyToken.Content.OnAction.Disabled
OudsButton.State.Skeleton -> OudsTheme.componentsTokens.skeleton.colorGradientStartEnd
}
}
}.value
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.Color
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Background
import com.orange.ouds.theme.tokens.android.OudsAndroidColorDarkTokens
import com.orange.ouds.theme.tokens.android.OudsAndroidColorLightTokens
import com.orange.ouds.theme.tokens.android.OudsAndroidColorLightTokens.surfaceVariant
import com.orange.ouds.theme.tokens.semantic.OudsColorSemanticTokens

data class OudsColorScheme(
Expand Down Expand Up @@ -729,4 +727,5 @@ val OudsColorKeyToken.value: Color
is OudsColorKeyToken.Opacity -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Overlay -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Surface -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Raw -> if (LocalDarkThemeEnabled.current) darkColor else lightColor
}
2 changes: 1 addition & 1 deletion core/src/main/java/com/orange/ouds/core/theme/OudsTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.orange.ouds.theme.tokens.components.OudsComponentsTokens
private fun missingCompositionLocalError(compositionLocalName: String): Nothing =
error("OudsTheme not found. $compositionLocalName CompositionLocal not present.")

private val LocalDarkThemeEnabled = staticCompositionLocalOf<Boolean> { missingCompositionLocalError("LocalDarkThemeEnabled") }
internal val LocalDarkThemeEnabled = staticCompositionLocalOf<Boolean> { missingCompositionLocalError("LocalDarkThemeEnabled") }
private val LocalColorScheme = staticCompositionLocalOf<OudsColorScheme> { missingCompositionLocalError("LocalColorScheme") }
private val LocalLightColorScheme = compositionLocalOf<OudsColorScheme> { missingCompositionLocalError("LocalLightColorScheme") }
private val LocalDarkColorScheme = compositionLocalOf<OudsColorScheme> { missingCompositionLocalError("LocalDarkColorScheme") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

package com.orange.ouds.theme.tokens

import androidx.compose.ui.graphics.Color

sealed interface OudsColorKeyToken {

@ConsistentCopyVisibility
data class Raw internal constructor(val lightColor: Color, val darkColor: Color) : OudsColorKeyToken

sealed interface Opacity : OudsColorKeyToken {
sealed interface Invisible : Opacity {
data object Black : Invisible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.tokens.global.raw.ColorRawTokens

open class OudsSkeletonTokens(
val colorBg: Color = ColorRawTokens.colorOpacityBlack40,
val colorBg: OudsColorKeyToken = OudsColorKeyToken.Raw(ColorRawTokens.colorOpacityBlack40, ColorRawTokens.colorOpacityWhite40),
val colorGradientMiddle: Color = ColorRawTokens.colorOpacityBlack80,
val colorGradientStartEnd: OudsColorKeyToken = OudsColorKeyToken.Opacity.Invisible.Black
)

0 comments on commit 68fc72d

Please sign in to comment.