Skip to content

Commit

Permalink
Adapt code to new tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea committed Dec 18, 2024
1 parent e603c34 commit c84b330
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
22 changes: 13 additions & 9 deletions app/src/main/java/com/orange/ouds/app/ui/tokens/TokenProperty.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ val OudsElevationKeyToken.order: Int
OudsElevationKeyToken.None -> 0
OudsElevationKeyToken.Raised -> 1
OudsElevationKeyToken.OverlayDefault -> 2
OudsElevationKeyToken.AllSticky -> 3
OudsElevationKeyToken.Drag -> 4
OudsElevationKeyToken.OverlayEmphasized -> 5
OudsElevationKeyToken.StickyDefault -> 3
OudsElevationKeyToken.StickyEmphasized -> 4
OudsElevationKeyToken.StickyNavigationScrolled -> 5
OudsElevationKeyToken.Drag -> 6
OudsElevationKeyToken.OverlayEmphasized -> 7
}

val OudsOpacityKeyToken.order: Int
Expand Down Expand Up @@ -263,12 +265,14 @@ val OudsSizeKeyToken.Icon.order: Int
OudsSizeKeyToken.Icon.WithBody.Large.SizeSmall -> 70
OudsSizeKeyToken.Icon.WithBody.Large.SizeMedium -> 71
OudsSizeKeyToken.Icon.WithBody.Large.SizeLarge -> 72
OudsSizeKeyToken.Icon.WithLabel.Small.SizeSmall -> 80
OudsSizeKeyToken.Icon.WithLabel.Small.SizeMedium -> 81
OudsSizeKeyToken.Icon.WithLabel.Small.SizeLarge -> 82
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeSmall -> 90
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeMedium -> 91
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeLarge -> 92
OudsSizeKeyToken.Icon.WithLabel.Small.SizeExtraSmall -> 80
OudsSizeKeyToken.Icon.WithLabel.Small.SizeSmall -> 81
OudsSizeKeyToken.Icon.WithLabel.Small.SizeMedium -> 82
OudsSizeKeyToken.Icon.WithLabel.Small.SizeLarge -> 83
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeExtraSmall -> 90
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeSmall -> 91
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeMedium -> 92
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeLarge -> 93
OudsSizeKeyToken.Icon.WithLabel.Large.SizeExtraSmall -> 100
OudsSizeKeyToken.Icon.WithLabel.Large.SizeSmall -> 101
OudsSizeKeyToken.Icon.WithLabel.Large.SizeMedium -> 102
Expand Down
32 changes: 18 additions & 14 deletions core/src/main/java/com/orange/ouds/core/theme/OudsColorScheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ data class OudsColorScheme(
)

data class Opacity(
val invisibleBlack: Color,
val invisibleWhite: Color
val transparent: Color,
val lowest: Color,
val lower: Color,
)

data class Overlay(
Expand Down Expand Up @@ -337,8 +338,9 @@ val OudsColorSemanticTokens.lightColorScheme: OudsColorScheme
},
opacityColors = with(opacityColorTokens) {
OudsColorScheme.Opacity(
invisibleBlack = opacityInvisibleBlackLight,
invisibleWhite = opacityInvisibleWhiteLight,
transparent = opacityTransparentLight,
lowest = opacityLowestLight,
lower = opacityLowerLight,
)
},
overlayColors = with(overlayColorTokens) {
Expand Down Expand Up @@ -535,8 +537,9 @@ val OudsColorSemanticTokens.darkColorScheme: OudsColorScheme
},
opacityColors = with(opacityColorTokens) {
OudsColorScheme.Opacity(
invisibleBlack = opacityInvisibleBlackDark,
invisibleWhite = opacityInvisibleWhiteDark,
transparent = opacityTransparentDark,
lowest = opacityLowestDark,
lower = opacityLowerDark,
)
},
overlayColors = with(overlayColorTokens) {
Expand Down Expand Up @@ -661,13 +664,13 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Always): Color {
}

@Stable
fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Background): Color {
fun OudsColorScheme.fromToken(token: Background): Color {
return with(backgroundColors) {
when (token) {
OudsColorKeyToken.Background.Emphasized -> emphasized
OudsColorKeyToken.Background.Primary -> primary
OudsColorKeyToken.Background.Secondary -> secondary
OudsColorKeyToken.Background.Tertiary -> tertiary
Background.Emphasized -> emphasized
Background.Primary -> primary
Background.Secondary -> secondary
Background.Tertiary -> tertiary
}
}
}
Expand Down Expand Up @@ -836,8 +839,9 @@ fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Surface): Color {
@Stable
fun OudsColorScheme.fromToken(token: OudsColorKeyToken.Opacity): Color {
return when (token) {
OudsColorKeyToken.Opacity.Invisible.Black -> opacityColors.invisibleBlack
OudsColorKeyToken.Opacity.Invisible.White -> opacityColors.invisibleWhite
OudsColorKeyToken.Opacity.Lower -> opacityColors.lower
OudsColorKeyToken.Opacity.Lowest -> opacityColors.lowest
OudsColorKeyToken.Opacity.Transparent -> opacityColors.transparent
}
}

Expand Down Expand Up @@ -946,7 +950,7 @@ val OudsColorKeyToken.value: Color
get() = when (this) {
is OudsColorKeyToken.Action -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Always -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Background -> OudsTheme.colorScheme.fromToken(this)
is Background -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Border -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Content -> OudsTheme.colorScheme.fromToken(this)
is OudsColorKeyToken.Decorative -> OudsTheme.colorScheme.fromToken(this)
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/com/orange/ouds/core/theme/OudsSizes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ data class OudsSizes(
val extraLarge: ExtraLarge
) {
data class Small(
val sizeExtraSmall: Dp,
val sizeSmall: Dp,
val sizeMedium: Dp,
val sizeLarge: Dp,
)

data class Medium(
val sizeExtraSmall: Dp,
val sizeSmall: Dp,
val sizeMedium: Dp,
val sizeLarge: Dp,
Expand Down Expand Up @@ -240,11 +242,13 @@ fun OudsSizeSemanticTokens.getSizes() = OudsSizes(
),
withLabel = OudsSizes.Icon.WithLabel(
small = OudsSizes.Icon.WithLabel.Small(
sizeExtraSmall = iconWithLabelSmallSizeXs.dp,
sizeSmall = iconWithLabelSmallSizeSm.dp,
sizeMedium = iconWithLabelSmallSizeMd.dp,
sizeLarge = iconWithLabelSmallSizeLg.dp,
),
medium = OudsSizes.Icon.WithLabel.Medium(
sizeExtraSmall = iconWithLabelMediumSizeXs.dp,
sizeSmall = iconWithLabelMediumSizeSm.dp,
sizeMedium = iconWithLabelMediumSizeMd.dp,
sizeLarge = iconWithLabelMediumSizeLg.dp,
Expand Down Expand Up @@ -475,6 +479,7 @@ fun OudsSizes.fromToken(token: OudsSizeKeyToken.Icon.WithLabel.Large): Dp {
@Stable
fun OudsSizes.fromToken(token: OudsSizeKeyToken.Icon.WithLabel.Medium): Dp {
return when (token) {
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeExtraSmall -> icon.withLabel.medium.sizeExtraSmall
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeSmall -> icon.withLabel.medium.sizeSmall
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeMedium -> icon.withLabel.medium.sizeMedium
OudsSizeKeyToken.Icon.WithLabel.Medium.SizeLarge -> icon.withLabel.medium.sizeLarge
Expand All @@ -484,6 +489,7 @@ fun OudsSizes.fromToken(token: OudsSizeKeyToken.Icon.WithLabel.Medium): Dp {
@Stable
fun OudsSizes.fromToken(token: OudsSizeKeyToken.Icon.WithLabel.Small): Dp {
return when (token) {
OudsSizeKeyToken.Icon.WithLabel.Small.SizeExtraSmall -> icon.withLabel.small.sizeExtraSmall
OudsSizeKeyToken.Icon.WithLabel.Small.SizeSmall -> icon.withLabel.small.sizeSmall
OudsSizeKeyToken.Icon.WithLabel.Small.SizeMedium -> icon.withLabel.small.sizeMedium
OudsSizeKeyToken.Icon.WithLabel.Small.SizeLarge -> icon.withLabel.small.sizeLarge
Expand Down

0 comments on commit c84b330

Please sign in to comment.