Skip to content
Open
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 @@ -56,7 +56,7 @@ fun AlertMessageDemoScreen() {
bottomSheetContent = { AlertMessageDemoBottomSheetContent(state = state) },
codeSnippet = { alertMessageDemoCodeSnippet(state = state, themeDrawableResources = themeDrawableResources) },
demoContent = { AlertMessageDemoContent(state = state) },
version = OudsVersion.Component.Alert
version = OudsVersion.Component.AlertMessage
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun InlineAlertDemoScreen() {
bottomSheetContent = { InlineAlertDemoBottomSheetContent(state = state) },
codeSnippet = { inlineAlertDemoCodeSnippet(state = state, themeDrawableResources = themeDrawableResources) },
demoContent = { InlineAlertDemoContent(state = state) },
version = OudsVersion.Component.Alert
version = OudsVersion.Component.InlineAlert
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun FilterChipDemoScreen() {
bottomSheetContent = { ChipDemoBottomSheetContent(state = state) },
codeSnippet = { filterChipDemoCodeSnippet(state = state, themeDrawableResources = themeDrawableResources) },
demoContent = { FilterChipDemoContent(state = state) },
version = OudsVersion.Component.Chip
version = OudsVersion.Component.FilterChip
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun SuggestionChipDemoScreen() {
bottomSheetContent = { ChipDemoBottomSheetContent(state = state) },
codeSnippet = { suggestionChipDemoCodeSnippet(state = state, themeDrawableResources = themeDrawableResources) },
demoContent = { SuggestionChipDemoContent(state = state) },
version = OudsVersion.Component.Chip
version = OudsVersion.Component.SuggestionChip
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun NavigationBarDemoScreen() {
},
demoContent = { NavigationBarDemoContent(state = state) },
demoContentPaddingValues = PaddingValues(horizontal = OudsTheme.spaces.fixed.none),
version = OudsVersion.Component.Bar
version = OudsVersion.Component.NavigationBar
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun TopAppBarDemoScreen() {
codeSnippet = { topAppBarDemoCodeSnippet(state = state, themeDrawableResources = themeDrawableResources) },
demoContent = { TopAppBarDemoContent(state = state) },
demoContentPaddingValues = PaddingValues(horizontal = OudsTheme.spaces.fixed.none),
version = OudsVersion.Component.Bar
version = OudsVersion.Component.NavigationBar // TODO Update to AppBar version when available
)
}

Expand Down
50 changes: 40 additions & 10 deletions buildSrc/src/main/kotlin/com/orange/ouds/gradle/Component.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ import com.orange.ouds.theme.OudsVersion
import org.gradle.api.Project

enum class Component {
Alert,
AlertMessage,
Badge,
Bar,
BadgeCount,
BadgeIcon,
BottomSheet,
BulletList,
Button,
Checkbox,
Chip,
Divider,
Fab,
FilterChip,
InlineAlert,
InputTag,
Link,
NavigationBar,
PasswordInput,
PinCodeInput,
RadioButton,
SuggestionChip,
Switch,
Tag,
TextArea,
Expand All @@ -36,41 +43,64 @@ enum class Component {
val version: String
get() = with(OudsVersion.Component) {
when (this@Component) {
Component.Alert -> Alert
Component.AlertMessage -> AlertMessage
Component.Badge -> Badge
Component.Bar -> Bar
Component.BadgeCount -> BadgeCount
Component.BadgeIcon -> BadgeIcon
Component.BottomSheet -> BottomSheet
Component.BulletList -> BulletList
Component.Button -> Button
Component.Checkbox -> Checkbox
Component.Chip -> Chip
Component.Divider -> Divider
Component.Fab -> Fab
Component.FilterChip -> FilterChip
Component.InlineAlert -> InlineAlert
Component.InputTag -> InputTag
Component.Link -> Link
Component.NavigationBar -> NavigationBar
Component.PasswordInput -> PasswordInput
Component.PinCodeInput -> PinCodeInput
Component.RadioButton -> RadioButton
Component.SuggestionChip -> SuggestionChip
Component.Switch -> Switch
Component.Tag -> Tag
Component.TextArea -> TextArea
Component.TextInput -> TextInput
}
}

val designName: String
get() {
// Convert enum name to design name (e.g., "BadgeIcon" -> "Badge Icon")
return this.name
.replace(Regex("([a-z])([A-Z])"), "$1 $2")
.replace("Pin", "PIN")
.replace("Fab", "FAB")
}

fun getSourceFilePaths(project: Project): List<String> {
val filenames = when (this) {
Alert -> listOf("OudsAlertMessage", "OudsInlineAlert")
AlertMessage -> listOf("OudsAlertMessage")
Badge -> listOf("OudsBadge")
Bar -> listOf("OudsNavigationBar", "OudsTopAppBar")
BadgeCount -> listOf("OudsBadge")
BadgeIcon -> listOf("OudsBadge")
BottomSheet -> listOf("OudsBottomSheetScaffold", "OudsModalBottomSheet")
BulletList -> listOf("OudsBulletList")
Button -> listOf("OudsButton")
Checkbox -> listOf("OudsCheckbox", "OudsCheckboxItem")
Chip -> listOf("OudsFilterChip", "OudsSuggestionChip")
Divider -> listOf("OudsDivider")
Fab -> listOf("OudsFloatingActionButton")
FilterChip -> listOf("OudsFilterChip")
InlineAlert -> listOf("OudsInlineAlert")
InputTag -> listOf("OudsInputTag")
Link -> listOf("OudsLink")
NavigationBar -> listOf("OudsNavigationBar") // TODO Waiting for a specific version number for TopAppBar (in Maxime's TODO)
PasswordInput -> listOf("OudsPasswordInput")
PinCodeInput -> listOf("OudsPinCodeInput")
RadioButton -> listOf("OudsRadioButton", "OudsRadioButtonItem")
SuggestionChip -> listOf("OudsSuggestionChip")
Switch -> listOf("OudsSwitch", "OudsSwitchItem")
Tag -> listOf("OudsTag", "OudsInputTag")
Tag -> listOf("OudsTag")
TextArea -> listOf("OudsTextArea")
TextInput -> listOf("OudsTextInput")
}
Expand Down
57 changes: 37 additions & 20 deletions buildSrc/src/main/kotlin/documentation.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ private val moduleDocumentationDirectories = listOf(
"theme-wireframe"
)

private val draftVersion = "Draft"

project.extra["moduleDocumentationDirectories"] = moduleDocumentationDirectories

tasks.register<DefaultTask>("prepareDocumentation") {
Expand Down Expand Up @@ -64,22 +66,28 @@ tasks.register<DefaultTask>("prepareDocumentation") {

tasks.register<DefaultTask>("checkDocumentation") {
doLast {
val componentVersionRegex = "Design version: (.*)$".toRegex()
val componentsByFile = mutableMapOf<String, MutableList<Component>>()
Component.entries.forEach { component ->
component.getSourceFilePaths(project).forEach { sourceFilePath ->
val versionByLineIndex = File(sourceFilePath).readLines()
.mapIndexedNotNull { index, line ->
componentVersionRegex.find(line)
?.groupValues
?.getOrNull(1)
?.let { version ->
index to version
}
}
versionByLineIndex.forEach { (lineIndex, version) ->
if (version != component.version) {
throw GradleException("Component version at line ${lineIndex + 1} in $sourceFilePath is not up to date. Please launch updateDocumentation Gradle task.")
}
component.getSourceFilePaths(project).forEach { filePath ->
componentsByFile.getOrPut(filePath) { mutableListOf() }.add(component)
}
}

componentsByFile.forEach { (filePath, components) ->
val content = File(filePath).readText()
val componentByDesignName = components.associateBy { it.designName }

val pattern = "> Design name: (.+?)\\s*\\n \\*\\n \\* > Design version: ([^\n]+)".toRegex()
val matches = pattern.findAll(content).toList()
matches.forEach { match ->
val designName = match.groupValues[1]
val version = match.groupValues[2]
val component = componentByDesignName[designName]
?: throw GradleException("Unknown design name '$designName' in $filePath. Expected one of: ${components.joinToString { it.designName }}.")

val componentVersion = if (component.version == "0.0.0") draftVersion else component.version
if (version != componentVersion) {
throw GradleException("Design version for '$designName' in $filePath is '$version' but expected '${componentVersion}'. Please launch updateDocumentation Gradle task.")
}
}
}
Expand All @@ -88,13 +96,22 @@ tasks.register<DefaultTask>("checkDocumentation") {

tasks.register<DefaultTask>("updateDocumentation") {
doLast {
val componentVersionRegex = "(Design version: ).*".toRegex()
val componentsByFile = mutableMapOf<String, MutableList<Component>>()
Component.entries.forEach { component ->
component.getSourceFilePaths(project).forEach { sourceFilePath ->
File(sourceFilePath).replace(componentVersionRegex) { matchResult ->
"${matchResult.groupValues[1]}${component.version}"
}
component.getSourceFilePaths(project).forEach { filePath ->
componentsByFile.getOrPut(filePath) { mutableListOf() }.add(component)
}
}

componentsByFile.forEach { (filePath, components) ->
var content = File(filePath).readText()
components.forEach { component ->
val componentVersion = if (component.version == "0.0.0") draftVersion else component.version
val pattern = "(> Design name: ${component.designName}\\s*\\n \\*\\n \\* > Design version: )([^\n]+)".toRegex()
content = content.replace(pattern, "$1$componentVersion")
}

File(filePath).writeText(content)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import com.orange.ouds.theme.OudsThemeContract
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-alert-message)
*
* > Design name: Alert Message
*
* > Design version: 1.1.0
*
* @param label Label displayed in the alert message. Main message that should be short, clear, and readable at a glance.
Expand Down Expand Up @@ -145,14 +147,14 @@ fun OudsAlertMessage(
) {
Column(verticalArrangement = Arrangement.spacedBy(spaceRowGap.value)) {
Text(
modifier = Modifier.widthIn(max = OudsTheme.sizes.maxWidth.type.label.large),
modifier = Modifier.widthIn(max = OudsTheme.sizes.maxWidth.label.large),
text = label,
color = status.contentColor,
style = OudsTheme.typography.label.moderate.large
)
description?.let {
Text(
modifier = Modifier.widthIn(max = OudsTheme.sizes.maxWidth.type.label.medium),
modifier = Modifier.widthIn(max = OudsTheme.sizes.maxWidth.label.medium),
text = description,
color = status.contentColor,
style = OudsTheme.typography.label.default.medium
Expand Down Expand Up @@ -387,7 +389,7 @@ private fun OudsAlertMessageBulletListItem(label: String, color: Color) {
modifier = Modifier
.fillMaxHeight()
.wrapContentHeight() // Allows to center the text vertically when its height is smaller than the row height
.widthIn(max = OudsTheme.sizes.maxWidth.type.label.medium),
.widthIn(max = OudsTheme.sizes.maxWidth.label.medium),
text = label,
style = OudsTheme.typography.label.default.medium,
color = color
Expand Down
10 changes: 8 additions & 2 deletions core/src/main/java/com/orange/ouds/core/component/OudsBadge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ import kotlin.enums.enumEntries
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-badge)
*
* > Design name: Badge
*
* > Design version: 1.2.0
*
* @param modifier The [Modifier] to be applied to this badge.
Expand Down Expand Up @@ -123,6 +125,8 @@ fun OudsBadge(
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-badge-count)
*
* > Design name: Badge Count
*
* > Design version: 1.2.0
*
* @param count The number displayed in the badge. Minimum and maximum values are 0 and 99 respectively.
Expand Down Expand Up @@ -171,7 +175,9 @@ fun OudsBadge(
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-badge-icon)
*
* > Design version: 1.2.0
* > Design name: Badge Icon
*
* > Design version: 1.3.0
*
* @param modifier The [Modifier] to be applied to this badge.
* @param enabled Controls the enabled appearance of the badge.
Expand Down Expand Up @@ -325,7 +331,7 @@ private fun contentPadding(size: OudsBadgeSize, count: Int?, icon: OudsBadgeIcon
when {
count != null && size == OudsBadgeSize.Medium -> PaddingValues(horizontal = spacePaddingInlineMedium.value * scale)
count != null && size == OudsBadgeSize.Large -> PaddingValues(horizontal = spacePaddingInlineLarge.value * scale)
icon != null && size in OudsBadgeSize.iconEntries -> PaddingValues(all = spaceInset.dp * scale)
icon != null && size in OudsBadgeSize.iconEntries -> PaddingValues(all = spaceInsetMediumLarge.dp * scale)
else -> PaddingValues(all = 0.dp)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import com.orange.ouds.theme.OudsThemeContract
*
* For a bottom sheet that appears in front of app content and requires user action to be dismissed (a modal behavior), consider using [OudsModalBottomSheet].
*
* > Design name: Bottom Sheet
*
* > Design version: Draft
*
* @param sheetContent The content of the bottom sheet.
* @param modifier The [Modifier] to be applied to the entire scaffold.
* @param scaffoldState The state of the bottom sheet scaffold, which controls its behavior. See [rememberBottomSheetScaffoldState].
Expand Down Expand Up @@ -86,7 +90,7 @@ fun OudsBottomSheetScaffold(
modifier = modifier,
scaffoldState = scaffoldState,
sheetPeekHeight = sheetPeekHeight,
sheetContainerColor = OudsTheme.colorScheme.overlay.modal,
sheetContainerColor = OudsTheme.colorScheme.overlay.modalSheet,
sheetContentColor = OudsTheme.colorScheme.content.default,
sheetShadowElevation = OudsTheme.elevations.emphasized,
sheetDragHandle = if (sheetDragHandle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ private const val MaxLevelCount = 3
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-bullet-list)
*
* > Design version: 1.0.0
* > Design name: Bullet List
*
* > Design version: 1.1.0
*
* @param modifier [Modifier] applied to the list.
* @param type The visual type of the list (e.g., ordered, unordered, bare). See [OudsBulletListType].
Expand Down Expand Up @@ -244,8 +246,8 @@ private fun OudsBulletListItem(
parentNodes = parentNodes
)
val textMaxWidth = when (currentTextStyle.fontSize) {
OudsBulletListFontSize.BodyLarge -> OudsTheme.sizes.maxWidth.type.body.large
OudsBulletListFontSize.BodyMedium -> OudsTheme.sizes.maxWidth.type.body.medium
OudsBulletListFontSize.BodyLarge -> OudsTheme.sizes.maxWidth.body.large
OudsBulletListFontSize.BodyMedium -> OudsTheme.sizes.maxWidth.body.medium
}
Text(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ import com.orange.ouds.theme.tokens.components.OudsButtonMonoTokens
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-button)
*
* > Design name: Button
*
* > Design version: 3.2.0
*
* @param label Label displayed in the button describing the button action. Use action verbs or phrases to tell the user what will happen next.
Expand Down Expand Up @@ -150,6 +152,8 @@ fun OudsButton(
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-button)
*
* > Design name: Button
*
* > Design version: 3.2.0
*
* @param icon Icon displayed in the button. Use an icon to add additional affordance where the icon has a clear and well-established meaning.
Expand Down Expand Up @@ -206,6 +210,8 @@ fun OudsButton(
*
* > Design guidelines: [unified-design-system.orange.com](https://r.orange.fr/r/S-ouds-doc-button)
*
* > Design name: Button
*
* > Design version: 3.2.0
*
* @param icon Icon displayed in the button. Use an icon to add additional affordance where the icon has a clear and well-established meaning.
Expand Down
Loading
Loading