Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update tokens #236

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun ComponentsScreen() {
.padding(top = OudsSpaceKeyToken.Fixed.Medium.value)
.width(OudsGridKeyToken.Margin.value)
.height(OudsGridKeyToken.ColumnGap.value)
.background(OudsColorKeyToken.Content.Brand.Primary.value)
.background(OudsColorKeyToken.Content.BrandPrimary.value)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private fun CodeColumn(codeExample: String, modifier: Modifier = Modifier) {
Icon(
modifier = Modifier.rotate(linkArrowRotation),
painter = painterResource(R.drawable.ic_chevron_down),
tint = OudsColorKeyToken.Content.Brand.Primary.value,
tint = OudsColorKeyToken.Content.BrandPrimary.value,
contentDescription = null
)
}
Expand Down
208 changes: 197 additions & 11 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 @@ -125,17 +125,17 @@ sealed class TokenProperty<T>(
data object SizeIconWithText : TokenProperty<TokenCategory.Dimension.Size>(
nameRes = R.string.app_tokens_dimension_size_iconWithText_label,
tokens = listOf(
OudsSizeKeyToken.Icon.WithHeadingExtraLarge::class,
OudsSizeKeyToken.Icon.WithHeadingLarge::class,
OudsSizeKeyToken.Icon.WithHeadingMedium::class,
OudsSizeKeyToken.Icon.WithHeadingSmall::class,
OudsSizeKeyToken.Icon.WithBodyLarge::class,
OudsSizeKeyToken.Icon.WithBodyMedium::class,
OudsSizeKeyToken.Icon.WithBodySmall::class,
OudsSizeKeyToken.Icon.WithLabelExtraLarge::class,
OudsSizeKeyToken.Icon.WithLabelLarge::class,
OudsSizeKeyToken.Icon.WithLabelMedium::class,
OudsSizeKeyToken.Icon.WithLabelSmall::class,
OudsSizeKeyToken.Icon.WithHeading.ExtraLarge::class,
OudsSizeKeyToken.Icon.WithHeading.Large::class,
OudsSizeKeyToken.Icon.WithHeading.Medium::class,
OudsSizeKeyToken.Icon.WithHeading.Small::class,
OudsSizeKeyToken.Icon.WithBody.Large::class,
OudsSizeKeyToken.Icon.WithBody.Medium::class,
OudsSizeKeyToken.Icon.WithBody.Small::class,
OudsSizeKeyToken.Icon.WithLabel.ExtraLarge::class,
OudsSizeKeyToken.Icon.WithLabel.Large::class,
OudsSizeKeyToken.Icon.WithLabel.Medium::class,
OudsSizeKeyToken.Icon.WithLabel.Small::class,
).flatMap { keyTokenClass ->
keyTokenClass.getTokens(tokenName = { it.getTokenName(OudsSizeKeyToken.Icon::class).removePrefix("With") })
},
Expand Down Expand Up @@ -190,3 +190,189 @@ sealed class TokenProperty<T>(
categoryClass = TokenCategory.Typography::class
)
}

val OudsBorderKeyToken.Radius.order: Int
get() = when (this) {
OudsBorderKeyToken.Radius.None -> 0
OudsBorderKeyToken.Radius.Default -> 1
OudsBorderKeyToken.Radius.Short -> 2
OudsBorderKeyToken.Radius.Medium -> 3
OudsBorderKeyToken.Radius.Tall -> 4
OudsBorderKeyToken.Radius.Pill -> 5
}

val OudsBorderKeyToken.Width.order: Int
get() = when (this) {
OudsBorderKeyToken.Width.None -> 0
OudsBorderKeyToken.Width.Default -> 2
OudsBorderKeyToken.Width.Thin -> 3
OudsBorderKeyToken.Width.Medium -> 4
OudsBorderKeyToken.Width.Thick -> 5
OudsBorderKeyToken.Width.Thicker -> 6
OudsBorderKeyToken.Width.Focus -> 7
OudsBorderKeyToken.Width.FocusInset -> 8
}

val OudsElevationKeyToken.order: Int
get() = when (this) {
OudsElevationKeyToken.None -> 0
OudsElevationKeyToken.Raised -> 1
OudsElevationKeyToken.OverlayDefault -> 2
OudsElevationKeyToken.AllSticky -> 3
OudsElevationKeyToken.Drag -> 4
OudsElevationKeyToken.OverlayEmphasized -> 5
}

val OudsOpacityKeyToken.order: Int
get() = when (this) {
OudsOpacityKeyToken.Invisible -> 0
OudsOpacityKeyToken.Weaker -> 1
OudsOpacityKeyToken.Weak -> 2
OudsOpacityKeyToken.Medium -> 3
OudsOpacityKeyToken.Strong -> 5
OudsOpacityKeyToken.Opaque -> 6
}

val OudsSizeKeyToken.Icon.order: Int
get() = when (this) {
OudsSizeKeyToken.Icon.Decorative.ExtraExtraSmall -> 0
OudsSizeKeyToken.Icon.Decorative.ExtraSmall -> 1
OudsSizeKeyToken.Icon.Decorative.Small -> 2
OudsSizeKeyToken.Icon.Decorative.Medium -> 3
OudsSizeKeyToken.Icon.Decorative.Large -> 4
OudsSizeKeyToken.Icon.Decorative.ExtraLarge -> 5
OudsSizeKeyToken.Icon.Decorative.ExtraExtraLarge -> 6
OudsSizeKeyToken.Icon.WithHeading.Small.SizeSmall -> 10
OudsSizeKeyToken.Icon.WithHeading.Small.SizeMedium -> 11
OudsSizeKeyToken.Icon.WithHeading.Small.SizeLarge -> 12
OudsSizeKeyToken.Icon.WithHeading.Medium.SizeSmall -> 20
OudsSizeKeyToken.Icon.WithHeading.Medium.SizeMedium -> 21
OudsSizeKeyToken.Icon.WithHeading.Medium.SizeLarge -> 22
OudsSizeKeyToken.Icon.WithHeading.Large.SizeSmall -> 30
OudsSizeKeyToken.Icon.WithHeading.Large.SizeMedium -> 31
OudsSizeKeyToken.Icon.WithHeading.Large.SizeLarge -> 32
OudsSizeKeyToken.Icon.WithHeading.ExtraLarge.SizeSmall -> 40
OudsSizeKeyToken.Icon.WithHeading.ExtraLarge.SizeMedium -> 41
OudsSizeKeyToken.Icon.WithHeading.ExtraLarge.SizeLarge -> 42
OudsSizeKeyToken.Icon.WithBody.Small.SizeSmall -> 50
OudsSizeKeyToken.Icon.WithBody.Small.SizeMedium -> 51
OudsSizeKeyToken.Icon.WithBody.Small.SizeLarge -> 52
OudsSizeKeyToken.Icon.WithBody.Medium.SizeSmall -> 60
OudsSizeKeyToken.Icon.WithBody.Medium.SizeMedium -> 61
OudsSizeKeyToken.Icon.WithBody.Medium.SizeLarge -> 62
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.Large.SizeExtraSmall -> 100
OudsSizeKeyToken.Icon.WithLabel.Large.SizeSmall -> 101
OudsSizeKeyToken.Icon.WithLabel.Large.SizeMedium -> 102
OudsSizeKeyToken.Icon.WithLabel.Large.SizeLarge -> 103
OudsSizeKeyToken.Icon.WithLabel.Large.SizeExtraLarge -> 104
OudsSizeKeyToken.Icon.WithLabel.ExtraLarge.SizeSmall -> 110
OudsSizeKeyToken.Icon.WithLabel.ExtraLarge.SizeMedium -> 111
OudsSizeKeyToken.Icon.WithLabel.ExtraLarge.SizeLarge -> 112
}

val OudsSpaceKeyToken.ColumnGap.order: Int
get() = when (this) {
OudsSpaceKeyToken.ColumnGap.None -> 0
OudsSpaceKeyToken.ColumnGap.Smash -> 1
OudsSpaceKeyToken.ColumnGap.Shortest -> 2
OudsSpaceKeyToken.ColumnGap.Shorter -> 3
OudsSpaceKeyToken.ColumnGap.Short -> 4
OudsSpaceKeyToken.ColumnGap.Medium -> 5
OudsSpaceKeyToken.ColumnGap.Tall -> 6
OudsSpaceKeyToken.ColumnGap.Taller -> 7
OudsSpaceKeyToken.ColumnGap.Tallest -> 8
}

val OudsSpaceKeyToken.Fixed.order: Int
get() = when (this) {
OudsSpaceKeyToken.Fixed.None -> 0
OudsSpaceKeyToken.Fixed.Smash -> 1
OudsSpaceKeyToken.Fixed.Shortest -> 2
OudsSpaceKeyToken.Fixed.Shorter -> 3
OudsSpaceKeyToken.Fixed.Short -> 4
OudsSpaceKeyToken.Fixed.Medium -> 5
OudsSpaceKeyToken.Fixed.Tall -> 6
OudsSpaceKeyToken.Fixed.Taller -> 7
OudsSpaceKeyToken.Fixed.Tallest -> 8
OudsSpaceKeyToken.Fixed.Spacious -> 9
OudsSpaceKeyToken.Fixed.Huge -> 10
OudsSpaceKeyToken.Fixed.Jumbo -> 11
}

val OudsSpaceKeyToken.Inset.order: Int
get() = when (this) {
OudsSpaceKeyToken.Inset.None -> 0
OudsSpaceKeyToken.Inset.Smash -> 1
OudsSpaceKeyToken.Inset.Shortest -> 2
OudsSpaceKeyToken.Inset.Shorter -> 3
OudsSpaceKeyToken.Inset.Short -> 4
OudsSpaceKeyToken.Inset.Medium -> 5
OudsSpaceKeyToken.Inset.Tall -> 6
OudsSpaceKeyToken.Inset.Taller -> 7
OudsSpaceKeyToken.Inset.Tallest -> 8
OudsSpaceKeyToken.Inset.Spacious -> 9
}

val OudsSpaceKeyToken.PaddingBlock.order: Int
get() = when (this) {
OudsSpaceKeyToken.PaddingBlock.None -> 0
OudsSpaceKeyToken.PaddingBlock.Smash -> 1
OudsSpaceKeyToken.PaddingBlock.Shortest -> 2
OudsSpaceKeyToken.PaddingBlock.Shorter -> 3
OudsSpaceKeyToken.PaddingBlock.Short -> 4
OudsSpaceKeyToken.PaddingBlock.Medium -> 5
OudsSpaceKeyToken.PaddingBlock.Tall -> 6
OudsSpaceKeyToken.PaddingBlock.Taller -> 7
OudsSpaceKeyToken.PaddingBlock.Tallest -> 8
OudsSpaceKeyToken.PaddingBlock.Spacious -> 9
OudsSpaceKeyToken.PaddingBlock.Huge -> 10
}

val OudsSpaceKeyToken.PaddingInline.order: Int
get() = when (this) {
OudsSpaceKeyToken.PaddingInline.None -> 0
OudsSpaceKeyToken.PaddingInline.Smash -> 1
OudsSpaceKeyToken.PaddingInline.Shortest -> 2
OudsSpaceKeyToken.PaddingInline.Shorter -> 3
OudsSpaceKeyToken.PaddingInline.Short -> 4
OudsSpaceKeyToken.PaddingInline.Medium -> 5
OudsSpaceKeyToken.PaddingInline.Tall -> 6
OudsSpaceKeyToken.PaddingInline.Taller -> 7
OudsSpaceKeyToken.PaddingInline.Tallest -> 8
OudsSpaceKeyToken.PaddingInline.Spacious -> 9
OudsSpaceKeyToken.PaddingInline.Huge -> 10
}

val OudsSpaceKeyToken.RowGap.order: Int
get() = when (this) {
OudsSpaceKeyToken.RowGap.None -> 0
OudsSpaceKeyToken.RowGap.Smash -> 1
OudsSpaceKeyToken.RowGap.Shortest -> 2
OudsSpaceKeyToken.RowGap.Shorter -> 3
OudsSpaceKeyToken.RowGap.Short -> 4
OudsSpaceKeyToken.RowGap.Medium -> 5
OudsSpaceKeyToken.RowGap.Tall -> 6
}

val OudsSpaceKeyToken.Scaled.order: Int
get() = when (this) {
OudsSpaceKeyToken.Scaled.None -> 0
OudsSpaceKeyToken.Scaled.Smash -> 1
OudsSpaceKeyToken.Scaled.Shortest -> 2
OudsSpaceKeyToken.Scaled.Shorter -> 3
OudsSpaceKeyToken.Scaled.Short -> 4
OudsSpaceKeyToken.Scaled.Medium -> 5
OudsSpaceKeyToken.Scaled.Tall -> 6
OudsSpaceKeyToken.Scaled.Taller -> 7
OudsSpaceKeyToken.Scaled.Tallest -> 8
OudsSpaceKeyToken.Scaled.Spacious -> 9
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -38,8 +37,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -142,7 +139,8 @@ fun SizeIconWithTextIllustrationRow(size: Dp, tokenName: String) {
val style = OudsTypographyKeyToken::class.getTokens()
.asOrNull<List<Token<TextStyle>>>()
?.firstOrNull { typographyToken ->
tokenName.split(".").firstOrNull() == typographyToken.name.replace("Strong", "").replace(".", "")
val tokenNameTreeValues = tokenName.split('.')
typographyToken.name.replace(".Strong", "") == "${tokenNameTreeValues[0]}.${tokenNameTreeValues[1]}"
}
?.value?.invoke()
.orElse { LocalTextStyle.current }
Expand Down
19 changes: 18 additions & 1 deletion app/src/main/java/com/orange/ouds/app/ui/utilities/KClassExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.orange.ouds.app.ui.utilities

import com.orange.ouds.app.ui.tokens.Token
import com.orange.ouds.app.ui.tokens.order
import com.orange.ouds.core.theme.value
import com.orange.ouds.foundation.extensions.asOrNull
import com.orange.ouds.foundation.extensions.orElse
Expand All @@ -30,7 +31,23 @@ fun KClass<*>.getTokens(
recursive: Boolean = true,
tokenName: (KClass<*>) -> String = { it.getTokenName(this) }
): List<Token<*>> {
return getNestedObjects(getRootKeyTokenSuperclass(), recursive).map { keyToken ->
return getNestedObjects(getRootKeyTokenSuperclass(), recursive).sortedBy {
when (it) {
is OudsBorderKeyToken.Radius -> it.order
is OudsBorderKeyToken.Width -> it.order
is OudsElevationKeyToken -> it.order
is OudsOpacityKeyToken -> it.order
is OudsSizeKeyToken.Icon -> it.order
is OudsSpaceKeyToken.ColumnGap -> it.order
is OudsSpaceKeyToken.Fixed -> it.order
is OudsSpaceKeyToken.Inset -> it.order
is OudsSpaceKeyToken.PaddingBlock -> it.order
is OudsSpaceKeyToken.PaddingInline -> it.order
is OudsSpaceKeyToken.RowGap -> it.order
is OudsSpaceKeyToken.Scaled -> it.order
else -> 0
}
}.map { keyToken ->
Token(
name = tokenName(keyToken::class),
value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,23 @@ fun OudsButton(
Button(
onClick = onClick,
enabled = enabled,
shape = RoundedCornerShape(cornerRadius.value),
shape = RoundedCornerShape(borderRadius.value),
modifier = modifier,
contentPadding = PaddingValues(
vertical = verticalContentPadding.value,
horizontal = horizontalContentPadding.value
vertical = spacePaddingBlock.value,
horizontal = spacePaddingBlock.value
),
interactionSource = remember { MutableInteractionSource() },
elevation = ButtonDefaults.buttonElevation(
defaultElevation = defaultElevation.value,
pressedElevation = pressedElevation.value,
focusedElevation = focusedElevation.value,
hoveredElevation = hoveredElevation.value,
disabledElevation = disabledElevation.value,
),
colors = ButtonDefaults.buttonColors(
containerColor = containerColor.value,
contentColor = contentColor.value,
disabledContainerColor = disabledContainerColor.value,
disabledContentColor = disabledContentColor.value,
containerColor = colorBgDefaultEnabled.value,
contentColor = colorContentDefaultEnabled.value,
disabledContainerColor = colorBgDefaultDisabled.value,
disabledContentColor = colorContentDefaultDisabled.value,
)
) {
Text(
modifier = modifier,
text = text,
style = labelStyle.value,
text = text
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fun OudsBorders.fromToken(token: OudsBorderKeyToken.Width): Dp {
OudsBorderKeyToken.Width.Thick -> widthThick
OudsBorderKeyToken.Width.Thicker -> widthThicker
OudsBorderKeyToken.Width.Focus -> widthFocus
OudsBorderKeyToken.Width.Focus.Inset -> widthFocusInset
OudsBorderKeyToken.Width.FocusInset -> widthFocusInset
}
}

Expand Down
Loading
Loading