From d6d0df65c11fb534e1596fa4a0a22e0865ee4bad Mon Sep 17 00:00:00 2001 From: Florent Maitre Date: Mon, 18 Nov 2024 17:25:04 +0100 Subject: [PATCH] Split color key tokens into nested objects --- .../app/ui/components/ComponentsScreen.kt | 2 +- .../ouds/app/ui/tokens/TokenCategory.kt | 2 +- .../ui/tokens/TokenCategoryDetailScreen.kt | 7 +- .../ouds/app/ui/tokens/TokenProperty.kt | 58 +- .../ouds/app/ui/tokens/TokenPropertyHeader.kt | 4 +- .../composable/DetailScreenHeader.kt | 2 +- .../app/ui/utilities/composable/LargeCard.kt | 2 +- .../ouds/core/component/button/OudsButton.kt | 2 +- .../orange/ouds/core/theme/OudsColorScheme.kt | 360 +++++----- .../ouds/theme/tokens/OudsColorKeyToken.kt | 665 ++++++++++++------ .../tokens/components/OudsButtonTokens.kt | 4 +- .../theme/orangecountry/OrangeCountryTheme.kt | 2 +- 12 files changed, 689 insertions(+), 421 deletions(-) diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/ComponentsScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/ComponentsScreen.kt index 5f2df8733..527d5bc9e 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/ComponentsScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/ComponentsScreen.kt @@ -51,7 +51,7 @@ fun ComponentsScreen() { .padding(top = OudsSpaceKeyToken.Fixed.Medium.value) .width(OudsGridKeyToken.Margin.value) .height(OudsGridKeyToken.ColumnGap.value) - .background(OudsColorKeyToken.Background.BrandPrimary.value) + .background(OudsColorKeyToken.Background.Brand.Primary.value) ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategory.kt b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategory.kt index b3c3cf777..34280fb18 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategory.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategory.kt @@ -54,9 +54,9 @@ sealed class TokenCategory( TokenProperty.ColorBorder, TokenProperty.ColorBrand, TokenProperty.ColorContent, + TokenProperty.ColorDecorative, TokenProperty.ColorElevation, TokenProperty.ColorGradient, - TokenProperty.ColorDecorative ) ) diff --git a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategoryDetailScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategoryDetailScreen.kt index c7e69cdcc..9347dc06c 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategoryDetailScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenCategoryDetailScreen.kt @@ -157,7 +157,7 @@ fun TokenCategoryDetailScreen(tokenCategory: TokenCategory<*>, onSubcategoryClic } @Composable -private fun TokenIllustration(tokenProperty: TokenProperty<*>, token: Token) = when (tokenProperty) { +private fun TokenIllustration(tokenProperty: TokenProperty<*>, token: Token<*>) = when (tokenProperty) { is TokenProperty.BorderWidth -> BorderIllustrationBox(width = token.value as Dp) is TokenProperty.BorderRadius -> BorderIllustrationBox(shape = RoundedCornerShape(token.value as Dp)) is TokenProperty.BorderStyle -> BorderIllustrationBox(style = token.value as OudsBorderStyle) @@ -194,7 +194,10 @@ private fun TokenPropertyHeader(tokenProperty: TokenProperty<*>, modifier: Modif @Suppress("UNCHECKED_CAST") when (tokenProperty.categoryClass) { TokenCategory.Grid::class -> GridHeader(modifier = modifier) - TokenCategory.Dimension.Space::class -> SpaceHeader(modifier = modifier, spaceTokenProperty = tokenProperty as TokenProperty) + TokenCategory.Dimension.Space::class -> SpaceHeader( + modifier = modifier, + spaceTokenProperty = tokenProperty as TokenProperty + ) else -> {} } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenProperty.kt b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenProperty.kt index cbc08f096..27be4c45c 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenProperty.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenProperty.kt @@ -28,7 +28,7 @@ import kotlin.reflect.KClass sealed class TokenProperty( @StringRes val nameRes: Int?, - val tokens: @Composable () -> List>, + val tokens: @Composable () -> List>, val categoryClass: KClass ) where T : TokenCategory { @@ -52,55 +52,55 @@ sealed class TokenProperty( data object ColorAction : TokenProperty( nameRes = R.string.app_tokens_color_action_label, - tokens = { OudsColorKeyToken.Action.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Action::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorAlways : TokenProperty( nameRes = R.string.app_tokens_color_always_label, - tokens = { OudsColorKeyToken.Always.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Always::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorBackground : TokenProperty( nameRes = R.string.app_tokens_color_background_label, - tokens = { OudsColorKeyToken.Background.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Background::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorBorder : TokenProperty( nameRes = R.string.app_tokens_color_border_label, - tokens = { OudsColorKeyToken.Border.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Border::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorBrand : TokenProperty( nameRes = R.string.app_tokens_color_brand_label, - tokens = { OudsColorKeyToken.Brand.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Brand::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorContent : TokenProperty( nameRes = R.string.app_tokens_color_content_label, - tokens = { OudsColorKeyToken.Content.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Content::class.getTokens() }, + categoryClass = TokenCategory.Color::class + ) + + data object ColorDecorative : TokenProperty( + nameRes = R.string.app_tokens_color_decorative_label, + tokens = { OudsColorKeyToken.Decorative::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorElevation : TokenProperty( nameRes = R.string.app_tokens_color_elevation_label, - tokens = { OudsColorKeyToken.Elevation.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Elevation::class.getTokens() }, categoryClass = TokenCategory.Color::class ) data object ColorGradient : TokenProperty( nameRes = R.string.app_tokens_color_gradient_label, - tokens = { OudsColorKeyToken.Gradient.entries.map { Token(it.name, it.value) } }, - categoryClass = TokenCategory.Color::class - ) - - data object ColorDecorative : TokenProperty( - nameRes = R.string.app_tokens_color_decorative_label, - tokens = { OudsColorKeyToken.Decorative.entries.map { Token(it.name, it.value) } }, + tokens = { OudsColorKeyToken.Gradient::class.getTokens() }, categoryClass = TokenCategory.Color::class ) @@ -217,4 +217,30 @@ sealed class TokenProperty( tokens = { OudsTypographyKeyToken.entries.map { Token(it.name, it.value) } }, categoryClass = TokenCategory.Typography::class ) -} \ No newline at end of file +} + +@PublishedApi +internal fun KClass<*>.getRelativeName(parent: KClass<*>): String { + return qualifiedName.orEmpty().removePrefix("${parent.qualifiedName.orEmpty()}.") +} + +@PublishedApi +internal inline fun KClass<*>.getNestedObjects(): List { + return getNestedClassesRecursive().mapNotNull { it.objectInstance }.filterIsInstance() +} + +@PublishedApi +internal fun KClass<*>.getNestedClassesRecursive(): List> { + return nestedClasses + nestedClasses.flatMap { it.getNestedClassesRecursive() } +} + +@Composable +inline fun KClass<*>.getTokens(): List> { + return getNestedObjects().mapNotNull { keyToken -> + val value = when (keyToken) { + is OudsColorKeyToken -> keyToken.value + else -> null + } + value?.let { Token(keyToken::class.getRelativeName(this).removeSuffix(".Companion"), it) } + }.sortedBy { it.name } +} diff --git a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenPropertyHeader.kt b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenPropertyHeader.kt index d974505a3..36e4e9179 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenPropertyHeader.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/tokens/TokenPropertyHeader.kt @@ -106,7 +106,7 @@ private fun SpaceHeaderContent(spaceTokenProperty: TokenProperty disabled - OudsColorKeyToken.Action.DisabledOnBgEmphasized -> disabledOnBgEmphasized - OudsColorKeyToken.Action.NegativeEnabled -> negativeEnabled - OudsColorKeyToken.Action.NegativeFocus -> negativeFocus - OudsColorKeyToken.Action.NegativeHover -> negativeHover - OudsColorKeyToken.Action.NegativeLoading -> negativeLoading - OudsColorKeyToken.Action.NegativePressed -> negativePressed - OudsColorKeyToken.Action.PrimaryEnabled -> primaryEnabled - OudsColorKeyToken.Action.PrimaryEnabledOnBgEmphasized -> primaryEnabledOnBgEmphasized - OudsColorKeyToken.Action.PrimaryFocus -> primaryFocus - OudsColorKeyToken.Action.PrimaryFocusOnBgEmphasized -> primaryFocusOnBgEmphasized - OudsColorKeyToken.Action.PrimaryHover -> primaryHover - OudsColorKeyToken.Action.PrimaryHoverOnBgEmphasized -> primaryHoverOnBgEmphasized - OudsColorKeyToken.Action.PrimaryLoading -> primaryLoading - OudsColorKeyToken.Action.PrimaryLoadingOnBgEmphasized -> primaryLoadingOnBgEmphasized - OudsColorKeyToken.Action.PrimaryPressed -> primaryPressed - OudsColorKeyToken.Action.PrimaryPressedOnBgEmphasized -> primaryPressedOnBgEmphasized - OudsColorKeyToken.Action.SecondaryEnabled -> secondaryEnabled - OudsColorKeyToken.Action.SecondaryEnabledOnBgEmphasized -> secondaryEnabledOnBgEmphasized - OudsColorKeyToken.Action.SecondaryFocus -> secondaryFocus - OudsColorKeyToken.Action.SecondaryFocusOnBgEmphasized -> secondaryFocusOnBgEmphasized - OudsColorKeyToken.Action.SecondaryHover -> secondaryHover - OudsColorKeyToken.Action.SecondaryHoverOnBgEmphasized -> secondaryHoverOnBgEmphasized - OudsColorKeyToken.Action.SecondaryLoading -> secondaryLoading - OudsColorKeyToken.Action.SecondaryLoadingOnBgEmphasized -> secondaryLoadingOnBgEmphasized - OudsColorKeyToken.Action.SecondaryPressed -> secondaryPressed - OudsColorKeyToken.Action.SecondaryPressedOnBgEmphasized -> secondaryPressedOnBgEmphasized + OudsColorKeyToken.Action.Disabled.OnBgEmphasized -> disabledOnBgEmphasized + OudsColorKeyToken.Action.Negative.Enabled -> negativeEnabled + OudsColorKeyToken.Action.Negative.Focus -> negativeFocus + OudsColorKeyToken.Action.Negative.Hover -> negativeHover + OudsColorKeyToken.Action.Negative.Loading -> negativeLoading + OudsColorKeyToken.Action.Negative.Pressed -> negativePressed + OudsColorKeyToken.Action.Primary.Enabled -> primaryEnabled + OudsColorKeyToken.Action.Primary.Enabled.OnBgEmphasized -> primaryEnabledOnBgEmphasized + OudsColorKeyToken.Action.Primary.Focus -> primaryFocus + OudsColorKeyToken.Action.Primary.Focus.OnBgEmphasized -> primaryFocusOnBgEmphasized + OudsColorKeyToken.Action.Primary.Hover -> primaryHover + OudsColorKeyToken.Action.Primary.Hover.OnBgEmphasized -> primaryHoverOnBgEmphasized + OudsColorKeyToken.Action.Primary.Loading -> primaryLoading + OudsColorKeyToken.Action.Primary.Loading.OnBgEmphasized -> primaryLoadingOnBgEmphasized + OudsColorKeyToken.Action.Primary.Pressed -> primaryPressed + OudsColorKeyToken.Action.Primary.Pressed.OnBgEmphasized -> primaryPressedOnBgEmphasized + OudsColorKeyToken.Action.Secondary.Enabled -> secondaryEnabled + OudsColorKeyToken.Action.Secondary.Enabled.OnBgEmphasized -> secondaryEnabledOnBgEmphasized + OudsColorKeyToken.Action.Secondary.Focus -> secondaryFocus + OudsColorKeyToken.Action.Secondary.Focus.OnBgEmphasized -> secondaryFocusOnBgEmphasized + OudsColorKeyToken.Action.Secondary.Hover -> secondaryHover + OudsColorKeyToken.Action.Secondary.Hover.OnBgEmphasized -> secondaryHoverOnBgEmphasized + OudsColorKeyToken.Action.Secondary.Loading -> secondaryLoading + OudsColorKeyToken.Action.Secondary.Loading.OnBgEmphasized -> secondaryLoadingOnBgEmphasized + OudsColorKeyToken.Action.Secondary.Pressed -> secondaryPressed + OudsColorKeyToken.Action.Secondary.Pressed.OnBgEmphasized -> secondaryPressedOnBgEmphasized OudsColorKeyToken.Action.Selected -> selected - OudsColorKeyToken.Action.SelectedOnBgEmphasized -> selectedOnBgEmphasized + OudsColorKeyToken.Action.Selected.OnBgEmphasized -> selectedOnBgEmphasized OudsColorKeyToken.Action.Visited -> visited - OudsColorKeyToken.Action.VisitedOnBgEmphasized -> visitedOnBgEmphasized + OudsColorKeyToken.Action.Visited.OnBgEmphasized -> visitedOnBgEmphasized } } } @@ -803,27 +803,27 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Always): Color { fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Background): Color { return with(backgroundColors) { when (token) { - OudsColorKeyToken.Background.BrandPrimary -> brandPrimary + OudsColorKeyToken.Background.Brand.Primary -> brandPrimary OudsColorKeyToken.Background.Emphasized -> emphasized OudsColorKeyToken.Background.Primary -> primary OudsColorKeyToken.Background.Secondary -> secondary - OudsColorKeyToken.Background.StatusAccentEmphasized -> statusAccentEmphasized - OudsColorKeyToken.Background.StatusAccentMuted -> statusAccentMuted - OudsColorKeyToken.Background.StatusAccentMutedOnBgEmphasized -> statusAccentMutedOnBgEmphasized - OudsColorKeyToken.Background.StatusInfoEmphasized -> statusInfoEmphasized - OudsColorKeyToken.Background.StatusInfoMuted -> statusInfoMuted - OudsColorKeyToken.Background.StatusInfoMutedOnBgEmphasized -> statusInfoMutedOnBgEmphasized - OudsColorKeyToken.Background.StatusNegativeEmphasized -> statusNegativeEmphasized - OudsColorKeyToken.Background.StatusNegativeMuted -> statusNegativeMuted - OudsColorKeyToken.Background.StatusNegativeMutedOnBgEmphasized -> statusNegativeMutedOnBgEmphasized - OudsColorKeyToken.Background.StatusNeutral -> statusNeutral - OudsColorKeyToken.Background.StatusNeutralOnBgEmphasized -> statusNeutralOnBgEmphasized - OudsColorKeyToken.Background.StatusPositiveEmphasized -> statusPositiveEmphasized - OudsColorKeyToken.Background.StatusPositiveMuted -> statusPositiveMuted - OudsColorKeyToken.Background.StatusPositiveMutedOnBgEmphasized -> statusPositiveMutedOnBgEmphasized - OudsColorKeyToken.Background.StatusWarningEmphasized -> statusWarningEmphasized - OudsColorKeyToken.Background.StatusWarningMuted -> statusWarningMuted - OudsColorKeyToken.Background.StatusWarningMutedOnBgEmphasized -> statusWarningMutedOnBgEmphasized + OudsColorKeyToken.Background.Status.Accent.Emphasized -> statusAccentEmphasized + OudsColorKeyToken.Background.Status.Accent.Muted -> statusAccentMuted + OudsColorKeyToken.Background.Status.Accent.Muted.OnBgEmphasized -> statusAccentMutedOnBgEmphasized + OudsColorKeyToken.Background.Status.Info.Emphasized -> statusInfoEmphasized + OudsColorKeyToken.Background.Status.Info.Muted -> statusInfoMuted + OudsColorKeyToken.Background.Status.Info.Muted.OnBgEmphasized -> statusInfoMutedOnBgEmphasized + OudsColorKeyToken.Background.Status.Negative.Emphasized -> statusNegativeEmphasized + OudsColorKeyToken.Background.Status.Negative.Muted -> statusNegativeMuted + OudsColorKeyToken.Background.Status.Negative.Muted.OnBgEmphasized -> statusNegativeMutedOnBgEmphasized + OudsColorKeyToken.Background.Status.Neutral -> statusNeutral + OudsColorKeyToken.Background.Status.Neutral.OnBgEmphasized -> statusNeutralOnBgEmphasized + OudsColorKeyToken.Background.Status.Positive.Emphasized -> statusPositiveEmphasized + OudsColorKeyToken.Background.Status.Positive.Muted -> statusPositiveMuted + OudsColorKeyToken.Background.Status.Positive.Muted.OnBgEmphasized -> statusPositiveMutedOnBgEmphasized + OudsColorKeyToken.Background.Status.Warning.Emphasized -> statusWarningEmphasized + OudsColorKeyToken.Background.Status.Warning.Muted -> statusWarningMuted + OudsColorKeyToken.Background.Status.Warning.Muted.OnBgEmphasized -> statusWarningMutedOnBgEmphasized OudsColorKeyToken.Background.Tertiary -> tertiary } } @@ -833,17 +833,17 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Background): Color { fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Border): Color { return with(borderColors) { when (token) { - OudsColorKeyToken.Border.BrandPrimary -> brandPrimary - OudsColorKeyToken.Border.BrandPrimaryOnBgEmphasized -> brandPrimaryOnBgEmphasized + OudsColorKeyToken.Border.Brand.Primary -> brandPrimary + OudsColorKeyToken.Border.Brand.Primary.OnBgEmphasized -> brandPrimaryOnBgEmphasized OudsColorKeyToken.Border.Default -> default - OudsColorKeyToken.Border.DefaultOnBgEmphasized -> defaultOnBgEmphasized + OudsColorKeyToken.Border.Default.OnBgEmphasized -> defaultOnBgEmphasized OudsColorKeyToken.Border.Emphasized -> emphasized - OudsColorKeyToken.Border.EmphasizedOnBgEmphasized -> emphasizedOnBgEmphasized + OudsColorKeyToken.Border.Emphasized.OnBgEmphasized -> emphasizedOnBgEmphasized OudsColorKeyToken.Border.Focus -> focus - OudsColorKeyToken.Border.FocusInset -> focusInset - OudsColorKeyToken.Border.FocusInsetOnBgEmphasized -> focusInsetOnBgEmphasized - OudsColorKeyToken.Border.FocusOnBgEmphasized -> focusOnBgEmphasized - OudsColorKeyToken.Border.OnBrandPrimary -> onBrandPrimary + OudsColorKeyToken.Border.Focus.Inset -> focusInset + OudsColorKeyToken.Border.Focus.Inset.OnBgEmphasized -> focusInsetOnBgEmphasized + OudsColorKeyToken.Border.Focus.OnBgEmphasized -> focusOnBgEmphasized + OudsColorKeyToken.Border.OnBrand.Primary -> onBrandPrimary } } } @@ -852,41 +852,41 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Border): Color { fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Brand): Color { return with(brandColors) { when (token) { - OudsColorKeyToken.Brand.AccentDefault -> accentDefault - OudsColorKeyToken.Brand.AccentHigh -> accentHigh - OudsColorKeyToken.Brand.AccentHighest -> accentHighest - OudsColorKeyToken.Brand.AccentLowest -> accentLowest - OudsColorKeyToken.Brand.InfoDefault -> infoDefault - OudsColorKeyToken.Brand.InfoHighest -> infoHighest - OudsColorKeyToken.Brand.InfoLowest -> infoLowest - OudsColorKeyToken.Brand.NegativeDefault -> negativeDefault - OudsColorKeyToken.Brand.NegativeHigh -> negativeHigh - OudsColorKeyToken.Brand.NegativeHigher -> negativeHigher - OudsColorKeyToken.Brand.NegativeHighest -> negativeHighest - OudsColorKeyToken.Brand.NegativeLowest -> negativeLowest - OudsColorKeyToken.Brand.NeutralEmphasizedBlack -> neutralEmphasizedBlack - OudsColorKeyToken.Brand.NeutralEmphasizedHigh -> neutralEmphasizedHigh - OudsColorKeyToken.Brand.NeutralEmphasizedHigher -> neutralEmphasizedHigher - OudsColorKeyToken.Brand.NeutralEmphasizedHighest -> neutralEmphasizedHighest - OudsColorKeyToken.Brand.NeutralEmphasizedLow -> neutralEmphasizedLow - OudsColorKeyToken.Brand.NeutralEmphasizedLower -> neutralEmphasizedLower - OudsColorKeyToken.Brand.NeutralEmphasizedLowest -> neutralEmphasizedLowest - OudsColorKeyToken.Brand.NeutralEmphasizedMedium -> neutralEmphasizedMedium - OudsColorKeyToken.Brand.NeutralMutedHighest -> neutralMutedHighest - OudsColorKeyToken.Brand.NeutralMutedLow -> neutralMutedLow - OudsColorKeyToken.Brand.NeutralMutedLower -> neutralMutedLower - OudsColorKeyToken.Brand.NeutralMutedLowest -> neutralMutedLowest - OudsColorKeyToken.Brand.NeutralMutedMedium -> neutralMutedMedium - OudsColorKeyToken.Brand.NeutralMutedWhite -> neutralMutedWhite - OudsColorKeyToken.Brand.PositiveDefault -> positiveDefault - OudsColorKeyToken.Brand.PositiveHighest -> positiveHighest - OudsColorKeyToken.Brand.PositiveLowest -> positiveLowest - OudsColorKeyToken.Brand.PrimaryDefault -> primaryDefault - OudsColorKeyToken.Brand.PrimaryLow -> primaryLow - OudsColorKeyToken.Brand.WarningDefault -> warningDefault - OudsColorKeyToken.Brand.WarningHigh -> warningHigh - OudsColorKeyToken.Brand.WarningHighest -> warningHighest - OudsColorKeyToken.Brand.WarningLowest -> warningLowest + OudsColorKeyToken.Brand.Accent.Default -> accentDefault + OudsColorKeyToken.Brand.Accent.High -> accentHigh + OudsColorKeyToken.Brand.Accent.Highest -> accentHighest + OudsColorKeyToken.Brand.Accent.Lowest -> accentLowest + OudsColorKeyToken.Brand.Info.Default -> infoDefault + OudsColorKeyToken.Brand.Info.Highest -> infoHighest + OudsColorKeyToken.Brand.Info.Lowest -> infoLowest + OudsColorKeyToken.Brand.Negative.Default -> negativeDefault + OudsColorKeyToken.Brand.Negative.High -> negativeHigh + OudsColorKeyToken.Brand.Negative.Higher -> negativeHigher + OudsColorKeyToken.Brand.Negative.Highest -> negativeHighest + OudsColorKeyToken.Brand.Negative.Lowest -> negativeLowest + OudsColorKeyToken.Brand.Neutral.Emphasized.Black -> neutralEmphasizedBlack + OudsColorKeyToken.Brand.Neutral.Emphasized.High -> neutralEmphasizedHigh + OudsColorKeyToken.Brand.Neutral.Emphasized.Higher -> neutralEmphasizedHigher + OudsColorKeyToken.Brand.Neutral.Emphasized.Highest -> neutralEmphasizedHighest + OudsColorKeyToken.Brand.Neutral.Emphasized.Low -> neutralEmphasizedLow + OudsColorKeyToken.Brand.Neutral.Emphasized.Lower -> neutralEmphasizedLower + OudsColorKeyToken.Brand.Neutral.Emphasized.Lowest -> neutralEmphasizedLowest + OudsColorKeyToken.Brand.Neutral.Emphasized.Medium -> neutralEmphasizedMedium + OudsColorKeyToken.Brand.Neutral.Muted.Highest -> neutralMutedHighest + OudsColorKeyToken.Brand.Neutral.Muted.Low -> neutralMutedLow + OudsColorKeyToken.Brand.Neutral.Muted.Lower -> neutralMutedLower + OudsColorKeyToken.Brand.Neutral.Muted.Lowest -> neutralMutedLowest + OudsColorKeyToken.Brand.Neutral.Muted.Medium -> neutralMutedMedium + OudsColorKeyToken.Brand.Neutral.Muted.White -> neutralMutedWhite + OudsColorKeyToken.Brand.Positive.Default -> positiveDefault + OudsColorKeyToken.Brand.Positive.Highest -> positiveHighest + OudsColorKeyToken.Brand.Positive.Lowest -> positiveLowest + OudsColorKeyToken.Brand.Primary.Default -> primaryDefault + OudsColorKeyToken.Brand.Primary.Low -> primaryLow + OudsColorKeyToken.Brand.Warning.Default -> warningDefault + OudsColorKeyToken.Brand.Warning.High -> warningHigh + OudsColorKeyToken.Brand.Warning.Highest -> warningHighest + OudsColorKeyToken.Brand.Warning.Lowest -> warningLowest } } } @@ -895,47 +895,85 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Brand): Color { fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Content): Color { return with(contentColors) { when (token) { - OudsColorKeyToken.Content.BrandPrimary -> brandPrimary - OudsColorKeyToken.Content.BrandPrimaryOnBgEmphasized -> brandPrimaryOnBgEmphasized + OudsColorKeyToken.Content.Brand.Primary -> brandPrimary + OudsColorKeyToken.Content.Brand.Primary.OnBgEmphasized -> brandPrimaryOnBgEmphasized OudsColorKeyToken.Content.Default -> default - OudsColorKeyToken.Content.DefaultOnBgEmphasized -> defaultOnBgEmphasized + OudsColorKeyToken.Content.Default.OnBgEmphasized -> defaultOnBgEmphasized OudsColorKeyToken.Content.Disabled -> disabled - OudsColorKeyToken.Content.DisabledOnBgEmphasized -> disabledOnBgEmphasized + OudsColorKeyToken.Content.Disabled.OnBgEmphasized -> disabledOnBgEmphasized OudsColorKeyToken.Content.Muted -> muted - OudsColorKeyToken.Content.MutedOnBgEmphasized -> mutedOnBgEmphasized - OudsColorKeyToken.Content.OnActionDisabled -> onActionDisabled - OudsColorKeyToken.Content.OnActionDisabledOnBgEmphasized -> onActionDisabledOnBgEmphasized - OudsColorKeyToken.Content.OnActionNegative -> onActionNegative - OudsColorKeyToken.Content.OnActionPrimaryEnabled -> onActionPrimaryEnabled - OudsColorKeyToken.Content.OnActionPrimaryEnabledOnBgEmphasized -> onActionPrimaryEnabledOnBgEmphasized - OudsColorKeyToken.Content.OnActionPrimaryFocus -> onActionPrimaryFocus - OudsColorKeyToken.Content.OnActionPrimaryFocusOnBgEmphasized -> onActionPrimaryFocusOnBgEmphasized - OudsColorKeyToken.Content.OnActionPrimaryHover -> onActionPrimaryHover - OudsColorKeyToken.Content.OnActionPrimaryHoverOnBgEmphasized -> onActionPrimaryHoverOnBgEmphasized - OudsColorKeyToken.Content.OnActionPrimaryLoading -> onActionPrimaryLoading - OudsColorKeyToken.Content.OnActionPrimaryLoadingOnBgEmphasized -> onActionPrimaryLoadingOnBgEmphasized - OudsColorKeyToken.Content.OnActionPrimaryPressed -> onActionPrimaryPressed - OudsColorKeyToken.Content.OnActionPrimaryPressedOnBgEmphasized -> onActionPrimaryPressedOnBgEmphasized - OudsColorKeyToken.Content.OnBrandPrimary -> onBrandPrimary - OudsColorKeyToken.Content.OnStatusAccentEmphasized -> onStatusAccentEmphasized - OudsColorKeyToken.Content.OnStatusAccentMuted -> onStatusAccentMuted - OudsColorKeyToken.Content.OnStatusAccentMutedOnBgEmphasized -> onStatusAccentMutedOnBgEmphasized - OudsColorKeyToken.Content.OnStatusInfoEmphasized -> onStatusInfoEmphasized - OudsColorKeyToken.Content.OnStatusInfoMuted -> onStatusInfoMuted - OudsColorKeyToken.Content.OnStatusInfoMutedOnBgEmphasized -> onStatusInfoMutedOnBgEmphasized - OudsColorKeyToken.Content.OnStatusNegativeEmphasized -> onStatusNegativeEmphasized - OudsColorKeyToken.Content.OnStatusNegativeMuted -> onStatusNegativeMuted - OudsColorKeyToken.Content.OnStatusNegativeMutedOnBgEmphasized -> onStatusNegativeMutedOnBgEmphasized - OudsColorKeyToken.Content.OnStatusPositiveEmphasized -> onStatusPositiveEmphasized - OudsColorKeyToken.Content.OnStatusPositiveMuted -> onStatusPositiveMuted - OudsColorKeyToken.Content.OnStatusPositiveMutedOnBgEmphasized -> onStatusPositiveMutedOnBgEmphasized - OudsColorKeyToken.Content.OnStatusWarningEmphasized -> onStatusWarningEmphasized - OudsColorKeyToken.Content.OnStatusWarningMuted -> onStatusWarningMuted - OudsColorKeyToken.Content.OnStatusWarningMutedOnBgEmphasized -> onStatusWarningMutedOnBgEmphasized - OudsColorKeyToken.Content.StatusInfo -> statusInfo - OudsColorKeyToken.Content.StatusNegative -> statusNegative - OudsColorKeyToken.Content.StatusPositive -> statusPositive - OudsColorKeyToken.Content.StatusWarning -> statusWarning + OudsColorKeyToken.Content.Muted.OnBgEmphasized -> mutedOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Disabled -> onActionDisabled + OudsColorKeyToken.Content.OnAction.Disabled.OnBgEmphasized -> onActionDisabledOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Negative -> onActionNegative + OudsColorKeyToken.Content.OnAction.Primary.Enabled -> onActionPrimaryEnabled + OudsColorKeyToken.Content.OnAction.Primary.Enabled.OnBgEmphasized -> onActionPrimaryEnabledOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Primary.Focus -> onActionPrimaryFocus + OudsColorKeyToken.Content.OnAction.Primary.Focus.OnBgEmphasized -> onActionPrimaryFocusOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Primary.Hover -> onActionPrimaryHover + OudsColorKeyToken.Content.OnAction.Primary.Hover.OnBgEmphasized -> onActionPrimaryHoverOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Primary.Loading -> onActionPrimaryLoading + OudsColorKeyToken.Content.OnAction.Primary.Loading.OnBgEmphasized -> onActionPrimaryLoadingOnBgEmphasized + OudsColorKeyToken.Content.OnAction.Primary.Pressed -> onActionPrimaryPressed + OudsColorKeyToken.Content.OnAction.Primary.Pressed.OnBgEmphasized -> onActionPrimaryPressedOnBgEmphasized + OudsColorKeyToken.Content.OnBrand.Primary -> onBrandPrimary + OudsColorKeyToken.Content.OnStatus.Accent.Emphasized -> onStatusAccentEmphasized + OudsColorKeyToken.Content.OnStatus.Accent.Muted -> onStatusAccentMuted + OudsColorKeyToken.Content.OnStatus.Accent.Muted.OnBgEmphasized -> onStatusAccentMutedOnBgEmphasized + OudsColorKeyToken.Content.OnStatus.Info.Emphasized -> onStatusInfoEmphasized + OudsColorKeyToken.Content.OnStatus.Info.Muted -> onStatusInfoMuted + OudsColorKeyToken.Content.OnStatus.Info.Muted.OnBgEmphasized -> onStatusInfoMutedOnBgEmphasized + OudsColorKeyToken.Content.OnStatus.Negative.Emphasized -> onStatusNegativeEmphasized + OudsColorKeyToken.Content.OnStatus.Negative.Muted -> onStatusNegativeMuted + OudsColorKeyToken.Content.OnStatus.Negative.Muted.OnBgEmphasized -> onStatusNegativeMutedOnBgEmphasized + OudsColorKeyToken.Content.OnStatus.Positive.Emphasized -> onStatusPositiveEmphasized + OudsColorKeyToken.Content.OnStatus.Positive.Muted -> onStatusPositiveMuted + OudsColorKeyToken.Content.OnStatus.Positive.Muted.OnBgEmphasized -> onStatusPositiveMutedOnBgEmphasized + OudsColorKeyToken.Content.OnStatus.Warning.Emphasized -> onStatusWarningEmphasized + OudsColorKeyToken.Content.OnStatus.Warning.Muted -> onStatusWarningMuted + OudsColorKeyToken.Content.OnStatus.Warning.Muted.OnBgEmphasized -> onStatusWarningMutedOnBgEmphasized + OudsColorKeyToken.Content.Status.Info -> statusInfo + OudsColorKeyToken.Content.Status.Negative -> statusNegative + OudsColorKeyToken.Content.Status.Positive -> statusPositive + OudsColorKeyToken.Content.Status.Warning -> statusWarning + } + } +} + +@Stable +fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Decorative): Color { + return with(decorativeColors) { + when (token) { + OudsColorKeyToken.Decorative.Accent.One.Default -> accent1Default + OudsColorKeyToken.Decorative.Accent.One.Emphasized -> accent1Emphasized + OudsColorKeyToken.Decorative.Accent.One.Muted -> accent1Muted + OudsColorKeyToken.Decorative.Accent.Two.Default -> accent2Default + OudsColorKeyToken.Decorative.Accent.Two.Emphasized -> accent2Emphasized + OudsColorKeyToken.Decorative.Accent.Two.Muted -> accent2Muted + OudsColorKeyToken.Decorative.Accent.Three.Default -> accent3Default + OudsColorKeyToken.Decorative.Accent.Three.Emphasized -> accent3Emphasized + OudsColorKeyToken.Decorative.Accent.Three.Muted -> accent3Muted + OudsColorKeyToken.Decorative.Accent.Four.Default -> accent4Default + OudsColorKeyToken.Decorative.Accent.Four.Emphasized -> accent4Emphasized + OudsColorKeyToken.Decorative.Accent.Four.Muted -> accent4Muted + OudsColorKeyToken.Decorative.Accent.Five.Default -> accent5Default + OudsColorKeyToken.Decorative.Accent.Five.Emphasized -> accent5Emphasized + OudsColorKeyToken.Decorative.Accent.Five.Muted -> accent5Muted + OudsColorKeyToken.Decorative.Brand.Primary -> brandPrimary + OudsColorKeyToken.Decorative.Brand.Secondary -> brandSecondary + OudsColorKeyToken.Decorative.Brand.Tertiary -> brandTertiary + OudsColorKeyToken.Decorative.Neutral.Default -> neutralDefault + OudsColorKeyToken.Decorative.Neutral.Emphasized -> neutralEmphasized + OudsColorKeyToken.Decorative.Neutral.Muted -> neutralMuted + OudsColorKeyToken.Decorative.Skin.Tint100 -> skinTint100 + OudsColorKeyToken.Decorative.Skin.Tint200 -> skinTint200 + OudsColorKeyToken.Decorative.Skin.Tint300 -> skinTint300 + OudsColorKeyToken.Decorative.Skin.Tint400 -> skinTint400 + OudsColorKeyToken.Decorative.Skin.Tint500 -> skinTint500 + OudsColorKeyToken.Decorative.Skin.Tint600 -> skinTint600 + OudsColorKeyToken.Decorative.Skin.Tint700 -> skinTint700 + OudsColorKeyToken.Decorative.Skin.Tint800 -> skinTint800 + OudsColorKeyToken.Decorative.Skin.Tint900 -> skinTint900 } } } @@ -945,18 +983,18 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Elevation): Color { return with(elevationColors) { when (token) { OudsColorKeyToken.Elevation.Drag -> drag - OudsColorKeyToken.Elevation.DragOnBgEmphasized -> dragOnBgEmphasized - OudsColorKeyToken.Elevation.DragOnBgSecondary -> dragOnBgSecondary + OudsColorKeyToken.Elevation.Drag.OnBgEmphasized -> dragOnBgEmphasized + OudsColorKeyToken.Elevation.Drag.OnBgSecondary -> dragOnBgSecondary OudsColorKeyToken.Elevation.Modal -> modal - OudsColorKeyToken.Elevation.OverlayDefault -> overlayDefault - OudsColorKeyToken.Elevation.OverlayDefaultOnBgEmphasized -> overlayDefaultOnBgEmphasized - OudsColorKeyToken.Elevation.OverlayDefaultOnBgSecondary -> overlayDefaultOnBgSecondary - OudsColorKeyToken.Elevation.OverlayEmphasized -> overlayEmphasized - OudsColorKeyToken.Elevation.OverlayEmphasizedOnBgEmphasized -> overlayEmphasizedOnBgEmphasized - OudsColorKeyToken.Elevation.OverlayEmphasizedOnBgSecondary -> overlayEmphasizedOnBgSecondary + OudsColorKeyToken.Elevation.Overlay.Default -> overlayDefault + OudsColorKeyToken.Elevation.Overlay.Default.OnBgEmphasized -> overlayDefaultOnBgEmphasized + OudsColorKeyToken.Elevation.Overlay.Default.OnBgSecondary -> overlayDefaultOnBgSecondary + OudsColorKeyToken.Elevation.Overlay.Emphasized -> overlayEmphasized + OudsColorKeyToken.Elevation.Overlay.Emphasized.OnBgEmphasized -> overlayEmphasizedOnBgEmphasized + OudsColorKeyToken.Elevation.Overlay.Emphasized.OnBgSecondary -> overlayEmphasizedOnBgSecondary OudsColorKeyToken.Elevation.Raised -> raised - OudsColorKeyToken.Elevation.RaisedOnBgEmphasized -> raisedOnBgEmphasized - OudsColorKeyToken.Elevation.RaisedOnBgSecondary -> raisedOnBgSecondary + OudsColorKeyToken.Elevation.Raised.OnBgEmphasized -> raisedOnBgEmphasized + OudsColorKeyToken.Elevation.Raised.OnBgSecondary -> raisedOnBgSecondary } } } @@ -965,48 +1003,10 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Elevation): Color { fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Gradient): Color { return with(gradientColors) { when (token) { - OudsColorKeyToken.Gradient.SkeletonMiddle -> skeletonMiddle - OudsColorKeyToken.Gradient.SkeletonMiddleOnBgEmphasized -> skeletonMiddleOnBgEmphasized - OudsColorKeyToken.Gradient.SkeletonStartEnd -> skeletonStartEnd - OudsColorKeyToken.Gradient.SkeletonStartEndOnBgEmphasized -> skeletonStartEndOnBgEmphasized - } - } -} - -@Stable -fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Decorative): Color { - return with(decorativeColors) { - when (token) { - OudsColorKeyToken.Decorative.Accent1Default -> accent1Default - OudsColorKeyToken.Decorative.Accent1Emphasized -> accent1Emphasized - OudsColorKeyToken.Decorative.Accent1Muted -> accent1Muted - OudsColorKeyToken.Decorative.Accent2Default -> accent2Default - OudsColorKeyToken.Decorative.Accent2Emphasized -> accent2Emphasized - OudsColorKeyToken.Decorative.Accent2Muted -> accent2Muted - OudsColorKeyToken.Decorative.Accent3Default -> accent3Default - OudsColorKeyToken.Decorative.Accent3Emphasized -> accent3Emphasized - OudsColorKeyToken.Decorative.Accent3Muted -> accent3Muted - OudsColorKeyToken.Decorative.Accent4Default -> accent4Default - OudsColorKeyToken.Decorative.Accent4Emphasized -> accent4Emphasized - OudsColorKeyToken.Decorative.Accent4Muted -> accent4Muted - OudsColorKeyToken.Decorative.Accent5Default -> accent5Default - OudsColorKeyToken.Decorative.Accent5Emphasized -> accent5Emphasized - OudsColorKeyToken.Decorative.Accent5Muted -> accent5Muted - OudsColorKeyToken.Decorative.BrandPrimary -> brandPrimary - OudsColorKeyToken.Decorative.BrandSecondary -> brandSecondary - OudsColorKeyToken.Decorative.BrandTertiary -> brandTertiary - OudsColorKeyToken.Decorative.NeutralDefault -> neutralDefault - OudsColorKeyToken.Decorative.NeutralEmphasized -> neutralEmphasized - OudsColorKeyToken.Decorative.NeutralMuted -> neutralMuted - OudsColorKeyToken.Decorative.SkinTint100 -> skinTint100 - OudsColorKeyToken.Decorative.SkinTint200 -> skinTint200 - OudsColorKeyToken.Decorative.SkinTint300 -> skinTint300 - OudsColorKeyToken.Decorative.SkinTint400 -> skinTint400 - OudsColorKeyToken.Decorative.SkinTint500 -> skinTint500 - OudsColorKeyToken.Decorative.SkinTint600 -> skinTint600 - OudsColorKeyToken.Decorative.SkinTint700 -> skinTint700 - OudsColorKeyToken.Decorative.SkinTint800 -> skinTint800 - OudsColorKeyToken.Decorative.SkinTint900 -> skinTint900 + OudsColorKeyToken.Gradient.Skeleton.Middle -> skeletonMiddle + OudsColorKeyToken.Gradient.Skeleton.Middle.OnBgEmphasized -> skeletonMiddleOnBgEmphasized + OudsColorKeyToken.Gradient.Skeleton.StartEnd -> skeletonStartEnd + OudsColorKeyToken.Gradient.Skeleton.StartEnd.OnBgEmphasized -> skeletonStartEndOnBgEmphasized } } } @@ -1014,7 +1014,7 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Decorative): Color { @Stable fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Transparent): Color { return when (token) { - OudsColorKeyToken.Transparent.TransparentDefault -> transparentColors.transparentDefault + OudsColorKeyToken.Transparent.Default -> transparentColors.transparentDefault } } diff --git a/theme-contract/src/main/java/com/orange/ouds/theme/tokens/OudsColorKeyToken.kt b/theme-contract/src/main/java/com/orange/ouds/theme/tokens/OudsColorKeyToken.kt index 2b2edabc8..aec0a1017 100644 --- a/theme-contract/src/main/java/com/orange/ouds/theme/tokens/OudsColorKeyToken.kt +++ b/theme-contract/src/main/java/com/orange/ouds/theme/tokens/OudsColorKeyToken.kt @@ -12,237 +12,476 @@ package com.orange.ouds.theme.tokens + sealed interface OudsColorKeyToken { - enum class Transparent : OudsColorKeyToken { - TransparentDefault, + sealed interface Transparent : OudsColorKeyToken { + data object Default : Transparent } - enum class Action : OudsColorKeyToken { - Disabled, - DisabledOnBgEmphasized, - NegativeEnabled, - NegativeFocus, - NegativeHover, - NegativeLoading, - NegativePressed, - PrimaryEnabled, - PrimaryEnabledOnBgEmphasized, - PrimaryFocus, - PrimaryFocusOnBgEmphasized, - PrimaryHover, - PrimaryHoverOnBgEmphasized, - PrimaryLoading, - PrimaryLoadingOnBgEmphasized, - PrimaryPressed, - PrimaryPressedOnBgEmphasized, - SecondaryEnabled, - SecondaryEnabledOnBgEmphasized, - SecondaryFocus, - SecondaryFocusOnBgEmphasized, - SecondaryHover, - SecondaryHoverOnBgEmphasized, - SecondaryLoading, - SecondaryLoadingOnBgEmphasized, - SecondaryPressed, - SecondaryPressedOnBgEmphasized, - Selected, - SelectedOnBgEmphasized, - Visited, - VisitedOnBgEmphasized, + sealed interface Action : OudsColorKeyToken { + sealed interface Disabled : Action { + companion object : Disabled + data object OnBgEmphasized : Disabled + } + + sealed interface Negative : Action { + data object Enabled : Negative + data object Focus : Negative + data object Hover : Negative + data object Loading : Negative + data object Pressed : Negative + } + + sealed interface Primary : Action { + sealed interface Enabled : Primary { + companion object : Enabled + data object OnBgEmphasized : Enabled + } + + sealed interface Focus : Primary { + companion object : Focus + data object OnBgEmphasized : Focus + } + + sealed interface Hover : Primary { + companion object : Hover + data object OnBgEmphasized : Hover + } + + sealed interface Loading : Primary { + companion object : Loading + data object OnBgEmphasized : Loading + } + + sealed interface Pressed : Primary { + companion object : Pressed + data object OnBgEmphasized : Pressed + } + } + + sealed interface Secondary : Action { + sealed interface Enabled : Secondary { + companion object : Enabled + data object OnBgEmphasized : Enabled + } + + sealed interface Focus : Secondary { + companion object : Focus + data object OnBgEmphasized : Focus + } + + sealed interface Hover : Secondary { + companion object : Hover + data object OnBgEmphasized : Hover + } + + sealed interface Loading : Secondary { + companion object : Loading + data object OnBgEmphasized : Loading + } + + sealed interface Pressed : Secondary { + companion object : Pressed + data object OnBgEmphasized : Pressed + } + } + + sealed interface Selected : Action { + companion object : Selected + data object OnBgEmphasized : Selected + } + + sealed interface Visited : Action { + companion object : Visited + data object OnBgEmphasized : Visited + } } - enum class Always : OudsColorKeyToken { - Accent, - Black, - Info, - Negative, - OnAccent, - OnBlack, - OnInfo, - OnNegative, - OnPositive, - OnWarning, - OnWhite, - Positive, - Warning, - White, + sealed interface Always : OudsColorKeyToken { + data object Accent : Always + data object Black : Always + data object Info : Always + data object Negative : Always + data object OnAccent : Always + data object OnBlack : Always + data object OnInfo : Always + data object OnNegative : Always + data object OnPositive : Always + data object OnWarning : Always + data object OnWhite : Always + data object Positive : Always + data object Warning : Always + data object White : Always } - enum class Background : OudsColorKeyToken { - BrandPrimary, - Emphasized, - Primary, - Secondary, - StatusAccentEmphasized, - StatusAccentMuted, - StatusAccentMutedOnBgEmphasized, - StatusInfoEmphasized, - StatusInfoMuted, - StatusInfoMutedOnBgEmphasized, - StatusNegativeEmphasized, - StatusNegativeMuted, - StatusNegativeMutedOnBgEmphasized, - StatusNeutral, - StatusNeutralOnBgEmphasized, - StatusPositiveEmphasized, - StatusPositiveMuted, - StatusPositiveMutedOnBgEmphasized, - StatusWarningEmphasized, - StatusWarningMuted, - StatusWarningMutedOnBgEmphasized, - Tertiary, + sealed interface Background : OudsColorKeyToken { + data object Emphasized : Background + data object Primary : Background + data object Secondary : Background + data object Tertiary : Background + + sealed interface Brand : Background { + data object Primary : Brand + } + + sealed interface Status : Background { + sealed interface Accent : Status { + data object Emphasized : Accent + sealed interface Muted : Accent { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Info : Background { + data object Emphasized : Info + sealed interface Muted : Info { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Negative : Background { + data object Emphasized : Negative + sealed interface Muted : Negative { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Neutral : Background { + companion object : Neutral + data object OnBgEmphasized : Neutral + } + + sealed interface Positive : Background { + data object Emphasized : Positive + sealed interface Muted : Positive { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Warning : Background { + data object Emphasized : Warning + sealed interface Muted : Warning { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + } } - enum class Border : OudsColorKeyToken { - BrandPrimary, - BrandPrimaryOnBgEmphasized, - Default, - DefaultOnBgEmphasized, - Emphasized, - EmphasizedOnBgEmphasized, - Focus, - FocusInset, - FocusInsetOnBgEmphasized, - FocusOnBgEmphasized, - OnBrandPrimary, + sealed interface Border : OudsColorKeyToken { + sealed interface Brand : Border { + sealed interface Primary : Brand { + companion object : Primary + data object OnBgEmphasized : Primary + } + } + + sealed interface Default : Border { + companion object : Default + data object OnBgEmphasized : Default + } + + sealed interface Emphasized : Border { + companion object : Emphasized + data object OnBgEmphasized : Emphasized + } + + sealed interface Focus : Border { + companion object : Focus + + sealed interface Inset : Focus { + companion object : Inset + data object OnBgEmphasized : Inset + } + + data object OnBgEmphasized : Focus + } + + sealed interface OnBrand : Border { + data object Primary : OnBrand + } } - enum class Brand : OudsColorKeyToken { - AccentDefault, - AccentHigh, - AccentHighest, - AccentLowest, - InfoDefault, - InfoHighest, - InfoLowest, - NegativeDefault, - NegativeHigh, - NegativeHigher, - NegativeHighest, - NegativeLowest, - NeutralEmphasizedBlack, - NeutralEmphasizedHigh, - NeutralEmphasizedHigher, - NeutralEmphasizedHighest, - NeutralEmphasizedLow, - NeutralEmphasizedLower, - NeutralEmphasizedLowest, - NeutralEmphasizedMedium, - NeutralMutedHighest, - NeutralMutedLow, - NeutralMutedLower, - NeutralMutedLowest, - NeutralMutedMedium, - NeutralMutedWhite, - PositiveDefault, - PositiveHighest, - PositiveLowest, - PrimaryDefault, - PrimaryLow, - WarningDefault, - WarningHigh, - WarningHighest, - WarningLowest, + sealed interface Brand : OudsColorKeyToken { + sealed interface Accent : Brand { + data object Default : Accent + data object High : Accent + data object Highest : Accent + data object Lowest : Accent + } + + sealed interface Info : Brand { + data object Default : Info + data object Highest : Info + data object Lowest : Info + } + + sealed interface Negative : Brand { + data object Default : Negative + data object High : Negative + data object Higher : Negative + data object Highest : Negative + data object Lowest : Negative + } + + sealed interface Neutral : Brand { + sealed interface Emphasized : Neutral { + data object Black : Emphasized + data object High : Emphasized + data object Higher : Emphasized + data object Highest : Emphasized + data object Low : Emphasized + data object Lower : Emphasized + data object Lowest : Emphasized + data object Medium : Emphasized + } + + sealed interface Muted : Neutral { + data object Highest : Muted + data object Low : Muted + data object Lower : Muted + data object Lowest : Muted + data object Medium : Muted + data object White : Muted + } + } + + sealed interface Positive : Brand { + data object Default : Positive + data object Highest : Positive + data object Lowest : Positive + } + + sealed interface Primary : Brand { + data object Default : Primary + data object Low : Primary + } + + sealed interface Warning : Brand { + data object Default : Warning + data object High : Warning + data object Highest : Warning + data object Lowest : Warning + } } - enum class Content : OudsColorKeyToken { - BrandPrimary, - BrandPrimaryOnBgEmphasized, - Default, - DefaultOnBgEmphasized, - Disabled, - DisabledOnBgEmphasized, - Muted, - MutedOnBgEmphasized, - OnActionDisabled, - OnActionDisabledOnBgEmphasized, - OnActionNegative, - OnActionPrimaryEnabled, - OnActionPrimaryEnabledOnBgEmphasized, - OnActionPrimaryFocus, - OnActionPrimaryFocusOnBgEmphasized, - OnActionPrimaryHover, - OnActionPrimaryHoverOnBgEmphasized, - OnActionPrimaryLoading, - OnActionPrimaryLoadingOnBgEmphasized, - OnActionPrimaryPressed, - OnActionPrimaryPressedOnBgEmphasized, - OnBrandPrimary, - OnStatusAccentEmphasized, - OnStatusAccentMuted, - OnStatusAccentMutedOnBgEmphasized, - OnStatusInfoEmphasized, - OnStatusInfoMuted, - OnStatusInfoMutedOnBgEmphasized, - OnStatusNegativeEmphasized, - OnStatusNegativeMuted, - OnStatusNegativeMutedOnBgEmphasized, - OnStatusPositiveEmphasized, - OnStatusPositiveMuted, - OnStatusPositiveMutedOnBgEmphasized, - OnStatusWarningEmphasized, - OnStatusWarningMuted, - OnStatusWarningMutedOnBgEmphasized, - StatusInfo, - StatusNegative, - StatusPositive, - StatusWarning, + sealed interface Content : OudsColorKeyToken { + sealed interface Brand : Content { + sealed interface Primary : Brand { + companion object : Primary + data object OnBgEmphasized : Primary + } + } + + sealed interface Default : Content { + companion object : Default + data object OnBgEmphasized : Default + } + + sealed interface Disabled : Content { + companion object : Disabled + data object OnBgEmphasized : Disabled + } + + sealed interface Muted : Content { + companion object : Muted + data object OnBgEmphasized : Muted + } + + sealed interface OnAction : Content { + sealed interface Disabled : OnAction { + companion object : Disabled + data object OnBgEmphasized : Disabled + } + + data object Negative : OnAction + + sealed interface Primary : OnAction { + sealed interface Enabled : Primary { + companion object : Enabled + data object OnBgEmphasized : Enabled + } + + sealed interface Focus : Primary { + companion object : Focus + data object OnBgEmphasized : Focus + } + + sealed interface Hover : Primary { + companion object : Hover + data object OnBgEmphasized : Hover + } + + sealed interface Loading : Primary { + companion object : Loading + data object OnBgEmphasized : Loading + } + + sealed interface Pressed : Primary { + companion object : Pressed + data object OnBgEmphasized : Pressed + } + } + } + + sealed interface OnBrand : Content { + data object Primary : OnBrand + } + + sealed interface OnStatus : Content { + sealed interface Accent : OnStatus { + data object Emphasized : Accent + sealed interface Muted : Accent { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Info : OnStatus { + data object Emphasized : Info + sealed interface Muted : Info { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Negative : OnStatus { + data object Emphasized : Negative + sealed interface Muted : Negative { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Positive : OnStatus { + data object Emphasized : Positive + sealed interface Muted : Positive { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + + sealed interface Warning : OnStatus { + data object Emphasized : Warning + sealed interface Muted : Warning { + companion object : Muted + data object OnBgEmphasized : Muted + } + } + } + + sealed interface Status : Content { + data object Info : Status + data object Negative : Status + data object Positive : Status + data object Warning : Status + } } - enum class Elevation : OudsColorKeyToken { - Drag, - DragOnBgEmphasized, - DragOnBgSecondary, - Modal, - OverlayDefault, - OverlayDefaultOnBgEmphasized, - OverlayDefaultOnBgSecondary, - OverlayEmphasized, - OverlayEmphasizedOnBgEmphasized, - OverlayEmphasizedOnBgSecondary, - Raised, - RaisedOnBgEmphasized, - RaisedOnBgSecondary, + sealed interface Elevation : OudsColorKeyToken { + sealed interface Drag : Elevation { + companion object : Drag + data object OnBgEmphasized : Drag + data object OnBgSecondary : Drag + } + + data object Modal : Elevation + + sealed interface Overlay : Elevation { + sealed interface Default : Overlay { + companion object : Default + data object OnBgEmphasized : Default + data object OnBgSecondary : Default + } + + sealed interface Emphasized : Overlay { + companion object : Emphasized + data object OnBgEmphasized : Emphasized + data object OnBgSecondary : Emphasized + } + } + + sealed interface Raised : Elevation { + companion object : Raised + data object OnBgEmphasized : Raised + data object OnBgSecondary : Raised + } } - enum class Gradient : OudsColorKeyToken { - SkeletonMiddle, - SkeletonMiddleOnBgEmphasized, - SkeletonStartEnd, - SkeletonStartEndOnBgEmphasized, + sealed interface Gradient : OudsColorKeyToken { + sealed interface Skeleton : Gradient { + sealed interface Middle : Skeleton { + companion object : Skeleton + data object OnBgEmphasized : Skeleton + } + + sealed interface StartEnd : Skeleton { + companion object : Skeleton + data object OnBgEmphasized : Skeleton + } + } } - enum class Decorative : OudsColorKeyToken { - Accent1Default, - Accent1Emphasized, - Accent1Muted, - Accent2Default, - Accent2Emphasized, - Accent2Muted, - Accent3Default, - Accent3Emphasized, - Accent3Muted, - Accent4Default, - Accent4Emphasized, - Accent4Muted, - Accent5Default, - Accent5Emphasized, - Accent5Muted, - BrandPrimary, - BrandSecondary, - BrandTertiary, - NeutralDefault, - NeutralEmphasized, - NeutralMuted, - SkinTint100, - SkinTint200, - SkinTint300, - SkinTint400, - SkinTint500, - SkinTint600, - SkinTint700, - SkinTint800, - SkinTint900, + sealed interface Decorative : OudsColorKeyToken { + sealed interface Accent : Decorative { + sealed interface One : Accent { + data object Default : One + data object Emphasized : One + data object Muted : One + } + + sealed interface Two : Accent { + data object Default : Two + data object Emphasized : Two + data object Muted : Two + } + + sealed interface Three : Accent { + data object Default : Three + data object Emphasized : Three + data object Muted : Three + } + + sealed interface Four : Accent { + data object Default : Four + data object Emphasized : Four + data object Muted : Four + } + + sealed interface Five : Accent { + data object Default : Five + data object Emphasized : Five + data object Muted : Five + } + } + + sealed interface Brand : Decorative { + data object Primary : Brand + data object Secondary : Brand + data object Tertiary : Brand + } + + sealed interface Neutral : Decorative { + data object Default : Neutral + data object Emphasized : Neutral + data object Muted : Neutral + } + + sealed interface Skin : Decorative { + data object Tint100 : Skin + data object Tint200 : Skin + data object Tint300 : Skin + data object Tint400 : Skin + data object Tint500 : Skin + data object Tint600 : Skin + data object Tint700 : Skin + data object Tint800 : Skin + data object Tint900 : Skin + } } -} \ No newline at end of file +} diff --git a/theme-contract/src/main/java/com/orange/ouds/theme/tokens/components/OudsButtonTokens.kt b/theme-contract/src/main/java/com/orange/ouds/theme/tokens/components/OudsButtonTokens.kt index efb0db76a..6039f3f08 100644 --- a/theme-contract/src/main/java/com/orange/ouds/theme/tokens/components/OudsButtonTokens.kt +++ b/theme-contract/src/main/java/com/orange/ouds/theme/tokens/components/OudsButtonTokens.kt @@ -19,8 +19,8 @@ import com.orange.ouds.theme.tokens.OudsSpaceKeyToken import com.orange.ouds.theme.tokens.OudsTypographyKeyToken open class OudsButtonTokens( - val containerColor: OudsColorKeyToken = OudsColorKeyToken.Background.BrandPrimary, - val contentColor: OudsColorKeyToken = OudsColorKeyToken.Content.BrandPrimary, + val containerColor: OudsColorKeyToken = OudsColorKeyToken.Background.Brand.Primary, + val contentColor: OudsColorKeyToken = OudsColorKeyToken.Content.Brand.Primary, val disabledContainerColor: OudsColorKeyToken = OudsColorKeyToken.Action.Disabled, val disabledContentColor: OudsColorKeyToken = OudsColorKeyToken.Content.Disabled, val cornerRadius: OudsBorderKeyToken.Radius = OudsBorderKeyToken.Radius.None, diff --git a/theme-orange-country/src/main/java/com/orange/ouds/theme/orangecountry/OrangeCountryTheme.kt b/theme-orange-country/src/main/java/com/orange/ouds/theme/orangecountry/OrangeCountryTheme.kt index 9b86619f3..116a65710 100644 --- a/theme-orange-country/src/main/java/com/orange/ouds/theme/orangecountry/OrangeCountryTheme.kt +++ b/theme-orange-country/src/main/java/com/orange/ouds/theme/orangecountry/OrangeCountryTheme.kt @@ -38,6 +38,6 @@ class OrangeCountryTheme : OrangeTheme() { override val componentsTokens: OudsComponentsTokens get() = OudsComponentsTokens( - button = OudsButtonTokens(containerColor = OudsColorKeyToken.Background.StatusAccentEmphasized, cornerRadius = OudsBorderKeyToken.Radius.Short) + button = OudsButtonTokens(containerColor = OudsColorKeyToken.Background.Status.Accent.Emphasized, cornerRadius = OudsBorderKeyToken.Radius.Short) ) } \ No newline at end of file