Skip to content

Commit

Permalink
Review: Create an interface implemented by all color nested classes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea committed Nov 8, 2024
1 parent d09bf1d commit d3ea127
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 90 deletions.
97 changes: 22 additions & 75 deletions core/src/main/java/com/orange/ouds/core/theme/OudsColorScheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ 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.Action
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Always
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Background
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Border
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Brand
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Content
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Decorative
import com.orange.ouds.theme.tokens.OudsColorKeyToken.Elevation
import com.orange.ouds.theme.tokens.semantic.OudsColorSemanticTokens

data class OudsColorScheme(
Expand Down Expand Up @@ -1085,81 +1093,20 @@ val OudsColorSemanticTokens.materialDarkColorScheme: ColorScheme
)

/**
* Converts an OUDS action color token to the local color value provided by the theme.
* Converts an OUDS color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Action.value: Color
val OudsColorKeyToken.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS always color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Always.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS background color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Background.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS border color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Border.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS brand color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Brand.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS content color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Content.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS elevation color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Elevation.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS gradient color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Gradient.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS decorative color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Decorative.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)

/**
* Converts an OUDS transparent color token to the local color value provided by the theme.
*/
val OudsColorKeyToken.Transparent.value: Color
@ReadOnlyComposable
@Composable
get() = OudsTheme.colorScheme.fromToken(this)
get() = when (this) {
is Action -> OudsTheme.colorScheme.fromToken(this)
is Always -> OudsTheme.colorScheme.fromToken(this)
is Background -> OudsTheme.colorScheme.fromToken(this)
is Border -> OudsTheme.colorScheme.fromToken(this)
is Brand -> OudsTheme.colorScheme.fromToken(this)
is Content -> OudsTheme.colorScheme.fromToken(this)
is Decorative -> OudsTheme.colorScheme.fromToken(this)
is Elevation -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Transparent -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Gradient -> OudsTheme.colorScheme.fromToken(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

package com.orange.ouds.theme.tokens

object OudsColorKeyToken {
enum class Transparent {
sealed interface OudsColorKeyToken {

enum class Transparent : OudsColorKeyToken {
TransparentDefault,
}

enum class Action {
enum class Action : OudsColorKeyToken {
Disabled,
DisabledOnBgEmphasized,
NegativeEnabled,
Expand Down Expand Up @@ -51,7 +52,7 @@ object OudsColorKeyToken {
VisitedOnBgEmphasized,
}

enum class Always {
enum class Always : OudsColorKeyToken {
Accent,
Black,
Info,
Expand All @@ -68,7 +69,7 @@ object OudsColorKeyToken {
White,
}

enum class Background {
enum class Background : OudsColorKeyToken {
BrandPrimary,
Emphasized,
Primary,
Expand All @@ -93,7 +94,7 @@ object OudsColorKeyToken {
Tertiary,
}

enum class Border {
enum class Border : OudsColorKeyToken {
BrandPrimary,
BrandPrimaryOnBgEmphasized,
Default,
Expand All @@ -107,7 +108,7 @@ object OudsColorKeyToken {
OnBrandPrimary,
}

enum class Brand {
enum class Brand : OudsColorKeyToken {
AccentDefault,
AccentHigh,
AccentHighest,
Expand Down Expand Up @@ -145,7 +146,7 @@ object OudsColorKeyToken {
WarningLowest,
}

enum class Content {
enum class Content : OudsColorKeyToken {
BrandPrimary,
BrandPrimaryOnBgEmphasized,
Default,
Expand Down Expand Up @@ -189,7 +190,7 @@ object OudsColorKeyToken {
StatusWarning,
}

enum class Elevation {
enum class Elevation : OudsColorKeyToken {
Drag,
DragOnBgEmphasized,
DragOnBgSecondary,
Expand All @@ -205,14 +206,14 @@ object OudsColorKeyToken {
RaisedOnBgSecondary,
}

enum class Gradient {
enum class Gradient : OudsColorKeyToken {
SkeletonMiddle,
SkeletonMiddleOnBgEmphasized,
SkeletonStartEnd,
SkeletonStartEndOnBgEmphasized,
}

enum class Decorative {
enum class Decorative : OudsColorKeyToken {
Accent1Default,
Accent1Emphasized,
Accent1Muted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken

open class OudsButtonTokens(
val containerColor: OudsColorKeyToken.Background = OudsColorKeyToken.Background.BrandPrimary,
val contentColor: OudsColorKeyToken.Content = OudsColorKeyToken.Content.BrandPrimary,
val disabledContainerColor: OudsColorKeyToken.Action = OudsColorKeyToken.Action.Disabled,
val disabledContentColor: OudsColorKeyToken.Content = OudsColorKeyToken.Content.Disabled,
val containerColor: OudsColorKeyToken = OudsColorKeyToken.Background.BrandPrimary,
val contentColor: OudsColorKeyToken = OudsColorKeyToken.Content.BrandPrimary,
val disabledContainerColor: OudsColorKeyToken = OudsColorKeyToken.Action.Disabled,
val disabledContentColor: OudsColorKeyToken = OudsColorKeyToken.Content.Disabled,
val cornerRadius: OudsBorderRadiusKeyToken = OudsBorderRadiusKeyToken.None,
val defaultElevation: OudsElevationKeyToken = OudsElevationKeyToken.None,
val pressedElevation: OudsElevationKeyToken = OudsElevationKeyToken.None,
Expand Down

0 comments on commit d3ea127

Please sign in to comment.