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

feat: add color tokens #152

Merged
merged 14 commits into from
Nov 8, 2024
Merged
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
3 changes: 2 additions & 1 deletion app/src/main/java/com/orange/ouds/app/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import com.orange.ouds.theme.OudsThemeContract
import com.orange.ouds.theme.orange.ORANGE_THEME_NAME
import com.orange.ouds.theme.orange.OrangeTheme
import com.orange.ouds.theme.orangecountry.OrangeCountryTheme
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.whitelabel.WhiteLabelTheme

Expand Down Expand Up @@ -154,7 +155,7 @@ private fun ChangeThemeDialog(themeManager: ThemeManager, dismissDialog: () -> U
Dialog(onDismissRequest = dismissDialog) {
Column(
modifier = Modifier
.background(OudsTheme.colorScheme.surfaceVariant)
.background(OudsColorKeyToken.Background.Secondary.value)
.selectableGroup()
) {
Text(
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/orange/ouds/app/ui/TopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import com.orange.ouds.app.ui.utilities.isDarkModeEnabled
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken


@Composable
Expand Down Expand Up @@ -70,15 +70,15 @@ private fun TopBar(
Image(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.app_common_back_a11y),
colorFilter = ColorFilter.tint(OudsColorKeyToken.OnSurface.value) //TODO use ContentDefault token when available
colorFilter = ColorFilter.tint(OudsColorKeyToken.Content.Default.value)
)
}
}
},
title = {
Text(
text = title,
color = OudsColorKeyToken.OnSurface.value, //TODO use ContentDefault token when available
color = OudsColorKeyToken.Content.Default.value,
modifier = Modifier.semantics { traversalIndex = -1f },
style = OudsTypographyKeyToken.HeadingMedium.value
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.orange.ouds.app.ui.utilities.composable.Screen
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.theme.OudsTheme
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsGridKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken

@Composable
fun ComponentsScreen() {
Screen {
Column(
modifier = Modifier
.fillMaxSize(),
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Expand All @@ -52,7 +51,7 @@ fun ComponentsScreen() {
.padding(top = OudsSpaceKeyToken.Fixed.Medium.value)
.width(OudsGridKeyToken.Margin.value)
.height(OudsGridKeyToken.ColumnGap.value)
.background(OudsTheme.colorScheme.primary)
.background(OudsColorKeyToken.Background.BrandPrimary.value)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.OudsBorderStyle
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken

@Composable
fun TokenCategoryDetailScreen(tokenCategory: TokenCategory, onSubcategoryClick: (Long) -> Unit) {
Expand Down Expand Up @@ -110,7 +110,7 @@ fun TokenCategoryDetailScreen(tokenCategory: TokenCategory, onSubcategoryClick:
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = OudsTypographyKeyToken.BodyDefaultMedium.value,
color = OudsColorKeyToken.OnSurfaceVariant.value //TODO use ContentMuted token when available
color = OudsColorKeyToken.Content.Muted.value
)
}
} else {
Expand Down Expand Up @@ -139,8 +139,7 @@ fun TokenCategoryDetailScreen(tokenCategory: TokenCategory, onSubcategoryClick:
text = token.literalValue,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = OudsTypographyKeyToken.BodyDefaultMedium.value.copy(color = OudsColorKeyToken.Tertiary.value), //TODO use ContentMuted token when available
color = OudsColorKeyToken.OnSurfaceVariant.value //TODO use ContentMuted token when available
style = OudsTypographyKeyToken.BodyDefaultMedium.value.copy(color = OudsColorKeyToken.Content.Muted.value)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sealed class TokenProperty(
nameRes = null,
tokens = { OudsOpacityKeyToken.entries.map { Token(it.name, it.value) } }
)

data object SizeIconDecorative : TokenProperty(
nameRes = R.string.app_tokens_dimension_size_iconDecorative_label,
tokens = { OudsSizeKeyToken.IconDecorative.entries.map { Token(it.name, it.value) } }
Expand Down Expand Up @@ -134,5 +134,4 @@ sealed class TokenProperty(
)

data object Typography : TokenProperty(nameRes = null, tokens = { OudsTypographyKeyToken.entries.map { Token(it.name, it.value) } })

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
Expand All @@ -49,16 +50,16 @@ import com.orange.ouds.foundation.extensions.orElse
import com.orange.ouds.theme.OudsBorderStyle
import com.orange.ouds.theme.dashedBorder
import com.orange.ouds.theme.dottedBorder
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken

private val defaultIllustrationSize = 64.dp

@Composable
fun IllustrationBox(
modifier: Modifier = Modifier,
backgroundColor: Color = OudsColorKeyToken.OnSurface.value,
backgroundColor: Color = OudsColorKeyToken.Background.Emphasized.value,
contentAlignment: Alignment = Alignment.TopStart,
content: @Composable BoxScope.() -> Unit = { }
) {
Expand All @@ -77,20 +78,20 @@ fun BorderIllustrationBox(
shape: Shape = RectangleShape,
style: OudsBorderStyle = OudsBorderStyle.Solid
) {
val borderColor = OudsColorKeyToken.OnSurface.value //TODO use ContentDefault token when available
val borderColor = OudsColorKeyToken.Content.Default.value
val modifier = when (style) {
OudsBorderStyle.None -> Modifier
OudsBorderStyle.Solid -> Modifier.border(width = width, color = borderColor, shape = shape)
OudsBorderStyle.Dashed -> Modifier.dashedBorder(width = width, color = borderColor, shape = shape)
OudsBorderStyle.Dotted -> Modifier.dottedBorder(width = width, color = borderColor, shape = shape)
}
IllustrationBox(modifier = modifier, backgroundColor = Color.Transparent)
IllustrationBox(modifier = modifier.clip(shape), backgroundColor = OudsColorKeyToken.Background.Secondary.value)
}

@Composable
fun ElevationIllustrationSurface(elevation: Dp) {
Surface(shadowElevation = elevation) {
IllustrationBox(backgroundColor = OudsColorKeyToken.Surface.value) //TODO use BgDefaultSecondary token when available
IllustrationBox(backgroundColor = OudsColorKeyToken.Background.Secondary.value)
}
}

Expand Down Expand Up @@ -150,7 +151,7 @@ fun SpaceWithIconIllustrationColumn(size: Dp, verticalArrangement: Arrangement.V
Column(
modifier = Modifier
.size(defaultIllustrationSize)
.background(color = OudsColorKeyToken.OnSurface.value), //TODO use BgEmphasizedPrimary token when available
.background(color = OudsColorKeyToken.Background.Emphasized.value),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = verticalArrangement
) {
Expand All @@ -167,7 +168,7 @@ fun SpaceWithIconIllustrationColumn(size: Dp, verticalArrangement: Arrangement.V
modifier = Modifier
.fillMaxWidth()
.height(height = size)
.background(Color(0xFF26B2FF)) //TODO use AlwaysInfo token when available
.background(OudsColorKeyToken.Always.Info.value)
)
}

Expand Down Expand Up @@ -208,14 +209,14 @@ private fun SpaceWithImageIllustrationRow(
Row(
modifier = modifier
.size(defaultIllustrationSize)
.background(color = OudsColorKeyToken.OnSurface.value), //TODO use BgEmphasizedPrimary token when available
.background(color = OudsColorKeyToken.Background.Emphasized.value),
verticalAlignment = Alignment.CenterVertically
) {
Box(
modifier = Modifier
.fillMaxHeight()
.width(width = spaceSize)
.background(Color(0xFF26B2FF)) //TODO use AlwaysInfo token when available
.background(OudsColorKeyToken.Always.Info.value)
)
Image(
modifier = imageModifier,
Expand All @@ -233,13 +234,13 @@ fun SpacePaddingInsetIllustrationBox(size: Dp) {
modifier = Modifier
.fillMaxWidth()
.height(height = size)
.background(Color(0xFF26B2FF)) //TODO use AlwaysInfo token when available
.background(OudsColorKeyToken.Always.Info.value)
)
Box(
modifier = Modifier
.fillMaxHeight()
.width(width = size)
.background(Color(0xFF26B2FF)) //TODO use AlwaysInfo token when available
.background(OudsColorKeyToken.Always.Info.value)
)
}
}
Expand All @@ -261,7 +262,7 @@ fun SpaceIllustrationBox(
}
IllustrationBox(contentAlignment = contentAlignment) {
Box(
modifier = dimensionBoxModifier.background(Color(0xFF26B2FF)) //TODO use AlwaysInfo token when available
modifier = dimensionBoxModifier.background(color = OudsColorKeyToken.Always.Info.value)
)
}
}
Expand All @@ -285,10 +286,10 @@ fun GridIllustrations() {
Image(
modifier = Modifier
.fillMaxWidth()
.background(OudsColorKeyToken.OnSurface.value), //TODO use BgEmphasizedPrimary token when available
.background(OudsColorKeyToken.Background.Emphasized.value),
painter = painterResource(id = it),
contentDescription = null
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import com.orange.ouds.app.R
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken

@Composable
fun DetailScreenHeader(
Expand All @@ -44,12 +44,12 @@ fun DetailScreenHeader(
Column {
Image(
painter = painterResource(imageRes),
colorFilter = ColorFilter.tint(OudsColorKeyToken.InverseOnSurface.value), //TODO use OnBgEmphasized token when available
colorFilter = ColorFilter.tint(OudsColorKeyToken.Content.DefaultOnBgEmphasized.value),
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(186.dp)
.background(OudsColorKeyToken.OnSurface.value), //TODO use BgEmphasizedPrimary token when available
.background(OudsColorKeyToken.Background.Emphasized.value),
contentScale = ContentScale.None
)

Expand All @@ -68,7 +68,7 @@ private fun DetailScreenDescription(
Text(
modifier = modifier,
text = stringResource(descriptionRes),
color = OudsColorKeyToken.OnSurface.value, //TODO use ContentDefault token when available
color = OudsColorKeyToken.Content.Default.value,
style = OudsTypographyKeyToken.BodyDefaultLarge.value
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults.cardElevation
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
Expand All @@ -32,9 +34,10 @@ import com.orange.ouds.app.R
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsElevationKeyToken
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken
import com.orange.ouds.theme.tokens.OudsTypographyKeyToken
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken

/**
* Temporary large card used by the demo app
Expand All @@ -46,24 +49,24 @@ fun LargeCard(
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Card(modifier = modifier, onClick = onClick) {
Column {
Card(modifier = modifier, shape = RectangleShape, elevation = cardElevation(defaultElevation = OudsElevationKeyToken.Raised.value), onClick = onClick) {
Column(modifier = Modifier.background(OudsColorKeyToken.Elevation.Raised.value)) {
Image(
painter = painterResource(imageRes),
colorFilter = ColorFilter.tint(OudsColorKeyToken.InverseOnSurface.value), //TODO use OnBgEmphasized token when available
colorFilter = ColorFilter.tint(OudsColorKeyToken.Content.DefaultOnBgEmphasized.value),
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(184.dp) //TODO use token when available
.background(OudsColorKeyToken.OnSurface.value), //TODO use BgEmphasizedPrimary token when available
.height(184.dp)
.background(OudsColorKeyToken.Background.Emphasized.value),
contentScale = ContentScale.None
)
Column(
modifier = Modifier.padding(OudsSpaceKeyToken.Fixed.Medium.value)
) {
Text(
text = title,
color = OudsColorKeyToken.OnSurface.value, //TODO use ContentDefault token when available
color = OudsColorKeyToken.Content.Default.value,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = OudsTypographyKeyToken.HeadingMedium.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import androidx.compose.ui.Modifier
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.semantic.OudsColorKeyToken
import com.orange.ouds.theme.tokens.OudsColorKeyToken

@Composable
fun Screen(content: @Composable () -> Unit) {
Box(
modifier = Modifier
.fillMaxSize()
.background(OudsColorKeyToken.Background.value) //TODO use BgDefaultPrimary token when available
.background(OudsColorKeyToken.Background.Primary.value)
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
import com.orange.ouds.foundation.utilities.UiModePreviews
import com.orange.ouds.theme.tokens.OudsColorKeyToken

@Composable
fun OudsButton(
Expand Down Expand Up @@ -64,7 +65,8 @@ fun OudsButton(
Text(
modifier = modifier,
text = text,
style = labelStyle.value
style = labelStyle.value,
color = OudsColorKeyToken.Content.OnActionPrimaryEnabled.value
)
}
}
Expand Down
Loading