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

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4384ce7
Add border tokens in the demo app
paulinea Oct 16, 2024
6a862e3
Review: Change dashedBorder modifier signature
paulinea Oct 17, 2024
5d0f34a
Review: Move defaultIllustrationSize variable in the companion object…
paulinea Oct 17, 2024
c81a14b
Add ic_spacing icon
paulinea Oct 17, 2024
858ae97
Start adding dimension tokens in demo app
paulinea Oct 18, 2024
8254ed5
Fix subcategories detail display
paulinea Oct 18, 2024
457a2b6
Reorder OudsSizeIconWithTextKeyToken
paulinea Oct 21, 2024
378812b
Display dimension size tokens
paulinea Oct 21, 2024
1d6cbcd
Display all spacing tokens in the demo app
paulinea Oct 21, 2024
3da3c0d
Apply filter before calling private composable
paulinea Oct 22, 2024
057b1c7
Reorder properties
paulinea Oct 22, 2024
a04f3d3
Update illustrations for spacing inline with icon
paulinea Oct 22, 2024
0b22f2b
Rename spacing into space
paulinea Oct 23, 2024
7f91d84
Rename strings
paulinea Oct 23, 2024
9b76204
Add WithArrow tokens illustrations
paulinea Oct 23, 2024
b696f73
Replace hardcoded spaces by tokens
paulinea Oct 24, 2024
79ca7ab
Factorize some code
paulinea Oct 24, 2024
3776da3
Improve size and space key tokens organization
paulinea Oct 25, 2024
d42faf4
Start adding dimension tokens in demo app
paulinea Oct 18, 2024
2629b8e
Add grid icon
paulinea Oct 22, 2024
116c516
Display grid tokens in demo app
paulinea Oct 22, 2024
cb5932d
Add grid illustrations
paulinea Oct 22, 2024
45db7e5
Replace Spacing by Space
paulinea Oct 23, 2024
f02c08f
Add header
paulinea Oct 24, 2024
d846e48
Move grid illustrations in TokenPropertyIllustration file
paulinea Oct 24, 2024
7fabe55
Fix broken build during rebase
paulinea Oct 25, 2024
133e5cb
Add grid illustrations
paulinea Oct 22, 2024
ae85afa
Add color tokens to the library and use them in the demo app
paulinea Oct 23, 2024
b1891e8
Split color semantic tokens file in several files
paulinea Oct 23, 2024
5fa3502
Fix colors to match demo app design
paulinea Oct 24, 2024
4d1a863
Update paparazzi snapshots
paulinea Oct 24, 2024
ee0f866
Split color tokens keys in several enums
paulinea Oct 24, 2024
f6ee355
Improve color key tokens organization
paulinea Oct 25, 2024
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
33 changes: 33 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,47 @@ Any use or displaying shall constitute an infringement under intellectual proper
app/src/main/res/drawable/ic_border.xml
app/src/main/res/drawable/ic_component_atom.xml
app/src/main/res/drawable/ic_design_token_figma.xml
app/src/main/res/drawable/ic_design_token_figma_no_padding.xml
app/src/main/res/drawable/ic_dimension.xml
app/src/main/res/drawable/ic_filter_effects.xml
app/src/main/res/drawable/ic_info.xml
app/src/main/res/drawable/ic_layers.xml
app/src/main/res/drawable/ic_menu_grid.xml
app/src/main/res/drawable/ic_solar_palette.xml
app/src/main/res/drawable/ic_typography.xml
app/src/main/res/drawable/ic_ui_dark_mode.xml
app/src/main/res/drawable/ic_ui_light_mode.xml
app/src/main/res/drawable/il_opacity_union.xml
app/src/main/res/drawable-hdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-hdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-hdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-mdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-mdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-mdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-xhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-xhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-xhdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-xxhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-xxhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-xxhdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-xxxhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-xxxhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-xxxhdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-night-hdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-night-hdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-night-hdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-night-mdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-night-mdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-night-mdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-night-xhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-night-xhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-night-xhdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-night-xxhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-night-xxhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-night-xxhdpi/il_tokens_grid_min_width.png
app/src/main/res/drawable-night-xxxhdpi/il_tokens_grid_column_margin.png
app/src/main/res/drawable-night-xxxhdpi/il_tokens_grid_max_width.png
app/src/main/res/drawable-night-xxxhdpi/il_tokens_grid_min_width.png

docs/images/favicon-16x16.png
docs/images/orange-logo.svg
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/com/orange/ouds/app/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ import com.orange.ouds.app.R
import com.orange.ouds.app.ui.navigation.appNavGraph
import com.orange.ouds.app.ui.utilities.isDarkModeEnabled
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.extensions.orElse
import com.orange.ouds.foundation.utilities.UiModePreviews
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

@Composable
Expand Down Expand Up @@ -152,15 +155,14 @@ private fun ChangeThemeDialog(themeManager: ThemeManager, dismissDialog: () -> U
Dialog(onDismissRequest = dismissDialog) {
Column(
modifier = Modifier
.background(OudsTheme.colorScheme.surfaceVariant)
.background(OudsColorKeyToken.Background.Secondary.value)
.selectableGroup()
) {
//TODO Replace hard coded values by tokens when available and use OUDS typography
Text(
text = stringResource(R.string.app_themeDialog_label),
modifier = Modifier
.padding(top = 16.dp, bottom = 8.dp)
.padding(horizontal = 16.dp),
.padding(top = OudsSpaceKeyToken.Fixed.Medium.value, bottom = OudsSpaceKeyToken.Fixed.Short.value)
.padding(horizontal = OudsSpaceKeyToken.Fixed.Medium.value),
style = MaterialTheme.typography.titleLarge
)
themeManager.availableThemes.forEach { theme ->
Expand All @@ -180,7 +182,7 @@ private fun ChangeThemeDialog(themeManager: ThemeManager, dismissDialog: () -> U
},
role = Role.RadioButton
)
.padding(horizontal = 16.dp),
.padding(horizontal = OudsSpaceKeyToken.Fixed.Medium.value),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
Expand All @@ -190,7 +192,7 @@ private fun ChangeThemeDialog(themeManager: ThemeManager, dismissDialog: () -> U
Text(
text = theme.name,
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(start = 16.dp)
modifier = Modifier.padding(start = OudsSpaceKeyToken.Fixed.Medium.value)
)
}
}
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.OudsSpacingFixedKeyToken
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 @@ -49,10 +48,10 @@ fun ComponentsScreen() {

Box(
modifier = Modifier
.padding(top = OudsSpacingFixedKeyToken.Medium.value)
.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 @@ -28,7 +28,7 @@ import com.orange.ouds.app.ui.tokens.addTokensNavGraph
* Root navigation graph of the application
*/
fun NavGraphBuilder.appNavGraph(navController: NavController) {
addTokensNavGraph()
addTokensNavGraph(navController)
addAboutNavGraph()
addBottomBarNavGraph(navController)
}
Expand All @@ -38,7 +38,7 @@ fun NavGraphBuilder.appNavGraph(navController: NavController) {
*/
private fun NavGraphBuilder.addBottomBarNavGraph(navController: NavController) {
composable(BottomBarItem.Tokens.route) { from ->
TokensScreen(onTokenClick = { id -> navController.navigateToElement(TokensNavigation.TokenCategoryDetailRoute, id, from) })
TokensScreen(onTokenCategoryClick = { id -> navController.navigateToElement(TokensNavigation.TokenCategoryDetailRoute, id, from) })
}
composable(BottomBarItem.Components.route) { _ ->
ComponentsScreen()
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/com/orange/ouds/app/ui/tokens/Token.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Software Name: OUDS Android
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Android library of reusable graphical components
*/

package com.orange.ouds.app.ui.tokens

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import com.orange.ouds.app.R

data class Token<T>(val name: String, val value: T) {
val literalValue: String
@Composable
get() = when (value) {
is Float -> stringResource(id = R.string.app_tokens_floatFormat_label, value)
is Dp -> stringResource(id = R.string.app_tokens_dpFormat_label, value.toString().replace(".0.dp", "").substringBeforeLast(".dp"))
is TextStyle -> stringResource(id = R.string.app_tokens_spFormat_label, value.fontSize.toString().replace(".0.sp", "").substringBeforeLast(".sp"))
else -> value.toString()
}
}
Loading